Skip to content

Commit 6fdbdb6

Browse files
committed
more live gh tweaks
1 parent d2004b5 commit 6fdbdb6

8 files changed

Lines changed: 108 additions & 10 deletions

File tree

.github/workflows/pages.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ jobs:
7777
cp -r website/out/* _site/
7878
mkdir -p _site/playground
7979
cp -r playground/dist/* _site/playground/
80+
# SPA fallback — serve index.html for all playground routes
81+
cp _site/playground/index.html _site/playground/404.html
8082
8183
- uses: actions/upload-pages-artifact@v3
8284

playground/src/gnata/GnataMode.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ import { useLayoutContext } from '../RootLayout';
1212

1313
const EXAMPLE_KEYS = Object.keys(GNATA_EXAMPLES);
1414

15+
const base = import.meta.env.BASE_URL;
16+
1517
const WASM_OPTIONS = {
16-
evalWasmUrl: '/gnata.wasm',
17-
evalExecUrl: '/wasm_exec.js',
18-
lspWasmUrl: '/gnata-lsp.wasm',
19-
lspExecUrl: '/lsp-wasm_exec.js',
18+
evalWasmUrl: `${base}gnata.wasm`,
19+
evalExecUrl: `${base}wasm_exec.js`,
20+
lspWasmUrl: `${base}gnata-lsp.wasm`,
21+
lspExecUrl: `${base}lsp-wasm_exec.js`,
2022
};
2123

2224
const DEFAULT_EXPR = '$sum(Account.Order.Product.(Price * Quantity))';

playground/src/router.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ const gnataRoute = createRoute({
3838

3939
const routeTree = rootRoute.addChildren([indexRoute, sqliteRoute, gnataRoute]);
4040

41-
export const router = createRouter({ routeTree });
41+
const basepath = import.meta.env.BASE_URL.replace(/\/$/, '') || '/';
42+
43+
export const router = createRouter({ routeTree, basepath });
4244

4345
declare module '@tanstack/react-router' {
4446
interface Register {

playground/src/sqlite/SqliteMode.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ export function SqliteMode() {
5454
(async () => {
5555
try {
5656
const [wasmExecText, wasmBytes] = await Promise.all([
57-
fetch('/wasm_exec.js').then((r) => r.text()),
57+
fetch(`${import.meta.env.BASE_URL}wasm_exec.js`).then((r) => r.text()),
5858
(async () => {
59-
const resp = await fetch('/gnata.wasm');
59+
const resp = await fetch(`${import.meta.env.BASE_URL}gnata.wasm`);
6060
const total = parseInt(resp.headers.get('content-length') || '0', 10);
6161
let loaded = 0;
6262
const chunks: Uint8Array[] = [];

website/source.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { defineConfig, defineDocs } from 'fumadocs-mdx/config';
22
import { metaSchema, pageSchema } from 'fumadocs-core/source/schema';
33
import { tokyoNightLight } from './src/lib/tokyo-night-light';
4+
import { tokyoNightDark } from './src/lib/tokyo-night-dark';
45

56
// You can customise Zod schemas for frontmatter and `meta.json` here
67
// see https://fumadocs.dev/docs/mdx/collections
@@ -22,7 +23,7 @@ export default defineConfig({
2223
rehypeCodeOptions: {
2324
themes: {
2425
light: tokyoNightLight,
25-
dark: 'tokyo-night',
26+
dark: tokyoNightDark,
2627
},
2728
},
2829
},

website/src/app/(home)/page.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,17 @@ function App() {
8686
}`;
8787

8888
import { tokyoNightLight } from '@/lib/tokyo-night-light';
89+
import { tokyoNightDark } from '@/lib/tokyo-night-dark';
8990

9091
const sqlHtml = await codeToHtml(sqlCode, {
9192
lang: 'sql',
92-
themes: { dark: 'tokyo-night', light: tokyoNightLight },
93+
themes: { dark: tokyoNightDark, light: tokyoNightLight },
9394
defaultColor: false,
9495
});
9596

9697
const reactHtml = await codeToHtml(reactCode, {
9798
lang: 'tsx',
98-
themes: { dark: 'tokyo-night', light: tokyoNightLight },
99+
themes: { dark: tokyoNightDark, light: tokyoNightLight },
99100
defaultColor: false,
100101
});
101102

website/src/lib/layout.shared.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,12 @@ export function baseOptions(): BaseLayoutProps {
1111
),
1212
},
1313
githubUrl: `https://github.com/${gitConfig.user}/${gitConfig.repo}`,
14+
links: [
15+
{
16+
text: 'Playground',
17+
url: 'https://rbby.dev/gnata-sqlite/playground',
18+
external: true,
19+
},
20+
],
1421
};
1522
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import type { ThemeRegistrationRaw } from 'shiki';
2+
3+
/**
4+
* Custom Tokyo Night dark theme for Shiki — matches the playground's CodeMirror colors.
5+
* The built-in shiki tokyo-night uses slightly different colors for some tokens.
6+
*/
7+
export const tokyoNightDark: ThemeRegistrationRaw = {
8+
name: 'tokyo-night-custom',
9+
type: 'dark',
10+
settings: [
11+
// Global defaults
12+
{ settings: { foreground: '#c0caf5', background: '#1a1b26' } },
13+
14+
// Comments
15+
{ scope: ['comment', 'punctuation.definition.comment'], settings: { foreground: '#565f89' } },
16+
17+
// Strings
18+
{ scope: ['string', 'string.quoted', 'string.template'], settings: { foreground: '#9ece6a' } },
19+
20+
// Numbers
21+
{ scope: ['constant.numeric', 'constant.numeric.decimal', 'constant.numeric.integer', 'constant.numeric.float', 'constant.numeric.hex'], settings: { foreground: '#ff9e64' } },
22+
23+
// Booleans
24+
{ scope: ['constant.language.boolean', 'constant.language'], settings: { foreground: '#ff9e64' } },
25+
{ scope: ['constant.language.null', 'constant.language.undefined'], settings: { foreground: '#565f89' } },
26+
27+
// Keywords
28+
{ scope: ['keyword', 'storage.type', 'storage.modifier', 'keyword.control', 'keyword.control.import', 'keyword.control.from', 'keyword.control.export', 'keyword.control.default', 'keyword.control.return', 'keyword.control.conditional', 'keyword.control.loop'], settings: { foreground: '#bb9af7', fontStyle: 'bold' } },
29+
30+
// Operators
31+
{ scope: ['keyword.operator', 'keyword.operator.assignment', 'keyword.operator.comparison', 'keyword.operator.arithmetic', 'keyword.operator.logical', 'keyword.operator.ternary', 'keyword.operator.spread', 'keyword.operator.type.annotation'], settings: { foreground: '#89ddff' } },
32+
33+
// Functions
34+
{ scope: ['entity.name.function', 'support.function', 'meta.function-call entity.name.function', 'variable.function'], settings: { foreground: '#7aa2f7' } },
35+
36+
// Types / classes
37+
{ scope: ['entity.name.type', 'support.type', 'support.class', 'entity.name.class', 'support.type.builtin', 'keyword.type'], settings: { foreground: '#7aa2f7' } },
38+
39+
// Variables — bright green like the playground
40+
{ scope: ['variable', 'variable.other.readwrite', 'entity.name.variable', 'variable.parameter'], settings: { foreground: '#c0caf5' } },
41+
42+
// Properties — teal
43+
{ scope: ['variable.other.property', 'support.variable.property', 'meta.object-literal.key', 'variable.other.object.property', 'entity.name.tag.yaml'], settings: { foreground: '#73daca' } },
44+
45+
// Punctuation — brackets, braces, parens
46+
{ scope: ['punctuation.definition.block', 'punctuation.definition.parameters', 'punctuation.section', 'meta.brace.round', 'meta.brace.curly', 'meta.brace.square', 'punctuation.definition.binding-pattern'], settings: { foreground: '#698098' } },
47+
48+
// Punctuation — separators, commas, semicolons, dots
49+
{ scope: ['punctuation.separator', 'punctuation.terminator', 'punctuation.accessor', 'punctuation.separator.comma', 'punctuation.definition.string'], settings: { foreground: '#89ddff' } },
50+
51+
// JSX/HTML tags — red/coral
52+
{ scope: ['entity.name.tag', 'support.class.component'], settings: { foreground: '#f7768e' } },
53+
54+
// JSX/HTML attributes — orange
55+
{ scope: ['entity.other.attribute-name'], settings: { foreground: '#ff9e64' } },
56+
57+
// Regex
58+
{ scope: ['string.regexp'], settings: { foreground: '#b4f9f8' } },
59+
60+
// Special — decorators
61+
{ scope: ['meta.decorator', 'punctuation.decorator'], settings: { foreground: '#ff9e64' } },
62+
63+
// SQL keywords — cyan blue like the playground
64+
{ scope: ['keyword.other.DML', 'keyword.other.DDL', 'keyword.other.sql', 'keyword.other.create', 'keyword.other.data-integrity'], settings: { foreground: '#bb9af7', fontStyle: 'bold' } },
65+
66+
// SQL functions
67+
{ scope: ['support.function.aggregate', 'support.function.scalar', 'support.function.string'], settings: { foreground: '#7aa2f7' } },
68+
69+
// Bash/shell
70+
{ scope: ['keyword.control.shell', 'support.function.builtin.shell', 'entity.name.command.shell'], settings: { foreground: '#7aa2f7' } },
71+
{ scope: ['string.unquoted.argument.shell', 'variable.other.normal.shell'], settings: { foreground: '#c0caf5' } },
72+
73+
// Go
74+
{ scope: ['entity.name.package.go', 'entity.name.import.go'], settings: { foreground: '#c0caf5' } },
75+
{ scope: ['keyword.function.go', 'keyword.var.go', 'keyword.const.go', 'keyword.type.go', 'keyword.import.go', 'keyword.package.go'], settings: { foreground: '#bb9af7', fontStyle: 'bold' } },
76+
77+
// Markdown
78+
{ scope: ['markup.heading'], settings: { foreground: '#7aa2f7', fontStyle: 'bold' } },
79+
{ scope: ['markup.bold'], settings: { fontStyle: 'bold' } },
80+
{ scope: ['markup.italic'], settings: { fontStyle: 'italic' } },
81+
{ scope: ['markup.inline.raw'], settings: { foreground: '#73daca' } },
82+
],
83+
};

0 commit comments

Comments
 (0)