feat: comments

This commit is contained in:
tresabhi committed 2025-03-18 18:32:14 -05:00
1 parent 9fb4607bba
commit cc3aa976db
12 files changed
+3137 -1902

No files matched your search

+9
View File
@@ -133,6 +133,14 @@ export const chartsTool: Tool = {
branches: ['main', 'dev', 'opentest', 'preview'],
};
export const apiTool: Tool = {
id: 'api',
button: {
color: 'indigo',
},
image: '0bWE5hC',
};
export const TOOLS: Tool[] = [
tanksTool,
compareTool,
@@ -142,5 +150,6 @@ export const TOOLS: Tool[] = [
sessionTool,
tierListTool,
embedTool,
apiTool,
// ratingTool,
];
@@ -0,0 +1,49 @@
---
import { Code, Flex, Link } from '@radix-ui/themes';
import { PageWrapper } from '../../../components/PageWrapper';
import { apiTool } from '../../../constants/tools';
import ToolLayout from '../../../layouts/ToolLayout.astro';
export { getStaticPaths } from '../index.astro';
const regex = /\/\*\*\n(( \* .+\n)+.+)\n \*\/\nexport const GET/gm;
const ROOT = '/src/pages/api/';
const glob = import.meta.glob('/src/pages/api/**/*.ts', {
eager: true,
query: '?raw',
import: 'default',
});
const apis: {
path: string;
content: string;
}[] = [];
for (const rawPath in glob) {
const content = (glob[rawPath] as string).replaceAll('\r', '');
const regexExecution = regex.exec(content);
if (!regexExecution?.[1]) continue;
const comment = regexExecution[1].replaceAll(/^ \* /gm, '');
console.log();
const path = rawPath.replace(ROOT, '');
apis.push({ path, content });
}
---
<ToolLayout tool={apiTool}>
<PageWrapper>
{
apis.map((api) => (
<Flex direction="column">
<Link href={api.path}>{api.path}</Link>
<Code>{api.content}</Code>
</Flex>
))
}
</PageWrapper>
</ToolLayout>
@@ -1,3 +1,4 @@
import { imgur } from '@blitzkit/core';
import { DEFAULT_LOCALE } from '@blitzkit/i18n';
import type { APIRoute, GetStaticPaths } from 'astro';
import { fetchGlossary } from '../../../core/blitz/fetchGlossary';
@@ -13,10 +14,18 @@ export const getStaticPaths = (async () => {
const glossary = await fetchGlossary(DEFAULT_LOCALE);
/**
* Test comment.
* Test comment.
* Test comment.
* Test comment.
* Test comment.
* Test comment.
*/
export const GET: APIRoute<{}, { avatar: string }> = async ({ params }) => {
const image =
glossary[`avatar_${params.avatar}`].image_url ??
'https://i.imgur.com/uXBiK05.jpeg';
imgur('uXBiK05', { format: 'jpeg' });
if (import.meta.env.MODE === 'development') {
return Response.redirect(image);