-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
60dbacd
commit 2abcee4
Showing
83 changed files
with
760 additions
and
576 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,105 +1,110 @@ | ||
@import "@fontsource/fira-mono"; | ||
@import '@fontsource/fira-mono'; | ||
|
||
:root { | ||
font-family: Arial, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, | ||
Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; | ||
--font-mono: "Fira Mono", monospace; | ||
--pure-white: #ffffff; | ||
--primary-color: #b9c6d2; | ||
--secondary-color: #676778; | ||
--tertiary-color: #edf0f8; | ||
--accent-color: #ff3e00; | ||
--heading-color: rgba(0, 0, 0, 0.7); | ||
--text-color: #444444; | ||
--background-without-opacity: rgba(255, 255, 255, 0.7); | ||
--column-width: 42rem; | ||
--column-margin-top: 4rem; | ||
font-family: 'Inter', ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', | ||
'Segoe UI Symbol', 'Noto Color Emoji'; | ||
--font-mono: 'Fira Mono', monospace; | ||
--pure-white: #ffffff; | ||
--primary-color: #b9c6d2; | ||
--secondary-color: #676778; | ||
--tertiary-color: #edf0f8; | ||
--accent-color: #ff3e00; | ||
--heading-color: rgba(0, 0, 0, 0.7); | ||
--text-color: #444444; | ||
--background-without-opacity: rgba(255, 255, 255, 0.7); | ||
--column-width: 42rem; | ||
--column-margin-top: 4rem; | ||
} | ||
|
||
body { | ||
min-height: 100vh; | ||
margin: 0; | ||
background-color: var(--primary-color); | ||
min-height: 100vh; | ||
margin: 0; | ||
background-color: var(--primary-color); | ||
line-height: 1.5; | ||
} | ||
|
||
body::before { | ||
content: ""; | ||
width: 80vw; | ||
height: 100vh; | ||
position: absolute; | ||
top: 0; | ||
left: 10vw; | ||
z-index: -1; | ||
background: radial-gradient( | ||
50% 50% at 50% 50%, | ||
var(--pure-white) 0%, | ||
rgba(255, 255, 255, 0) 100% | ||
); | ||
opacity: 0.05; | ||
content: ''; | ||
width: 80vw; | ||
height: 100vh; | ||
position: absolute; | ||
top: 0; | ||
left: 10vw; | ||
z-index: -1; | ||
background: radial-gradient( | ||
50% 50% at 50% 50%, | ||
var(--pure-white) 0%, | ||
rgba(255, 255, 255, 0) 100% | ||
); | ||
opacity: 0.05; | ||
} | ||
|
||
#svelte { | ||
min-height: 100vh; | ||
display: flex; | ||
flex-direction: column; | ||
min-height: 100vh; | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
h1, | ||
h2, | ||
p { | ||
font-weight: 400; | ||
color: var(--heading-color); | ||
font-weight: 400; | ||
color: var(--heading-color); | ||
} | ||
|
||
p { | ||
line-height: 1.5; | ||
line-height: 1.5; | ||
} | ||
|
||
a { | ||
color: var(--accent-color); | ||
text-decoration: none; | ||
color: var(--accent-color); | ||
text-decoration: none; | ||
} | ||
|
||
a:hover { | ||
text-decoration: underline; | ||
text-decoration: underline; | ||
} | ||
|
||
h1 { | ||
font-size: 2rem; | ||
text-align: center; | ||
font-size: 2rem; | ||
text-align: center; | ||
} | ||
|
||
h2 { | ||
font-size: 1rem; | ||
font-size: 1rem; | ||
} | ||
|
||
pre { | ||
font-size: 16px; | ||
font-family: var(--font-mono); | ||
background-color: rgba(255, 255, 255, 0.45); | ||
border-radius: 3px; | ||
box-shadow: 2px 2px 6px rgb(255 255 255 / 25%); | ||
padding: 0.5em; | ||
overflow-x: auto; | ||
color: var(--text-color); | ||
font-size: 16px; | ||
background-color: rgba(255, 255, 255, 0.45); | ||
border-radius: 3px; | ||
box-shadow: 2px 2px 6px rgb(255 255 255 / 25%); | ||
padding: 0.5em; | ||
overflow-x: auto; | ||
color: var(--text-color); | ||
} | ||
|
||
code { | ||
font-family: 'Inter', ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', | ||
'Segoe UI Symbol', 'Noto Color Emoji' !important; | ||
} | ||
|
||
input, | ||
button { | ||
font-size: inherit; | ||
font-family: inherit; | ||
font-size: inherit; | ||
font-family: inherit; | ||
} | ||
|
||
button:focus:not(:focus-visible) { | ||
outline: none; | ||
outline: none; | ||
} | ||
|
||
@media (min-width: 720px) { | ||
h1 { | ||
font-size: 2.4rem; | ||
} | ||
h1 { | ||
font-size: 2.4rem; | ||
} | ||
} | ||
|
||
:target { | ||
scroll-margin-top: 80px; | ||
scroll-margin-top: 80px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { readFile } from 'node:fs/promises'; | ||
import MarkdownIt from 'markdown-it'; | ||
import Shiki from '@shikijs/markdown-it'; | ||
|
||
function headingRenderer(md: MarkdownIt) { | ||
const buildId = (text: string) => { | ||
return text | ||
.replace(/[^ \-0-9a-z]/gi, '') | ||
.trim() | ||
.replace(/\s+/g, '-') | ||
.toLowerCase(); | ||
}; | ||
|
||
md.renderer.rules.heading_open = function (tokens, idx) { | ||
const tag = tokens[idx].tag; | ||
const text = tokens[idx + 1].content; | ||
const id = buildId(text); | ||
return `<${tag} id=${id} tabindex="-1"><a href="#${id}">#</a>`; | ||
}; | ||
} | ||
|
||
function noteRenderer(md: MarkdownIt) { | ||
md.renderer.rules.text = function (tokens, idx) { | ||
const text = tokens[idx].content; | ||
const match = /^::: (\S+)(\s.*)?$/.exec(text); | ||
if (match) { | ||
const type = match[1]?.trim(); | ||
const title = (match[2] ?? type)?.trim(); | ||
return `<div class="custom-block ${type}"><p class="custom-block-title">${title}</p>`; | ||
} | ||
if (text.startsWith(':::')) { | ||
return '</div>'; | ||
} | ||
return text; | ||
}; | ||
} | ||
|
||
const md = MarkdownIt(); | ||
md.use(headingRenderer); | ||
md.use(noteRenderer); | ||
md.use( | ||
await Shiki({ | ||
themes: { | ||
light: 'vitesse-dark', | ||
dark: 'vitesse-dark' | ||
} | ||
}) | ||
); | ||
|
||
function removeQuotes(str: string) { | ||
return str.replace(/^["']|["']$/g, ''); | ||
} | ||
|
||
function extractFrontmatter(markdown: string) { | ||
const match = /---\r?\n([\s\S]+?)\r?\n---/.exec(markdown); | ||
if (!match) return { metadata: {}, body: markdown }; | ||
|
||
const frontmatter = match[1]; | ||
const body = markdown.slice(match[0].length); | ||
|
||
const metadata: Record<string, string> = {}; | ||
frontmatter.split('\n').forEach((pair) => { | ||
const i = pair.indexOf(':'); | ||
metadata[pair.slice(0, i).trim()] = removeQuotes(pair.slice(i + 1).trim()); | ||
}); | ||
|
||
return { metadata, body }; | ||
} | ||
|
||
function removeComments(markdown: string) { | ||
return markdown.replace(/<!--[\s\S]*?-->/g, ''); | ||
} | ||
|
||
export async function getParsedMarkdown( | ||
path: string | ||
): Promise<{ metadata: Record<string, string | number>; html: string }> { | ||
const markdown = await readFile(path, 'utf-8'); | ||
const { metadata, body } = extractFrontmatter(markdown); | ||
const bodyWithoutComment = removeComments(body); | ||
const html = md.render(bodyWithoutComment); | ||
return { metadata, html }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { getParsedMarkdown } from '$lib/server/markdown.js'; | ||
import { error } from '@sveltejs/kit'; | ||
import type { PageServerLoad } from './$types'; | ||
|
||
export const load: PageServerLoad = async ({ params }) => { | ||
const content = await getParsedMarkdown(`${process.cwd()}/../docs/${params.slug}.md`); | ||
|
||
if (content) { | ||
return { content }; | ||
} | ||
|
||
error(404, 'Not found'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<script lang="ts"> | ||
import type { PageData } from './$types'; | ||
export let data: PageData; | ||
</script> | ||
|
||
<section data-rule-page> | ||
{@html data.content.html} | ||
</section> | ||
|
||
<style global> | ||
section[data-rule-page] > h1 { | ||
display: flex; | ||
justify-content: center; | ||
} | ||
section[data-rule-page] > h1 > a, | ||
h2 > a, | ||
h3 > a, | ||
h4 > a, | ||
h5 > a, | ||
h6 > a { | ||
content: '#'; | ||
color: var(--accent-color); | ||
margin-right: 8px; | ||
} | ||
section[data-rule-page] td:nth-child(3) { | ||
width: 42px; | ||
text-align: right; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { getParsedMarkdown } from '$lib/server/markdown.js'; | ||
import { error } from '@sveltejs/kit'; | ||
import type { PageServerLoad } from './$types'; | ||
|
||
export const load: PageServerLoad = async ({ params }) => { | ||
const content = await getParsedMarkdown(`${process.cwd()}/../docs/rules/${params.slug}.md`); | ||
|
||
if (content) { | ||
return { content }; | ||
} | ||
|
||
error(404, 'Not found'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<script lang="ts"> | ||
import type { PageData } from './$types'; | ||
export let data: PageData; | ||
</script> | ||
|
||
<section data-rule-page> | ||
{@html data.content.html} | ||
</section> | ||
|
||
<style global> | ||
section[data-rule-page] > h1 { | ||
display: flex; | ||
justify-content: center; | ||
} | ||
section[data-rule-page] > h1 > a, | ||
h2 > a, | ||
h3 > a, | ||
h4 > a, | ||
h5 > a, | ||
h6 > a { | ||
content: '#'; | ||
color: var(--accent-color); | ||
margin-right: 8px; | ||
} | ||
</style> |
Oops, something went wrong.