fix: some static shit

This commit is contained in:
TrèsAbhi committed 2024-09-08 21:29:18 -05:00
1 parent d306b51c2c
commit 250b61b68d
8 files changed
+38 -46

No files matched your search

+2 -1
View File
@@ -200,5 +200,6 @@
"deno.enable": false, "deno.enable": false,
"deno.unstable": false, "deno.unstable": false,
"cSpell.enableFiletypes": ["glsl", "proto3"], "cSpell.enableFiletypes": ["glsl", "proto3"],
"typescript.tsdk": "node_modules\\typescript\\lib" "typescript.tsdk": "node_modules\\typescript\\lib",
"liveServer.settings.multiRootWorkspaceName": "blitzkit"
} }
BIN
View File
Binary file not shown.
+2 -1
View File
@@ -35,10 +35,11 @@
"lodash": "^4.17.21" "lodash": "^4.17.21"
}, },
"devDependencies": { "devDependencies": {
"@types/bun": "latest",
"@types/node": "^22.5.4",
"esbuild": "^0.19.12", "esbuild": "^0.19.12",
"prettier": "^3.3.3", "prettier": "^3.3.3",
"prisma": "^5.19.1", "prisma": "^5.19.1",
"@types/bun": "latest",
"typescript": "^5.5.4" "typescript": "^5.5.4"
} }
} }
@@ -1,43 +1,28 @@
import { assertSecret } from '@blitzkit/core'; import { readdir } from 'fs/promises';
export async function generateStaticParams() { export async function generateStaticParams() {
return await fetch( return await readdir('../../docs').then((directories) =>
`https://api.github.com/repos/tresabhi/blitzkit/contents/docs?ref=${assertSecret( Promise.all(
process.env.NEXT_PUBLIC_ASSET_BRANCH, directories
)}`, .filter(
) (directory) =>
.then((response) => response.json() as Promise<{ name: string }[]>) !['.vitepress', 'public'].includes(directory) &&
.then((directories) => !directory.endsWith('.md'),
Promise.all( )
directories .map((directory) =>
.filter( readdir(`../../docs/${directory}`).then((files) =>
(directory) => Promise.all(
!['.vitepress', 'public', 'index.md'].includes(directory.name), files
) .filter((file) => file.endsWith('.md'))
.map((directory) => .map((file) => ({
fetch( directory,
`https://api.github.com/repos/tresabhi/blitzkit/contents/docs/${directory.name}?ref=${assertSecret( document: file.replace(/\.md$/, ''),
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,
})),
),
), ),
), ),
) ).then((directories) => directories.flat()),
.then((docs) => docs.flat()); );
} }
export default function Layout({ children }: { children: React.ReactNode }) { export default function Layout({ children }: { children: React.ReactNode }) {
@@ -1,6 +1,7 @@
'use client'; 'use client';
import { Code, Heading } from '@radix-ui/themes'; import { Code, Heading } from '@radix-ui/themes';
import { useSearchParams } from 'next/navigation';
import { useMemo } from 'react'; import { useMemo } from 'react';
import { PageWrapper } from '../../../../../components/PageWrapper'; import { PageWrapper } from '../../../../../components/PageWrapper';
import * as EmbedState from '../../../../../stores/embedState'; import * as EmbedState from '../../../../../stores/embedState';
@@ -13,16 +14,17 @@ export interface EmbedPreviewControllerProps {
export default function Page({ export default function Page({
params, params,
searchParams,
}: { }: {
params: { embed: keyof typeof configurations }; 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 config = configurations[params.embed];
const initialState = useMemo( const initialState = useMemo(
() => ({ () => ({
...extractEmbedConfigDefaults(config), ...extractEmbedConfigDefaults(config),
...(JSON.parse(searchParams.state) as EmbedState.EmbedState), ...(JSON.parse(stateParam) as EmbedState.EmbedState),
}), }),
[params.embed], [params.embed],
); );
@@ -44,7 +44,8 @@ export function Navbar() {
const pathname = usePathname(); const pathname = usePathname();
const logins = App.use((state) => state.logins); const logins = App.use((state) => state.logins);
const mutateApp = App.useMutation(); const mutateApp = App.useMutation();
const tools = [homeTool, ...TOOLS]; const toolsFiltered = TOOLS.filter((tool) => !('href' in tool));
const tools = [homeTool, ...toolsFiltered];
const isBranchNamed = const isBranchNamed =
process.env.NEXT_PUBLIC_ASSET_BRANCH && process.env.NEXT_PUBLIC_ASSET_BRANCH &&
BRANCH_NAMES[process.env.NEXT_PUBLIC_ASSET_BRANCH]; BRANCH_NAMES[process.env.NEXT_PUBLIC_ASSET_BRANCH];
@@ -99,7 +100,7 @@ export function Navbar() {
justify="center" justify="center"
className={styles.tools} className={styles.tools}
> >
{TOOLS.map((tool, index) => { {toolsFiltered.map((tool, index) => {
const unavailableOnBranch = tool.branches?.every( const unavailableOnBranch = tool.branches?.every(
(branch) => (branch) =>
branch !== branch !==
+2 -1
View File
@@ -139,6 +139,7 @@ export const embedTool: Tool = {
}, },
image: 'Q0faRYg', image: 'Q0faRYg',
branches: ['main', 'dev', 'opentest'], branches: ['main', 'dev', 'opentest'],
href: '',
}; };
export const homeTool: Tool = { export const homeTool: Tool = {
@@ -154,6 +155,6 @@ export const TOOLS: Tool[] = [
compareTool, compareTool,
tankPerformanceTool, tankPerformanceTool,
sessionTool, sessionTool,
// embedTool, embedTool,
ratingTool, ratingTool,
]; ];
+2 -1
View File
@@ -10,6 +10,7 @@
"include": [ "include": [
"src/**/*", "src/**/*",
".next/types/**/*.ts", ".next/types/**/*.ts",
"../../dist/website/types/**/*.ts" "../../dist/website/types/**/*.ts",
"dist/website/types/**/*.ts"
] ]
} }