Skip to content

Commit 7fdd550

Browse files
committed
chore: preview
1 parent f9541bf commit 7fdd550

33 files changed

+2046
-1043
lines changed

.helix/languages.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ languages = { typescriptreact = [
1111
{ formatCommand = "pnpm biome check --write -unsafe --stdin-file-path=${INPUT}", formatStdin = true },
1212
], typescript = [
1313
{ formatCommand = "pnpm biome check --write -unsafe --stdin-file-path=${INPUT}", formatStdin = true },
14+
], javascript = [
15+
{ formatCommand = "pnpm biome check --write -unsafe --stdin-file-path=${INPUT}", formatStdin = true },
1416
] }
1517

1618
[[language]]
@@ -87,4 +89,4 @@ language-servers = [
8789
] },
8890
"emmet-ls",
8991
]
90-
auto-format = true
92+
auto-format = true

biome.json

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@
1212
"recommended": true,
1313
"style": {
1414
"noNonNullAssertion": "warn"
15+
},
16+
"suspicious": {
17+
"noExplicitAny": "warn"
1518
}
16-
}
17-
},
18-
"files": {
19-
"ignore": [
20-
"*.js",
21-
"*.cjs"
22-
]
19+
},
20+
"ignore": ["*.js"]
2321
}
24-
}
22+
}

docs/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,5 @@ gitignore
2727
# System Files
2828
.DS_Store
2929
Thumbs.db
30+
31+
.content

docs/app.config.ts

Lines changed: 124 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,134 @@
1-
import { dirname, resolve } from "node:path";
1+
import { existsSync, mkdirSync, readdirSync, writeFileSync } from "node:fs";
2+
import { dirname, join, relative, resolve } from "node:path";
23
import { fileURLToPath } from "node:url";
4+
import { mdx } from "@cyco130/vite-plugin-mdx";
35
import { defineConfig } from "@solidjs/start/config";
6+
import rehypeSlug from "rehype-slug";
7+
import remarkFrontmatter from "remark-frontmatter";
8+
import remarkGfm from "remark-gfm";
9+
import { readSync } from "to-vfile";
10+
import { matter } from "vfile-matter";
411

512
const __filename = fileURLToPath(import.meta.url);
613
const __dirname = dirname(__filename);
714

815
export default defineConfig({
9-
vite: {
10-
resolve: {
11-
alias: {
12-
"@": resolve(__dirname, "./src"),
16+
extensions: ["mdx"],
17+
vite: () => {
18+
// https://andi.dev/blog/how-solid-start-blog
19+
const processFiles = () => {
20+
const docs: {
21+
headings?: { depth: number; slug: string; text: string }[];
22+
frontmatter?: {
23+
title: string;
24+
description: string;
25+
component: boolean;
26+
link: {
27+
doc: string;
28+
api: string;
29+
};
30+
toc: boolean;
31+
};
32+
slug?: string;
33+
}[] = [];
34+
35+
const outputFile = resolve(".content/index.js");
36+
const docsDir = resolve("src/routes/docs");
37+
38+
if (!existsSync(".content")) {
39+
mkdirSync(".content", { recursive: true });
40+
}
41+
42+
(function processDirectory(currentDir: string) {
43+
const items = readdirSync(currentDir, { withFileTypes: true });
44+
45+
for (const item of items) {
46+
const fullPath = join(currentDir, item.name);
47+
48+
if (item.isDirectory()) {
49+
processDirectory(fullPath);
50+
} else if (item.isFile() && item.name.endsWith(".mdx")) {
51+
const fileContent = readSync(fullPath, "utf-8");
52+
matter(fileContent);
53+
54+
const relativePath = relative(docsDir, fullPath);
55+
const slug = `/docs/${relativePath.replace(/\.mdx$/, "").replace(/\\/g, "/")}`;
56+
57+
const headings: { depth: number; slug: string; text: string }[] =
58+
[];
59+
const regex = /^(#{1,6})\s+(.+)$/gm;
60+
let match: RegExpExecArray | null;
61+
62+
// biome-ignore lint/suspicious/noAssignInExpressions:
63+
while ((match = regex.exec(String(fileContent))) !== null) {
64+
const depth = match[1].length;
65+
const text = match[2].trim();
66+
67+
headings.push({
68+
depth,
69+
text,
70+
slug: text
71+
.toLowerCase()
72+
.replace(/[^a-z0-9]+/g, "-")
73+
.replace(/(^-|-$)/g, ""),
74+
});
75+
}
76+
77+
docs.push({
78+
frontmatter: fileContent.data
79+
.matter as (typeof docs)[0]["frontmatter"],
80+
headings,
81+
slug,
82+
});
83+
}
84+
}
85+
})(docsDir);
86+
87+
writeFileSync(
88+
outputFile,
89+
`export const allDocs = ${JSON.stringify(docs, null, 2)}`,
90+
"utf-8",
91+
);
92+
};
93+
94+
return {
95+
plugins: [
96+
{
97+
name: "posts-gen",
98+
buildStart() {
99+
processFiles();
100+
},
101+
configureServer(server) {
102+
server.watcher.on("change", (filePath) => {
103+
if (filePath.includes("/src/routes/docs")) {
104+
processFiles();
105+
}
106+
});
107+
},
108+
},
109+
mdx({
110+
jsx: true,
111+
jsxImportSource: "solid-js",
112+
providerImportSource: "@/components/mdx",
113+
remarkPlugins: [remarkGfm, remarkFrontmatter],
114+
rehypePlugins: [rehypeSlug],
115+
}),
116+
],
117+
resolve: {
118+
alias: {
119+
"@": resolve(__dirname, "./src"),
120+
"#content": resolve(__dirname, "./.content"),
121+
},
122+
},
123+
};
124+
},
125+
server: {
126+
prerender: {
127+
crawlLinks: true,
128+
},
129+
esbuild: {
130+
options: {
131+
target: "esnext",
13132
},
14133
},
15134
},

docs/eslint.config.js

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,41 @@
11
import js from "@eslint/js";
2-
import solid from "eslint-plugin-solid/configs/typescript";
32
import * as tsParser from "@typescript-eslint/parser";
4-
import tseslint from 'typescript-eslint';
53
import biome from "eslint-config-biome";
4+
import solid from "eslint-plugin-solid/configs/typescript";
5+
import tseslint from "typescript-eslint";
66

77
export default tseslint.config(
8-
js.configs.recommended,
9-
tseslint.configs.strictTypeChecked,
10-
tseslint.configs.stylisticTypeChecked,
11-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
12-
biome,
13-
{
14-
languageOptions: {
15-
parserOptions: {
16-
projectService: true,
17-
tsconfigRootDir: import.meta.dirname,
18-
},
19-
},
20-
},
21-
{
22-
files: ["**/*.{ts,tsx}"],
23-
...solid,
24-
languageOptions: {
25-
parser: tsParser,
26-
parserOptions: {
27-
project: "tsconfig.json",
28-
},
29-
},
30-
},
31-
)
8+
js.configs.recommended,
9+
tseslint.configs.strictTypeChecked,
10+
tseslint.configs.stylisticTypeChecked,
11+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
12+
biome,
13+
{
14+
languageOptions: {
15+
parserOptions: {
16+
projectService: true,
17+
tsconfigRootDir: import.meta.dirname,
18+
},
19+
},
20+
},
21+
{
22+
files: ["**/*.{ts,tsx}"],
23+
...solid,
24+
languageOptions: {
25+
parser: tsParser,
26+
parserOptions: {
27+
project: "tsconfig.json",
28+
},
29+
},
30+
},
31+
{
32+
rules: {
33+
"@typescript-eslint/no-unsafe-assignment": "off",
34+
"@typescript-eslint/no-unsafe-call": "off",
35+
"@typescript-eslint/no-unsafe-member-access": "off",
36+
"@typescript-eslint/consistent-type-definitions": ["error", "type"],
37+
"@typescript-eslint/no-confusing-void-expression": "off",
38+
"@typescript-eslint/ban-ts-comment": "off",
39+
},
40+
},
41+
);

docs/package.json

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,45 @@
88
"version": "vinxi version"
99
},
1010
"dependencies": {
11+
"@kobalte/core": "^0.13.7",
12+
"@solid-primitives/intersection-observer": "^2.1.6",
1113
"@solidjs/meta": "^0.29.4",
1214
"@solidjs/router": "^0.15.0",
1315
"@solidjs/start": "^1.0.10",
16+
"clsx": "^2.1.1",
1417
"solid-js": "^1.9.2",
18+
"solid-wrap-balancer": "^0.0.5",
19+
"tailwind-merge": "^2.5.4",
1520
"vinxi": "^0.4.3"
1621
},
1722
"engines": {
1823
"node": ">=18"
1924
},
2025
"devDependencies": {
26+
"@cyco130/vite-plugin-mdx": "^2.1.6",
2127
"@eslint/js": "^9.15.0",
28+
"@repo/tailwindcss": "workspace:*",
2229
"@typescript-eslint/parser": "^8.15.0",
2330
"autoprefixer": "^10.4.20",
2431
"eslint": "^9.15.0",
2532
"eslint-config-biome": "^1.9.3",
2633
"eslint-plugin-solid": "^0.14.4",
34+
"mdast-util-from-markdown": "^2.0.2",
35+
"mdast-util-frontmatter": "^2.0.1",
36+
"micromark-extension-frontmatter": "^2.0.0",
2737
"postcss": "^8.4.49",
38+
"rehype-autolink-headings": "^7.1.0",
39+
"rehype-slug": "^6.0.0",
40+
"remark-frontmatter": "^5.0.0",
41+
"remark-gfm": "^4.0.0",
42+
"remark-rehype": "^11.1.1",
2843
"tailwindcss": "^3.4.15",
29-
"typescript-eslint": "^8.15.0"
44+
"to-vfile": "^8.0.0",
45+
"typescript-eslint": "^8.15.0",
46+
"unist-util-visit": "^5.0.0",
47+
"vfile": "^6.0.3",
48+
"vfile-matter": "^5.0.0",
49+
"vite-plugin-virtual": "^0.3.0",
50+
"yaml": "^2.6.1"
3051
}
3152
}

docs/src/app.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
--radius: 0.5rem;
2727
}
2828

29-
.dark {
29+
[data-kb-theme="dark"] {
3030
--background: 240 10% 3.9%;
3131
--foreground: 0 0% 98%;
3232
--card: 240 10% 3.9%;

docs/src/app.tsx

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,43 @@
1+
import { Footer } from "@/components/footer";
2+
import { Header } from "@/components/header";
13
import { Metadata } from "@/components/metadata";
4+
import { ColorModeProvider, ColorModeScript } from "@kobalte/core";
5+
import { ToastList, ToastRegion } from "@repo/tailwindcss/ui/toast";
26
import { MetaProvider } from "@solidjs/meta";
37
import { Router } from "@solidjs/router";
8+
import { clientOnly } from "@solidjs/start";
49
import { FileRoutes } from "@solidjs/start/router";
510
import { Suspense } from "solid-js";
11+
612
import "./app.css";
13+
import "./mdx.css";
14+
15+
const Toaster = clientOnly(
16+
async () => (await import("@repo/tailwindcss/ui/sonner")).Toaster,
17+
);
718

819
export default function App() {
920
return (
1021
<Router
1122
root={(props) => (
1223
<MetaProvider>
1324
<Metadata />
14-
<Suspense>{props.children}</Suspense>
25+
<ColorModeScript />
26+
<ColorModeProvider>
27+
<Suspense>
28+
<div class="relative flex min-h-screen flex-col">
29+
<div class="mx-auto w-full border-border/40 dark:border-border min-[1800px]:max-w-[1536px] min-[1800px]:border-x">
30+
<Header />
31+
<div class="flex-1">{props.children}</div>
32+
<Footer />
33+
<ToastRegion>
34+
<ToastList />
35+
</ToastRegion>
36+
<Toaster />
37+
</div>
38+
</div>
39+
</Suspense>
40+
</ColorModeProvider>
1541
</MetaProvider>
1642
)}
1743
>

0 commit comments

Comments
 (0)