diff --git a/package-lock.json b/package-lock.json index 1243f1e..06e0ec4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,6 +19,7 @@ "@types/react-dom": "^18.3.1", "@vitejs/plugin-react": "^4.4.1", "autoprefixer": "^10.4.21", + "playwright": "^1.58.2", "postcss": "^8.5.3", "tailwindcss": "^3.4.17", "typescript": "~5.8.3", @@ -2085,6 +2086,53 @@ "node": ">= 6" } }, + "node_modules/playwright": { + "version": "1.58.2", + "resolved": "https://registry.npmmirror.com/playwright/-/playwright-1.58.2.tgz", + "integrity": "sha512-vA30H8Nvkq/cPBnNw4Q8TWz1EJyqgpuinBcHET0YVJVFldr8JDNiU9LaWAE1KqSkRYazuaBhTpB5ZzShOezQ6A==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright-core": "1.58.2" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "fsevents": "2.3.2" + } + }, + "node_modules/playwright-core": { + "version": "1.58.2", + "resolved": "https://registry.npmmirror.com/playwright-core/-/playwright-core-1.58.2.tgz", + "integrity": "sha512-yZkEtftgwS8CsfYo7nm0KE8jsvm6i/PTgVtB8DL726wNf6H2IMsDuxCpJj59KDaxCtSnrWan2AeDqM7JBaultg==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/playwright/node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmmirror.com/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, "node_modules/postcss": { "version": "8.5.8", "resolved": "https://registry.npmmirror.com/postcss/-/postcss-8.5.8.tgz", diff --git a/package.json b/package.json index 62169bc..c6db77d 100644 --- a/package.json +++ b/package.json @@ -8,20 +8,21 @@ "preview": "vite preview" }, "dependencies": { + "clsx": "^2.1.1", + "lucide-react": "^0.511.0", "react": "^18.3.1", "react-dom": "^18.3.1", - "lucide-react": "^0.511.0", - "clsx": "^2.1.1", "tailwind-merge": "^3.5.0" }, "devDependencies": { "@types/react": "^18.3.12", "@types/react-dom": "^18.3.1", "@vitejs/plugin-react": "^4.4.1", - "typescript": "~5.8.3", - "vite": "^6.3.5", - "tailwindcss": "^3.4.17", "autoprefixer": "^10.4.21", - "postcss": "^8.5.3" + "playwright": "^1.58.2", + "postcss": "^8.5.3", + "tailwindcss": "^3.4.17", + "typescript": "~5.8.3", + "vite": "^6.3.5" } } diff --git a/src/App.tsx b/src/App.tsx index ecedc2f..0d80ffa 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,6 +1,8 @@ import { ApiDocViewer } from './components/ApiDocViewer' +import { config } from './config' function App() { + document.title = config.projectName return } diff --git a/src/components/ApiDocViewer.tsx b/src/components/ApiDocViewer.tsx index 0c15633..eb53a56 100644 --- a/src/components/ApiDocViewer.tsx +++ b/src/components/ApiDocViewer.tsx @@ -3,9 +3,16 @@ import { DocTree } from './DocTree' import { DocContent } from './DocContent' import { parseMarkdown, buildFileTree } from '@/lib/parser' import type { DocFile, ParsedDoc } from '@/lib/types' -import { docs } from '@/data/docs' +import { config } from '@/config' -const DOCS_FILES: Record = docs +const modules = import.meta.glob('../docs/**/*.md', { as: 'raw', eager: true }) + +const DOCS_FILES: Record = Object.fromEntries( + Object.entries(modules).map(([path, content]) => { + const relativePath = path.replace('../docs/', '') + return [relativePath, content as string] + }) +) export const ApiDocViewer = () => { const [fileTree, setFileTree] = useState([]) @@ -14,8 +21,7 @@ export const ApiDocViewer = () => { useEffect(() => { const files = Object.keys(DOCS_FILES) - const basePath = '/docs' - const tree = buildFileTree(files, basePath) + const tree = buildFileTree(files, '/') setFileTree(tree) if (files.length > 0) { @@ -41,7 +47,7 @@ export const ApiDocViewer = () => { const handleReferenceClick = useCallback((ref: string) => { const normalizedRef = ref.replace('.md', '') - const allFiles = Object.keys(DOCS_FILES).map(k => k.replace('/docs/', '')) + const allFiles = Object.keys(DOCS_FILES) const match = allFiles.find(f => f.replace('.md', '') === normalizedRef) if (match) { setSelectedPath(match) @@ -52,7 +58,7 @@ export const ApiDocViewer = () => {