feat: migrate docs

This commit is contained in:
TrèsAbhi committed 2024-10-07 18:36:07 -05:00
1 parent dc37b23727
commit ea490628fb
15 files changed
+126 -282

No files matched your search

-39
View File
@@ -1,39 +0,0 @@
import { compareVersions } from 'compare-versions';
import { readdirSync } from 'fs';
import { parse } from 'path';
import { defineConfig } from 'vitepress';
import { getSidebar } from 'vitepress-plugin-auto-sidebar';
export default defineConfig({
title: 'BlitzKit',
description: '🎉 All-in-one Discord bot for everything World of Tanks Blitz',
base: '/blitzkit/',
outDir: '../dist/docs',
themeConfig: {
nav: [
{ text: 'Home', link: '/' },
{ text: 'Guide', link: '/guide/introduction' },
],
sidebar: [
...getSidebar({
collapsed: false,
contentDirs: ['guide', 'legal'],
contentRoot: '/docs/',
}),
{
text: 'Changelogs',
items: readdirSync('./docs/changelogs')
.map((file) => parse(file).name)
.sort(compareVersions)
.map((name) => ({ text: name, link: `/changelogs/${name}.html` })),
},
],
socialLinks: [
{ icon: 'github', link: 'https://github.com/tresabhi/blitzkit' },
],
},
});
-16
View File
@@ -1,16 +0,0 @@
// https://vitepress.dev/guide/custom-theme
import { h } from 'vue';
import Theme from 'vitepress/theme';
import './style.css';
export default {
extends: Theme,
Layout: () => {
return h(Theme.Layout, null, {
// https://vitepress.dev/guide/extending-default-theme#layout-slots
});
},
enhanceApp({ app, router, siteData }) {
// ...
},
};
-90
View File
@@ -1,90 +0,0 @@
/**
* Customize default theme styling by overriding CSS variables:
* https://github.com/vuejs/vitepress/blob/main/src/client/theme-default/styles/vars.css
*/
/**
* Colors
* -------------------------------------------------------------------------- */
:root {
--vp-c-brand: #646cff;
--vp-c-brand-light: #747bff;
--vp-c-brand-lighter: #9499ff;
--vp-c-brand-lightest: #bcc0ff;
--vp-c-brand-dark: #535bf2;
--vp-c-brand-darker: #454ce1;
--vp-c-brand-dimm: rgba(100, 108, 255, 0.08);
}
/**
* Component: Button
* -------------------------------------------------------------------------- */
:root {
--vp-button-brand-border: var(--vp-c-brand-light);
--vp-button-brand-text: var(--vp-c-white);
--vp-button-brand-bg: var(--vp-c-brand);
--vp-button-brand-hover-border: var(--vp-c-brand-light);
--vp-button-brand-hover-text: var(--vp-c-white);
--vp-button-brand-hover-bg: var(--vp-c-brand-light);
--vp-button-brand-active-border: var(--vp-c-brand-light);
--vp-button-brand-active-text: var(--vp-c-white);
--vp-button-brand-active-bg: var(--vp-button-brand-bg);
}
/**
* Component: Home
* -------------------------------------------------------------------------- */
:root {
--vp-home-hero-name-color: transparent;
--vp-home-hero-name-background: -webkit-linear-gradient(
120deg,
#bd34fe 30%,
#41d1ff
);
--vp-home-hero-image-background-image: linear-gradient(
-45deg,
#bd34fe 50%,
#47caff 50%
);
--vp-home-hero-image-filter: blur(40px);
}
@media (min-width: 640px) {
:root {
--vp-home-hero-image-filter: blur(56px);
}
}
@media (min-width: 960px) {
:root {
--vp-home-hero-image-filter: blur(72px);
}
}
/**
* Component: Custom Block
* -------------------------------------------------------------------------- */
:root {
--vp-custom-block-tip-border: var(--vp-c-brand);
--vp-custom-block-tip-text: var(--vp-c-brand-darker);
--vp-custom-block-tip-bg: var(--vp-c-brand-dimm);
}
.dark {
--vp-custom-block-tip-border: var(--vp-c-brand);
--vp-custom-block-tip-text: var(--vp-c-brand-lightest);
--vp-custom-block-tip-bg: var(--vp-c-brand-dimm);
}
/**
* Component: Algolia
* -------------------------------------------------------------------------- */
.DocSearch {
--docsearch-primary-color: var(--vp-c-brand) !important;
}
+1 -1
View File
@@ -2,7 +2,7 @@
This release of Blitzkrieg focuses mainly on **performance**. Blitzkrieg now uses **Satori** and **resvg** under the hood to render images resulting in a solid **2x to 8x performance boost** depending on the situation.
This only applies to `/today` and /stats` as they're the only commands that render an image currently.
This only applies to `/today` and `/stats` as they're the only commands that render an image currently.
We're working further on **performance optimizations**. Our goal is to deliver a message within **3 seconds or less**. We're close and we'll get there!
-30
View File
@@ -1,30 +0,0 @@
---
# https://vitepress.dev/reference/default-theme-home-page
layout: home
hero:
name: 'BlitzKit'
text: Everything Blitz, right in Discord
tagline: All-in-one Discord bot for everything World of Tanks Blitz
image:
src: '/assets/images/hero.png'
alt: 'blitzkit'
actions:
- theme: brand
text: Add to Discord Server
link: /guide/invite
- theme: alt
text: Guide
link: /guide/introduction
features:
- title: Clean and Efficient UI
icon: 🚀
details: BlitzKit is where concise meets efficient. Get the information you need in the way you want.
- title: Endless Possibilities
icon: 🛠
details: With endless ways to customize the output, it's guaranteed that you'll always get the information you need.
- title: Easy to Use
icon: 💻
details: Leveraging Discord's, Blitz Stars', and Wargaming's powerful APIS, Blitzkit does all the hard work for you.
---
Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

-2
View File
@@ -19,8 +19,6 @@
"urlon": "^3.1.0",
"react": "^18.3.1",
"@vanilla-extract/css": "^1.15.5",
"markdown-to-jsx": "^7.5.0",
"compare-versions": "^6.1.1",
"react-device-detect": "^2.2.3",
"react-dom": "^18.3.1",
"react-fuzzysort": "^1.0.1",
@@ -1,30 +0,0 @@
import { readdir } from 'fs/promises';
export async function generateStaticParams() {
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((directories) => directories.flat()),
);
}
export default function Layout({ children }: { children: React.ReactNode }) {
return children;
}
@@ -1,45 +0,0 @@
import { assertSecret } from '@blitzkit/core';
import { Table } from '@radix-ui/themes';
import Markdown from 'markdown-to-jsx';
import { use } from 'react';
import { Link } from '../../../../components/Link';
import { PageWrapper } from '../../../../components/PageWrapper';
export default function Page({
params,
}: {
params: { document: string; directory: string };
}) {
const markdown = use(
fetch(
`https://raw.githubusercontent.com/tresabhi/blitzkit/${assertSecret(
process.env.PUBLIC_ASSET_BRANCH,
)}/docs/${params.directory}/${params.document}.md`,
).then((response) => response.text()),
);
const title = markdown.split('\n')[0].replaceAll(/[^a-zA-Z0-9 \.&]/g, '');
return (
<>
<title>{title}</title>
<PageWrapper>
<Markdown
options={{
overrides: {
a: { component: Link },
table: { component: Table.Root },
thead: { component: Table.Header },
tbody: { component: Table.Body },
tr: { component: Table.Row },
th: { component: Table.ColumnHeaderCell },
td: { component: Table.Cell },
},
}}
>
{markdown}
</Markdown>
</PageWrapper>
</>
);
}
@@ -1,29 +0,0 @@
import { Flex, Heading } from '@radix-ui/themes';
import { compareVersions } from 'compare-versions';
import versions from '../../../../public/assets/versions.json';
import { Link } from '../../../components/Link';
import { PageWrapper } from '../../../components/PageWrapper';
export default async function Page() {
return (
<>
<title>BlitzKit - Patch Notes</title>
<PageWrapper>
<Heading>BlitzKit patch notes</Heading>
<Flex wrap="wrap" gap="4">
{versions
.sort(compareVersions)
.reverse()
.map((version) => {
return (
<Link key={version} href={`/docs/changelogs/${version}`}>
{version}
</Link>
);
})}
</Flex>
</PageWrapper>{' '}
</>
);
}
+2
View File
@@ -24,6 +24,8 @@
"nanostores": "^0.11.3",
"purgecss": "^6.0.0",
"react": "^18.3.1",
"markdown-to-jsx": "^7.5.0",
"compare-versions": "^6.1.1",
"react-dom": "^18.3.1",
"react-promise-suspense": "^0.3.4",
"three": "0.159.0",
@@ -0,0 +1,26 @@
import { Link, Table } from '@radix-ui/themes';
import MarkdownToJSX from 'markdown-to-jsx';
interface MarkdownProps {
children: string;
}
export function Markdown({ children }: MarkdownProps) {
return (
<MarkdownToJSX
options={{
overrides: {
a: { component: Link },
table: { component: Table.Root },
thead: { component: Table.Header },
tbody: { component: Table.Body },
tr: { component: Table.Row },
th: { component: Table.ColumnHeaderCell },
td: { component: Table.Cell },
},
}}
>
{children}
</MarkdownToJSX>
);
}
@@ -0,0 +1,35 @@
---
import type { GetStaticPaths } from 'astro';
import { readFile } from 'fs/promises';
import { Page } from '.';
import RootLayout from '../../../../layouts/RootLayout.astro';
export const getStaticPaths = (async () => {
const ROOT = '../../../../../../../docs/';
const files = import.meta.glob('../../../../../../../docs/**/*.md', {
eager: true,
});
return await Promise.all(
Object.keys(files).map(async (file) => {
const couple = file.replace(ROOT, '').split('/');
couple[1] = couple[1].replace('.md', '');
const content = await readFile(
`../../docs/${couple[0]}/${couple[1]}.md`,
).then((buffer) => buffer.toString());
return {
params: { directory: couple[0], document: couple[1] },
props: { content },
};
}),
);
}) satisfies GetStaticPaths;
const { content } = Astro.props;
---
<!-- <title>{title}</title> -->
<RootLayout>
<Page content={content} />
</RootLayout>
@@ -0,0 +1,14 @@
import { Markdown } from '../../../../components/Markdown';
import { PageWrapper } from '../../../../components/PageWrapper';
interface PageProps {
content: string;
}
export function Page({ content }: PageProps) {
return (
<PageWrapper>
<Markdown>{content}</Markdown>
</PageWrapper>
);
}
@@ -0,0 +1,48 @@
---
import { MagicWandIcon, StarFilledIcon } from '@radix-ui/react-icons';
import { Flex, Heading, Link } from '@radix-ui/themes';
import { compareVersions } from 'compare-versions';
import { PageWrapper } from '../../../components/PageWrapper';
import RootLayout from '../../../layouts/RootLayout.astro';
// this can't be used in template literal :(
const ROOT = '../../../../../../docs/changelogs/';
const versions = Object.keys(
import.meta.glob(`../../../../../../docs/changelogs/*.md`, {
eager: true,
}),
)
.map((file) => file.replace(ROOT, '').replace('.md', ''))
.sort(compareVersions)
.reverse();
---
<RootLayout>
<PageWrapper align="center">
<Heading mt="6" mb="4">BlitzKit patches</Heading>
<Flex direction="column" gap="2" align="center">
{
versions.map((version) => {
const split = version.split('.').map(Number);
const isMajor = split[2] === 0;
return (
<Link
size="5"
href={`/docs/changelogs/${version}`}
mb={isMajor ? '6' : '0'}
>
<Flex align="center" gap="2">
{!isMajor && <MagicWandIcon />}
{isMajor && <StarFilledIcon />}
{version}
</Flex>
</Link>
);
})
}
</Flex>
</PageWrapper>
</RootLayout>