diff --git a/src/app/components/Clients.tsx b/src/app/components/Clients.tsx index a19b0de..690cbb5 100644 --- a/src/app/components/Clients.tsx +++ b/src/app/components/Clients.tsx @@ -1,5 +1,6 @@ 'use client'; import { useState } from 'react'; +import { VERSIONS } from '../constants'; import styles from './Clients.module.css'; export default function Clients({ @@ -7,76 +8,7 @@ export default function Clients({ }: { version: string; }) { - const csharpSvg = ` - - - - - - - - `; - - const versionClients = { - 1: [ - { - name: 'C#', - repoLink: - 'https://github.com/onspring-technologies/onspring-api-sdk/tree/v1.1', - installCommand: - 'dotnet add package Onspring.API.SDK --version 2.1.0', - svg: csharpSvg, - official: true, - }, - ], - 2: [ - { - name: 'C#', - repoLink: - 'https://github.com/onspring-technologies/onspring-api-sdk', - installCommand: - 'dotnet add package Onspring.API.SDK', - svg: csharpSvg, - official: true, - }, - { - name: 'Javascript', - repoLink: - 'https://github.com/StevanFreeborn/onspring-api-sdk-javascript', - installCommand: 'npm install onspring-api-sdk', - svg: ` - - - - - `, - official: false, - }, - { - name: 'Python', - repoLink: - 'https://github.com/StevanFreeborn/onspring-api-sdk-python', - installCommand: 'pip install OnspringApiSdk', - svg: ` - - - - - `, - official: false, - }, - ], - } as { - [key: string]: { - name: string; - repoLink: string; - installCommand: string; - svg: string; - official: boolean; - }[]; - }; - - const clients = versionClients[version]; + const clients = VERSIONS[version].clients; const [selectedClient, setSelectedClient] = useState( clients[0] ); diff --git a/src/app/components/NavBar.tsx b/src/app/components/NavBar.tsx index a22c71a..abd278c 100644 --- a/src/app/components/NavBar.tsx +++ b/src/app/components/NavBar.tsx @@ -2,29 +2,17 @@ import Link from 'next/link'; import { useState } from 'react'; +import { VERSIONS } from '../constants'; import { themes, useThemeContext } from '../context/theme'; -import { DocsStructure } from '../types/types'; +import { DocsStructure, Version } from '../types/types'; import styles from './NavBar.module.css'; import SectionDropdown from './SectionDropdown'; function VersionsDropdown({ version, }: { - version: string; + version: Version; }) { - const versions = { - version_001: { - name: 'Version 1', - path: '/version-1', - }, - version_002: { - name: 'Version 2', - path: '/', - }, - } as { [key: string]: { name: string; path: string } }; - - const currentVersion = versions[version]; - const [isDropdownOpen, setIsDropdownOpen] = useState(false); @@ -38,7 +26,7 @@ function VersionsDropdown({ className={styles.navLink} onClick={handleDropdownToggle} > - {currentVersion.name}{' '} + {version.name}{' '} {isDropdownOpen ? ( - {Object.keys(versions) - .filter(v => v !== version) + {Object.keys(VERSIONS) + .filter(v => VERSIONS[v].name !== version.name) .map(v => ( { setIsDropdownOpen(false); }} > - {versions[v].name} + {VERSIONS[v].name} ))} @@ -96,12 +84,14 @@ function VersionsDropdown({ } export default function NavBar({ - version, + versionDocStructure, }: { - version: DocsStructure; + versionDocStructure: DocsStructure; }) { const { theme } = useThemeContext(); const themeStyles = themes[theme]; + const currentVersion = + VERSIONS[versionDocStructure.version]; const [isNavOpen, setIsNavOpen] = useState(false); @@ -114,7 +104,9 @@ export default function NavBar({
@@ -134,18 +126,18 @@ export default function NavBar({ } >
  • - +
  • Official Docs
  • - {version.hasSwagger ? ( + {currentVersion.hasSwagger ? (
  • - +
    - +
  • diff --git a/src/app/components/SectionDropdown.tsx b/src/app/components/SectionDropdown.tsx index e6ff1a6..1435795 100644 --- a/src/app/components/SectionDropdown.tsx +++ b/src/app/components/SectionDropdown.tsx @@ -4,9 +4,9 @@ import { toKebabCase } from '../utils/stringUtils'; import styles from './SectionDropdown.module.css'; export default function SectionDropdown({ - version, + versionDocStructure, }: { - version: DocsStructure; + versionDocStructure: DocsStructure; }) { const { section, setSection } = useSectionContext(); const handleSelectChange = (e: any) => { @@ -28,7 +28,7 @@ export default function SectionDropdown({ return result; }; - const docs = getAllDocs(version.docs); + const docs = getAllDocs(versionDocStructure.docs); return (