Skip to content

Commit cc9280f

Browse files
committed
chore(docs): migrate to astro-pigment, drop custom site infrastructure
Replaces the hand-rolled Astro docs site (layouts, components, stores, attachments, custom CSS pipeline) with astro-pigment documentation theme. Removes ~4000 lines of custom code and unused dependencies (CodeMirror, MDX, sitemap, postcss-preset-env, etc.).
1 parent 9e76aa0 commit cc9280f

112 files changed

Lines changed: 479 additions & 4119 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/docs/astro.config.mjs

Lines changed: 25 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,115 +1,43 @@
11
// @ts-check
2-
import { defineConfig, fontProviders } from "astro/config";
3-
import { createHash } from "node:crypto";
4-
import path from "node:path";
5-
import mdx from "@astrojs/mdx";
6-
import sitemap from "@astrojs/sitemap";
7-
import postcssPresetEnv from "postcss-preset-env";
8-
import rehypeAutolinkHeadings from "rehype-autolink-headings";
9-
import rehypeSlug from "rehype-slug";
10-
import { shikiThemes } from "./src/config.ts";
11-
12-
/** Fixes heading anchor links broken by <base href="/">: rewrites #fragment → slug#fragment */
13-
function rehypeFixBaseAnchors() {
14-
return (tree, file) => {
15-
const match = file.history[0]?.match(/\/content\/docs\/(.+)\.mdx?$/);
16-
if (!match || match[1] === "index") return;
17-
18-
const slug = match[1];
19-
(function walk(node) {
20-
if (
21-
node.tagName === "a" &&
22-
node.properties?.className?.includes("anchor") &&
23-
typeof node.properties.href === "string" &&
24-
node.properties.href.startsWith("#")
25-
) {
26-
node.properties.href = `${slug}${node.properties.href}`;
27-
}
28-
if (node.children) node.children.forEach(walk);
29-
})(tree);
30-
};
31-
}
2+
import { defineConfig } from "astro/config";
3+
import docsTheme from "astro-pigment";
324

335
const nanoTagsRoot = new URL("../../packages/nanotags", import.meta.url).pathname;
346

357
// https://astro.build/config
368
export default defineConfig({
37-
site: "https://psd-coder.github.io",
38-
base: process.env.CI ? "/nanotags/" : "/",
39-
integrations: [mdx(), sitemap()],
40-
markdown: {
41-
shikiConfig: {
42-
themes: shikiThemes,
43-
},
44-
rehypePlugins: [
45-
rehypeSlug,
46-
[
47-
rehypeAutolinkHeadings,
48-
{
49-
behavior: "prepend",
50-
properties: { className: ["anchor"], ariaHidden: true, tabIndex: -1 },
51-
content: [],
9+
integrations: [
10+
docsTheme({
11+
project: {
12+
name: "nanotags",
13+
description:
14+
"Tiny Web Components wrapper powered by Nano Stores reactivity. No Shadow DOM, typed builder API, reactive props and refs via nanostores, automatic cleanup on disconnect.",
15+
license: {
16+
name: "MIT",
17+
url: "https://github.com/psd-coder/nanotags/blob/main/LICENSE",
5218
},
53-
],
54-
rehypeFixBaseAnchors,
55-
],
56-
},
57-
fonts: [
58-
{
59-
provider: fontProviders.local(),
60-
name: "Martian Grotesk",
61-
cssVariable: "--font-sans",
62-
options: {
63-
variants: [
64-
{
65-
weight: "100 900",
66-
style: "normal",
67-
src: ["./src/assets/fonts/MartianGrotesk-VF.woff2"],
68-
},
69-
],
19+
github: { user: "psd-coder", repository: "nanotags" },
7020
},
71-
},
72-
{
73-
provider: fontProviders.local(),
74-
name: "Martian Mono",
75-
cssVariable: "--font-mono",
76-
options: {
77-
variants: [
78-
{
79-
weight: 400,
80-
style: "normal",
81-
src: ["./src/assets/fonts/MartianMono-Regular.woff2"],
82-
},
21+
author: { name: "Pavel Grinchenko", url: "https://x.com/psd_coder" },
22+
credits: [{ name: "Evil Martians", url: "https://evilmartians.com/" }],
23+
customCss: ["./src/assets/custom.css"],
24+
logo: "./src/assets/logo.svg",
25+
icon: "./src/assets/favicon.svg",
26+
docs: {
27+
navLinks: [
28+
{ href: "/", label: "Getting Started" },
29+
{ href: "/api", label: "API" },
30+
{ href: "/cookbook", label: "Cookbook" },
31+
{ href: "/examples", label: "Examples" },
8332
],
8433
},
85-
},
34+
extraEntries: "./src/extra-entries.ts",
35+
}),
8636
],
8737
vite: {
8838
optimizeDeps: {
8939
entries: ["!src/content/examples/**"],
9040
},
91-
css: {
92-
modules: {
93-
generateScopedName(name, filename) {
94-
const dir = path.basename(path.dirname(filename));
95-
const hash = createHash("sha256").update(`${filename}:${name}`).digest("hex").slice(0, 5);
96-
97-
return `${dir}__${name}_${hash}`;
98-
},
99-
},
100-
postcss: {
101-
plugins: [
102-
postcssPresetEnv({
103-
stage: 3,
104-
features: {
105-
"nesting-rules": true,
106-
"custom-media-queries": true,
107-
"media-query-ranges": true,
108-
},
109-
}),
110-
],
111-
},
112-
},
11341
plugins: [
11442
{
11543
name: "nanotags-source",

apps/docs/package.json

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,15 @@
1313
"format:styles": "stylelint \"src/**/*.css\" --fix"
1414
},
1515
"dependencies": {
16-
"@astrojs/mdx": "^5.0.2",
17-
"@astrojs/sitemap": "^3.7.1",
18-
"@catppuccin/codemirror": "^1.0.3",
19-
"@codemirror/lang-css": "^6.3.1",
20-
"@codemirror/lang-html": "^6.4.9",
21-
"@codemirror/lang-javascript": "^6.2.2",
22-
"@codemirror/lang-json": "^6.0.1",
23-
"@codemirror/language": "^6.12.2",
24-
"@codemirror/state": "^6.6.0",
2516
"@nanostores/persistent": "^1.3.3",
2617
"astro": "^6.0.8",
27-
"codemirror": "^6.0.1",
18+
"astro-pigment": "^0.11.1",
2819
"es-toolkit": "^1.45.1",
2920
"linkedom": "^0.18.12",
30-
"nanotags": "workspace:*",
3121
"nanoid": "^5.1.7",
3222
"nanostores": "^1.2.0",
33-
"rehype-autolink-headings": "^7.1.0",
34-
"rehype-slug": "^6.0.0",
23+
"nanotags": "workspace:*",
24+
"sharp": "^0.34.0",
3525
"valibot": "^1.3.1"
3626
},
3727
"devDependencies": {
@@ -40,7 +30,6 @@
4030
"@css-modules-kit/codegen": "^0.10.0",
4131
"@css-modules-kit/ts-plugin": "^0.10.0",
4232
"@types/node": "^24.12.0",
43-
"postcss-preset-env": "^11.2.0",
4433
"stylelint": "^17.5.0",
4534
"stylelint-config-clean-order": "^8.0.1",
4635
"stylelint-config-standard": "^40.0.0",
-4.29 KB
Binary file not shown.

apps/docs/public/favicon-96x96.png

-2.12 KB
Binary file not shown.

apps/docs/public/favicon.ico

-14.7 KB
Binary file not shown.

apps/docs/public/site.webmanifest

Lines changed: 0 additions & 21 deletions
This file was deleted.
-4.77 KB
Binary file not shown.
-18.6 KB
Binary file not shown.

apps/docs/src/assets/custom.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
:root {
2+
--theme-hue-override: 135;
3+
--layout-width: 1280px;
4+
}

0 commit comments

Comments
 (0)