diff --git a/.vscode/settings.json b/.vscode/settings.json index 5b01a0358..1c67db08c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -200,5 +200,6 @@ "deno.enable": false, "deno.unstable": false, "cSpell.enableFiletypes": ["glsl", "proto3"], - "typescript.tsdk": "node_modules\\typescript\\lib" + "typescript.tsdk": "node_modules\\typescript\\lib", + "liveServer.settings.multiRootWorkspaceName": "blitzkit" } diff --git a/bun.lockb b/bun.lockb index f554250ad..f9555e289 100644 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index e2b61b78f..0c00fafba 100644 --- a/package.json +++ b/package.json @@ -35,10 +35,11 @@ "lodash": "^4.17.21" }, "devDependencies": { + "@types/bun": "latest", + "@types/node": "^22.5.4", "esbuild": "^0.19.12", "prettier": "^3.3.3", "prisma": "^5.19.1", - "@types/bun": "latest", "typescript": "^5.5.4" } } diff --git a/packages/website/src/app/docs/[directory]/[document]/layout.tsx b/packages/website/src/app/docs/[directory]/[document]/layout.tsx index 82286e714..be5ab03af 100644 --- a/packages/website/src/app/docs/[directory]/[document]/layout.tsx +++ b/packages/website/src/app/docs/[directory]/[document]/layout.tsx @@ -1,43 +1,28 @@ -import { assertSecret } from '@blitzkit/core'; +import { readdir } from 'fs/promises'; export async function generateStaticParams() { - return await fetch( - `https://api.github.com/repos/tresabhi/blitzkit/contents/docs?ref=${assertSecret( - process.env.NEXT_PUBLIC_ASSET_BRANCH, - )}`, - ) - .then((response) => response.json() as Promise<{ name: string }[]>) - .then((directories) => - Promise.all( - directories - .filter( - (directory) => - !['.vitepress', 'public', 'index.md'].includes(directory.name), - ) - .map((directory) => - fetch( - `https://api.github.com/repos/tresabhi/blitzkit/contents/docs/${directory.name}?ref=${assertSecret( - process.env.NEXT_PUBLIC_ASSET_BRANCH, - )}`, - ) - .then( - (response) => response.json() as Promise<{ name: string }[]>, - ) - .then((docs) => - docs - .map((document) => { - console.log(`${directory.name}/${document.name}`); - return document; - }) - .map((document) => ({ - document: document.name.split('.').slice(0, -1).join('.'), - directory: directory.name, - })), - ), + return await readdir('../../docs').then((directories) => + Promise.all( + directories + .filter( + (directory) => + !['.vitepress', 'public'].includes(directory) && + !directory.endsWith('.md'), + ) + .map((directory) => + readdir(`../../docs/${directory}`).then((files) => + Promise.all( + files + .filter((file) => file.endsWith('.md')) + .map((file) => ({ + directory, + document: file.replace(/\.md$/, ''), + })), + ), ), - ), - ) - .then((docs) => docs.flat()); + ), + ).then((directories) => directories.flat()), + ); } export default function Layout({ children }: { children: React.ReactNode }) { diff --git a/packages/website/src/app/tools/embed/[embed]/host/page.tsx b/packages/website/src/app/tools/embed/[embed]/host/page.tsx index 35eb18234..c30994249 100644 --- a/packages/website/src/app/tools/embed/[embed]/host/page.tsx +++ b/packages/website/src/app/tools/embed/[embed]/host/page.tsx @@ -1,6 +1,7 @@ 'use client'; import { Code, Heading } from '@radix-ui/themes'; +import { useSearchParams } from 'next/navigation'; import { useMemo } from 'react'; import { PageWrapper } from '../../../../../components/PageWrapper'; import * as EmbedState from '../../../../../stores/embedState'; @@ -13,16 +14,17 @@ export interface EmbedPreviewControllerProps { export default function Page({ params, - searchParams, }: { params: { embed: keyof typeof configurations }; - searchParams: { state: string }; }) { + const searchParams = useSearchParams(); + // TODO: check for this? idk lol + const stateParam = searchParams.get('state')!; const config = configurations[params.embed]; const initialState = useMemo( () => ({ ...extractEmbedConfigDefaults(config), - ...(JSON.parse(searchParams.state) as EmbedState.EmbedState), + ...(JSON.parse(stateParam) as EmbedState.EmbedState), }), [params.embed], ); diff --git a/packages/website/src/components/Navbar/index.tsx b/packages/website/src/components/Navbar/index.tsx index 537f7c875..003058c28 100644 --- a/packages/website/src/components/Navbar/index.tsx +++ b/packages/website/src/components/Navbar/index.tsx @@ -44,7 +44,8 @@ export function Navbar() { const pathname = usePathname(); const logins = App.use((state) => state.logins); const mutateApp = App.useMutation(); - const tools = [homeTool, ...TOOLS]; + const toolsFiltered = TOOLS.filter((tool) => !('href' in tool)); + const tools = [homeTool, ...toolsFiltered]; const isBranchNamed = process.env.NEXT_PUBLIC_ASSET_BRANCH && BRANCH_NAMES[process.env.NEXT_PUBLIC_ASSET_BRANCH]; @@ -99,7 +100,7 @@ export function Navbar() { justify="center" className={styles.tools} > - {TOOLS.map((tool, index) => { + {toolsFiltered.map((tool, index) => { const unavailableOnBranch = tool.branches?.every( (branch) => branch !== diff --git a/packages/website/src/constants/tools.tsx b/packages/website/src/constants/tools.tsx index 42143f4a1..150274549 100644 --- a/packages/website/src/constants/tools.tsx +++ b/packages/website/src/constants/tools.tsx @@ -139,6 +139,7 @@ export const embedTool: Tool = { }, image: 'Q0faRYg', branches: ['main', 'dev', 'opentest'], + href: '', }; export const homeTool: Tool = { @@ -154,6 +155,6 @@ export const TOOLS: Tool[] = [ compareTool, tankPerformanceTool, sessionTool, - // embedTool, + embedTool, ratingTool, ]; diff --git a/packages/website/tsconfig.json b/packages/website/tsconfig.json index 485b9f36c..b85067d35 100644 --- a/packages/website/tsconfig.json +++ b/packages/website/tsconfig.json @@ -10,6 +10,7 @@ "include": [ "src/**/*", ".next/types/**/*.ts", - "../../dist/website/types/**/*.ts" + "../../dist/website/types/**/*.ts", + "dist/website/types/**/*.ts" ] }