@vercel/geistdocs 2.15.2 → 2.15.3-canary.7d55dcf

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/cli/index.js +1 -1
  2. package/dist/internal/mdx-to-markdown.d.ts.map +1 -1
  3. package/dist/internal/mdx-to-markdown.js +9 -0
  4. package/dist/internal/page-actions.d.ts +4 -4
  5. package/dist/internal/page-actions.d.ts.map +1 -1
  6. package/dist/internal/page-actions.js +6 -1
  7. package/dist/internal/source-loader.d.ts +28 -0
  8. package/dist/internal/source-loader.d.ts.map +1 -0
  9. package/dist/internal/source-loader.js +77 -0
  10. package/dist/mdx-basic.d.ts +27 -0
  11. package/dist/mdx-basic.d.ts.map +1 -0
  12. package/dist/mdx-basic.js +61 -0
  13. package/dist/mdx.d.ts +3 -25
  14. package/dist/mdx.d.ts.map +1 -1
  15. package/dist/mdx.js +8 -61
  16. package/dist/navigation.d.ts +11 -0
  17. package/dist/navigation.d.ts.map +1 -0
  18. package/dist/navigation.js +8 -0
  19. package/dist/next.d.ts +9 -1
  20. package/dist/next.d.ts.map +1 -1
  21. package/dist/next.js +25 -2
  22. package/dist/pages/docs-custom.d.ts +111 -0
  23. package/dist/pages/docs-custom.d.ts.map +1 -0
  24. package/dist/pages/docs-custom.js +250 -0
  25. package/dist/pages/docs.d.ts +5 -98
  26. package/dist/pages/docs.d.ts.map +1 -1
  27. package/dist/pages/docs.js +13 -250
  28. package/dist/source-config.d.ts +10 -1
  29. package/dist/source-config.d.ts.map +1 -1
  30. package/dist/source-config.js +20 -10
  31. package/dist/source.d.ts +6 -17
  32. package/dist/source.d.ts.map +1 -1
  33. package/dist/source.js +2 -75
  34. package/docs/agents.md +1 -1
  35. package/docs/llms.txt +9 -1
  36. package/docs/manifest.json +1 -1
  37. package/docs/pages/configuration.md +8 -0
  38. package/native-mdx/LICENSE-mdxjs-rs +22 -0
  39. package/native-mdx/binaries/darwin-arm64.node +0 -0
  40. package/native-mdx/binaries/linux-x64-gnu.node +0 -0
  41. package/native-mdx/data-entry.d.mts +15 -0
  42. package/native-mdx/data-entry.mjs +97 -0
  43. package/native-mdx/data-projection.mjs +205 -0
  44. package/native-mdx/index-emitter.mjs +34 -0
  45. package/native-mdx/loader-data.cjs +36 -0
  46. package/native-mdx/loader-mdx.cjs +9 -0
  47. package/native-mdx/loader-mdx.mjs +262 -0
  48. package/native-mdx/native-binding.cjs +25 -0
  49. package/native-mdx/navigation-entry.d.mts +11 -0
  50. package/native-mdx/navigation-entry.mjs +136 -0
  51. package/native-mdx/navigation-title.mjs +53 -0
  52. package/package.json +36 -8
  53. package/rehype-code-highlights.d.ts +13 -0
  54. package/rehype-code-highlights.js +230 -0
  55. package/source-config.js +24 -10
  56. package/template/app/[lang]/(home)/opengraph-image.tsx +4 -28
  57. package/template/app/[lang]/og/[...slug]/route.tsx +5 -68
  58. package/template/content/docs/configuration.mdx +8 -0
  59. package/template/lib/geistdocs/geist-mono-regular.ttf +0 -0
  60. package/template/lib/geistdocs/og.tsx +95 -0
  61. package/template/package.json +1 -1
  62. package/template/app/[lang]/og/[...slug]/background.png +0 -0
  63. package/template/app/[lang]/og/[...slug]/geist-sans-semibold.ttf +0 -0
  64. /package/template/{app/[lang]/og/[...slug] → lib/geistdocs}/geist-sans-regular.ttf +0 -0
@@ -0,0 +1,136 @@
1
+ import { extendIndexEmitter } from "./index-emitter.mjs";
2
+
3
+ const MDX_EXTENSION = /\.mdx?$/;
4
+ const META_EXTENSION = /\.json$/;
5
+
6
+ /** Add navigation.ts to Fumadocs' existing discovery/watch lifecycle. */
7
+ export function navigationEntryPlugin(typeScriptOrLoader) {
8
+ let parserPromise;
9
+ const getParser = () =>
10
+ (parserPromise ??= Promise.resolve()
11
+ .then(() =>
12
+ typeof typeScriptOrLoader === "function"
13
+ ? typeScriptOrLoader()
14
+ : typeScriptOrLoader
15
+ )
16
+ .then((module) => module.default ?? module));
17
+ return {
18
+ name: "geistdocs-navigation-entry",
19
+ config() {
20
+ const collections = this.core.getConfig?.().collectionList ?? [];
21
+ for (const collection of collections) {
22
+ const doc = collection.type === "docs" ? collection.docs : collection;
23
+ if (doc.dynamic || doc.async) {
24
+ throw new Error(
25
+ "Navigation entries require synchronous collections; disable docs.async and docs.dynamic"
26
+ );
27
+ }
28
+ }
29
+ extendIndexEmitter(
30
+ this,
31
+ "geistdocs-navigation-entry",
32
+ async (entries) => {
33
+ const server = entries.find((entry) => entry.path === "server.ts");
34
+ if (
35
+ !server ||
36
+ entries.some((entry) => entry.path === "navigation.ts")
37
+ ) {
38
+ throw new Error(
39
+ "Content entries require server.ts and an unused navigation.ts output"
40
+ );
41
+ }
42
+ return [
43
+ ...entries,
44
+ {
45
+ path: "navigation.ts",
46
+ content: createNavigationEntry(server.content, await getParser())
47
+ .code,
48
+ },
49
+ ];
50
+ }
51
+ );
52
+ },
53
+ };
54
+ }
55
+
56
+ /** Metadata queries only: no renderable MDX imports, including dynamic ones. */
57
+ export function createNavigationEntry(serverCode, ts) {
58
+ const file = ts.createSourceFile(
59
+ "server.ts",
60
+ serverCode,
61
+ ts.ScriptTarget.Latest,
62
+ true,
63
+ ts.ScriptKind.TS
64
+ );
65
+ if (file.parseDiagnostics.length) {
66
+ throw new Error("Cannot parse generated server entry");
67
+ }
68
+ const edits = [];
69
+ function inspect(node) {
70
+ if (
71
+ ts.isMetaProperty(node) &&
72
+ node.keywordToken === ts.SyntaxKind.ImportKeyword
73
+ ) {
74
+ throw new Error("Navigation entries do not support Vite glob entries");
75
+ }
76
+ if (
77
+ ts.isCallExpression(node) &&
78
+ (node.expression.kind === ts.SyntaxKind.ImportKeyword ||
79
+ (ts.isPropertyAccessExpression(node.expression) &&
80
+ ["docsLazy", "docLazy"].includes(node.expression.name.text)))
81
+ ) {
82
+ throw new Error(
83
+ "Navigation entries currently require synchronous Fumadocs collections; leave docs.async disabled"
84
+ );
85
+ }
86
+ ts.forEachChild(node, inspect);
87
+ }
88
+ inspect(file);
89
+ for (const statement of file.statements) {
90
+ if (
91
+ !(
92
+ ts.isImportDeclaration(statement) &&
93
+ ts.isStringLiteral(statement.moduleSpecifier)
94
+ )
95
+ ) {
96
+ continue;
97
+ }
98
+ const specifier = statement.moduleSpecifier;
99
+ const separator = specifier.text.indexOf("?");
100
+ const pathname =
101
+ separator < 0 ? specifier.text : specifier.text.slice(0, separator);
102
+ if (!MDX_EXTENSION.test(pathname)) {
103
+ if (
104
+ !(
105
+ statement.importClause?.isTypeOnly ||
106
+ META_EXTENSION.test(pathname) ||
107
+ pathname === "fumadocs-mdx/runtime/server"
108
+ )
109
+ ) {
110
+ throw new Error(`Unsupported navigation runtime import: ${pathname}`);
111
+ }
112
+ continue;
113
+ }
114
+ const query = new URLSearchParams(
115
+ separator < 0 ? "" : specifier.text.slice(separator + 1)
116
+ );
117
+ if (!query.has("collection")) {
118
+ throw new Error(
119
+ "Navigation MDX imports must identify a Fumadocs collection"
120
+ );
121
+ }
122
+ query.delete("geistdocs-data");
123
+ query.set("only", "frontmatter");
124
+ query.set("geistdocs-navigation", "1");
125
+ edits.push({
126
+ start: specifier.getStart(file),
127
+ end: specifier.end,
128
+ value: JSON.stringify(`${pathname}?${query}`),
129
+ });
130
+ }
131
+ let code = serverCode;
132
+ for (const edit of edits.reverse()) {
133
+ code = code.slice(0, edit.start) + edit.value + code.slice(edit.end);
134
+ }
135
+ return { code, imports: edits.length };
136
+ }
@@ -0,0 +1,53 @@
1
+ let parserPromise;
2
+
3
+ /** Parse only when frontmatter omits a title. Never compile or evaluate MDX. */
4
+ export async function navigationTitle(content, format = "mdx") {
5
+ parserPromise ??= Promise.all([
6
+ import("unified"),
7
+ import("remark-parse"),
8
+ import("remark-mdx"),
9
+ import("remark-gfm"),
10
+ import("fumadocs-core/mdx-plugins/remark-heading"),
11
+ import("fumadocs-core/mdx-plugins/remark-steps"),
12
+ ]);
13
+ const [
14
+ { unified },
15
+ { default: parse },
16
+ { default: mdx },
17
+ { default: gfm },
18
+ { remarkHeading },
19
+ { remarkSteps },
20
+ ] = await parserPromise;
21
+ let parser = unified().use(parse).use(gfm);
22
+ if (format === "mdx") {
23
+ parser = parser.use(mdx);
24
+ }
25
+ parser = parser.use(remarkSteps).use(remarkHeading, { generateToc: false });
26
+ const parsed = parser.parse(content);
27
+ const checkIncludes = (node) => {
28
+ if (node.name === "include") {
29
+ throw new Error(
30
+ "Navigation requires an explicit frontmatter title for pages using include"
31
+ );
32
+ }
33
+ for (const child of node.children ?? []) {
34
+ checkIncludes(child);
35
+ }
36
+ };
37
+ checkIncludes(parsed);
38
+ const tree = await parser.run(parsed);
39
+ const flatten = (node) =>
40
+ node.children ? node.children.map(flatten).join("") : (node.value ?? "");
41
+ const find = (node) => {
42
+ if (node.type === "heading" && node.depth === 1) {
43
+ return flatten(node);
44
+ }
45
+ for (const child of node.children ?? []) {
46
+ const value = find(child);
47
+ if (value !== undefined) {
48
+ return value;
49
+ }
50
+ }
51
+ };
52
+ return find(tree);
53
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vercel/geistdocs",
3
3
  "description": "Runtime and CLI for Geistdocs projects.",
4
- "version": "2.15.2",
4
+ "version": "2.15.3-canary.7d55dcf",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
7
7
  "type": "git",
@@ -27,6 +27,8 @@
27
27
  "cli.js",
28
28
  "dist",
29
29
  "docs",
30
+ "rehype-code-highlights.d.ts",
31
+ "rehype-code-highlights.js",
30
32
  "rehype-task-list-labels.d.ts",
31
33
  "rehype-task-list-labels.js",
32
34
  "remark-details.d.ts",
@@ -37,7 +39,8 @@
37
39
  "shared-theme.css",
38
40
  "styles.css",
39
41
  "theme.css",
40
- "LICENSE"
42
+ "LICENSE",
43
+ "native-mdx"
41
44
  ],
42
45
  "exports": {
43
46
  "./changelog": {
@@ -92,6 +95,10 @@
92
95
  "types": "./dist/source.d.ts",
93
96
  "default": "./dist/source.js"
94
97
  },
98
+ "./navigation": {
99
+ "types": "./dist/navigation.d.ts",
100
+ "default": "./dist/navigation.js"
101
+ },
95
102
  "./sidebar": {
96
103
  "types": "./dist/sidebar.d.ts",
97
104
  "default": "./dist/sidebar.js"
@@ -299,7 +306,29 @@
299
306
  },
300
307
  "./styles.css": "./styles.css",
301
308
  "./theme.css": "./theme.css",
302
- "./package.json": "./package.json"
309
+ "./package.json": "./package.json",
310
+ "./pages/docs/custom": {
311
+ "types": "./dist/pages/docs-custom.d.ts",
312
+ "default": "./dist/pages/docs-custom.js"
313
+ },
314
+ "./mdx/basic": {
315
+ "types": "./dist/mdx-basic.d.ts",
316
+ "default": "./dist/mdx-basic.js"
317
+ },
318
+ "./native-mdx": "./native-mdx/loader-mdx.cjs",
319
+ "./native-mdx/data-loader": "./native-mdx/loader-data.cjs",
320
+ "./native-mdx/data-entry": {
321
+ "types": "./native-mdx/data-entry.d.mts",
322
+ "import": "./native-mdx/data-entry.mjs"
323
+ },
324
+ "./native-mdx/navigation-entry": {
325
+ "types": "./native-mdx/navigation-entry.d.mts",
326
+ "import": "./native-mdx/navigation-entry.mjs"
327
+ }
328
+ },
329
+ "scripts": {
330
+ "build": "rm -rf dist docs template && node ./scripts/bundle-template.mjs && node ./scripts/bundle-docs.mjs && tsc -p tsconfig.runtime.json && tsup --config tsup.config.cli.ts",
331
+ "dev": "tsc -p tsconfig.runtime.json --watch --preserveWatchOutput"
303
332
  },
304
333
  "dependencies": {
305
334
  "@ai-sdk/react": "^3.0.134",
@@ -307,6 +336,8 @@
307
336
  "@modelcontextprotocol/server": "^2.0.0",
308
337
  "@next/env": "16.3.3",
309
338
  "@orama/tokenizers": "^3.1.16",
339
+ "@pierre/highlights": "0.5.1",
340
+ "@shikijs/rehype": "3.19.0",
310
341
  "@streamdown/cjk": "^1.0.1",
311
342
  "@types/mdx": "^2.0.13",
312
343
  "@types/react": "^19.2.7",
@@ -335,6 +366,7 @@
335
366
  "remark-mdx": "^3.1.1",
336
367
  "remark-parse": "^11.0.0",
337
368
  "remark-stringify": "^11.0.0",
369
+ "shiki": "3.19.0",
338
370
  "sonner": "^2.0.8",
339
371
  "streamdown": "^2.1.0",
340
372
  "tailwind-merge": "^3.4.0",
@@ -364,9 +396,5 @@
364
396
  "react-dom": "^19.2.3",
365
397
  "tsup": "^8.5.1",
366
398
  "typescript": "^5.9.3"
367
- },
368
- "scripts": {
369
- "build": "rm -rf dist docs template && node ./scripts/bundle-template.mjs && node ./scripts/bundle-docs.mjs && tsc -p tsconfig.runtime.json && tsup --config tsup.config.cli.ts",
370
- "dev": "tsc -p tsconfig.runtime.json --watch --preserveWatchOutput"
371
399
  }
372
- }
400
+ }
@@ -0,0 +1,13 @@
1
+ import type { RehypeCodeOptions } from "fumadocs-core/mdx-plugins";
2
+ import type { Root } from "hast";
3
+
4
+ /** Zed-format Geist theme for @pierre/highlights, using Geist's Shiki CSS variables. */
5
+ export declare const geistHighlightsTheme: Record<string, unknown>;
6
+
7
+ /**
8
+ * Experimental drop-in for Fumadocs' `rehypeCode` that tokenizes with
9
+ * @pierre/highlights while keeping Shiki's HAST output and transformers.
10
+ */
11
+ export declare const rehypeCodeHighlights: (
12
+ options?: Partial<RehypeCodeOptions>
13
+ ) => (tree: Root, file: unknown) => Promise<void>;
@@ -0,0 +1,230 @@
1
+ import { codeToTokens, isSupportedLanguage } from "@pierre/highlights";
2
+ import rehypeShikiFromHighlighter from "@shikijs/rehype/core";
3
+ import {
4
+ rehypeCodeDefaultOptions,
5
+ transformerIcon,
6
+ transformerTab,
7
+ } from "fumadocs-core/mdx-plugins";
8
+ import { tokensToHast, transformerDecorations } from "shiki/core";
9
+
10
+ // Experimental: highlights code blocks with @pierre/highlights (hand-written
11
+ // Wasm lexers) instead of Shiki's TextMate grammars, while keeping Shiki's
12
+ // HAST output and transformer pipeline so Fumadocs' code block features
13
+ // (titles, icons, tabs, line notation, diffs, focus) keep working.
14
+
15
+ const v = (name) => `token-${name}`;
16
+
17
+ // Maps Highlights' Zed token names onto the same CSS variables the Geist
18
+ // Shiki theme uses (see `geistShikiTheme`), so the existing palette applies.
19
+ // With a `cssVariables` palette, colors are variable suffixes: `token-keyword`
20
+ // renders as `var(--shiki-token-keyword)`.
21
+ export const geistHighlightsTheme = {
22
+ name: "geist",
23
+ appearance: "light",
24
+ cssVariables: {
25
+ prefix: "--shiki-",
26
+ defaults: { "color-text": "inherit", "color-background": "transparent" },
27
+ },
28
+ style: {
29
+ "editor.foreground": "color-text",
30
+ "editor.background": "color-background",
31
+ syntax: {
32
+ comment: v("comment"),
33
+ "comment.doc": v("comment"),
34
+ "keyword.jsdoc": v("comment"),
35
+ "type.jsdoc": v("comment"),
36
+ "variable.jsdoc": v("comment"),
37
+ constant: v("constant"),
38
+ "constant.builtin": v("constant"),
39
+ boolean: v("constant"),
40
+ number: v("constant"),
41
+ enum: v("constant"),
42
+ "variable.special": v("constant"),
43
+ function: v("function"),
44
+ "function.definition": v("function"),
45
+ "function.method": v("function"),
46
+ constructor: v("function"),
47
+ type: v("function"),
48
+ "type.class": v("function"),
49
+ tag: v("function"),
50
+ "tag.jsx": v("function"),
51
+ "tag.component.jsx": v("function"),
52
+ "tag.doctype": v("function"),
53
+ title: v("function"),
54
+ namespace: v("function"),
55
+ selector: v("function"),
56
+ "selector.class": v("function"),
57
+ "selector.id": v("function"),
58
+ "selector.pseudo": v("function"),
59
+ attribute: v("constant"),
60
+ "attribute.jsx": v("constant"),
61
+ "variable.parameter": v("parameter"),
62
+ property: v("parameter"),
63
+ "property.json_key": v("parameter"),
64
+ label: v("parameter"),
65
+ "text.jsx": v("parameter"),
66
+ "punctuation.list_marker": v("parameter"),
67
+ keyword: v("keyword"),
68
+ "keyword.control": v("keyword"),
69
+ "keyword.declaration": v("keyword"),
70
+ "keyword.import": v("keyword"),
71
+ "keyword.operator": v("keyword"),
72
+ operator: v("keyword"),
73
+ preproc: v("keyword"),
74
+ string: v("string"),
75
+ "string.escape": v("string"),
76
+ "string.special": v("string"),
77
+ "string.special.symbol": v("string"),
78
+ "text.literal": v("string"),
79
+ "string.regex": v("string-expression"),
80
+ punctuation: v("punctuation"),
81
+ "punctuation.bracket": v("punctuation"),
82
+ "punctuation.delimiter": v("punctuation"),
83
+ "punctuation.special": v("keyword"),
84
+ "punctuation.markup": v("punctuation"),
85
+ "punctuation.bracket.html": v("parameter"),
86
+ "punctuation.bracket.jsx": v("parameter"),
87
+ "punctuation.delimiter.html": v("parameter"),
88
+ "punctuation.delimiter.jsx": v("parameter"),
89
+ link_uri: v("link"),
90
+ link_text: v("parameter"),
91
+ },
92
+ },
93
+ };
94
+
95
+ // Fenced-code names that Highlights doesn't know but Shiki users write.
96
+ const LANG_ALIASES = {
97
+ plaintext: "plain",
98
+ txt: "plain",
99
+ "": "plain",
100
+ };
101
+
102
+ const resolveLang = (lang) => {
103
+ const name = LANG_ALIASES[lang] ?? lang ?? "plain";
104
+ return isSupportedLanguage(name) ? name : "plain";
105
+ };
106
+
107
+ const TRAILING_NEWLINE = /\n$/;
108
+
109
+ const ENFORCE_ORDER = { pre: 0, undefined: 1, post: 2 };
110
+
111
+ const getTransformers = (options) => [
112
+ ...[...(options.transformers ?? [])].sort(
113
+ (a, b) => ENFORCE_ORDER[a.enforce] - ENFORCE_ORDER[b.enforce]
114
+ ),
115
+ transformerDecorations(),
116
+ ];
117
+
118
+ const UNSTYLED = "var(--shiki-foreground)";
119
+
120
+ const tokenize = (code, options) => {
121
+ const result = codeToTokens(code, {
122
+ lang: resolveLang(options.lang),
123
+ themes: { light: geistHighlightsTheme },
124
+ defaultColor: "light",
125
+ cssVariablePrefix: "--shiki-",
126
+ });
127
+ // Highlights colors unstyled runs with `var(--shiki-foreground)`; Shiki uses
128
+ // the theme foreground, which Geist defines as `--shiki-color-text`.
129
+ for (const line of result.tokens) {
130
+ for (const token of line) {
131
+ if (token.htmlStyle?.color === UNSTYLED) {
132
+ token.htmlStyle = { ...token.htmlStyle, color: result.fg };
133
+ }
134
+ }
135
+ }
136
+ return {
137
+ tokens: result.tokens,
138
+ fg: result.fg,
139
+ bg: result.bg,
140
+ themeName: "shiki-themes geist",
141
+ };
142
+ };
143
+
144
+ /**
145
+ * A minimal Shiki highlighter: enough of the API for `@shikijs/rehype/core`.
146
+ * Mirrors Shiki's `codeToHast` (preprocess → tokens → token transformers →
147
+ * `tokensToHast`), swapping the tokenizer for Highlights.
148
+ */
149
+ export const highlightsShikiAdapter = {
150
+ getLoadedLanguages: () => [],
151
+ loadLanguage: async () => undefined,
152
+ codeToTokens: (code, options) => tokenize(code, options),
153
+ codeToHast(code, options) {
154
+ const transformers = getTransformers(options);
155
+ const context = {
156
+ meta: {},
157
+ options,
158
+ codeToHast: (c, o) => highlightsShikiAdapter.codeToHast(c, o),
159
+ codeToTokens: (c, o) => tokenize(c, o),
160
+ };
161
+
162
+ let input = code;
163
+ for (const transformer of transformers) {
164
+ input = transformer.preprocess?.call(context, input, options) || input;
165
+ }
166
+
167
+ let { tokens, fg, bg, themeName } = tokenize(input, options);
168
+ const contextSource = {
169
+ ...context,
170
+ get source() {
171
+ return input;
172
+ },
173
+ };
174
+ for (const transformer of transformers) {
175
+ tokens = transformer.tokens?.call(contextSource, tokens) || tokens;
176
+ }
177
+
178
+ return tokensToHast(
179
+ tokens,
180
+ {
181
+ ...options,
182
+ fg,
183
+ bg,
184
+ themeName,
185
+ transformers: options.transformers,
186
+ },
187
+ contextSource
188
+ );
189
+ },
190
+ };
191
+
192
+ /** Drop-in for Fumadocs' `rehypeCode`, backed by @pierre/highlights. */
193
+ export const rehypeCodeHighlights = (userOptions = {}) => {
194
+ const options = { ...rehypeCodeDefaultOptions, ...userOptions };
195
+ const transformers = [...(options.transformers ?? [])];
196
+
197
+ // Same preprocessing as Fumadocs' rehypeCode.
198
+ transformers.unshift({
199
+ name: "rehype-code:pre-process",
200
+ preprocess(code, { meta }) {
201
+ if (meta && "__parsed_raw" in meta) {
202
+ meta.__raw = meta.__parsed_raw;
203
+ // biome-ignore lint/performance/noDelete: matches Fumadocs.
204
+ delete meta.__parsed_raw;
205
+ }
206
+ if (meta && options.filterMetaString) {
207
+ meta.__raw = options.filterMetaString(meta.__raw ?? "");
208
+ }
209
+ return code.replace(TRAILING_NEWLINE, "");
210
+ },
211
+ });
212
+ if (options.icon !== false) {
213
+ transformers.push(transformerIcon(options.icon));
214
+ }
215
+ if (options.tab !== false) {
216
+ transformers.push(transformerTab());
217
+ }
218
+
219
+ // `lazy` routes every language through `loadLanguage`, which is a no-op:
220
+ // Highlights bundles its lexers and unknown languages fall back to plain.
221
+ const transformer = rehypeShikiFromHighlighter(highlightsShikiAdapter, {
222
+ ...options,
223
+ lazy: true,
224
+ transformers,
225
+ });
226
+
227
+ return async (tree, file) => {
228
+ await transformer(tree, file, () => undefined);
229
+ };
230
+ };
package/source-config.js CHANGED
@@ -15,6 +15,7 @@ import {
15
15
  } from "fumadocs-mdx/config";
16
16
  import lastModified from "fumadocs-mdx/plugins/last-modified";
17
17
  import { z } from "zod";
18
+ import { rehypeCodeHighlights } from "./rehype-code-highlights.js";
18
19
  import { rehypeTaskListLabels } from "./rehype-task-list-labels.js";
19
20
  import { remarkDetails } from "./remark-details.js";
20
21
 
@@ -276,11 +277,18 @@ export const resolveGeistdocsRemarkPlugins = (
276
277
  // Mirrors src/source-config.ts. Geistdocs rehype plugins run after the
277
278
  // consumer's: an array is handed to Fumadocs, which places it among its
278
279
  // defaults; a function receives those defaults and returns the final list.
279
- export const resolveGeistdocsRehypePlugins = (consumerPlugins) => {
280
+ export const resolveGeistdocsRehypePlugins = (
281
+ consumerPlugins,
282
+ leadingPlugins = []
283
+ ) => {
280
284
  if (typeof consumerPlugins === "function") {
281
- return (defaults) => [...consumerPlugins(defaults), rehypeTaskListLabels];
285
+ return (defaults) => [
286
+ ...leadingPlugins,
287
+ ...consumerPlugins(defaults),
288
+ rehypeTaskListLabels,
289
+ ];
282
290
  }
283
- return [...(consumerPlugins ?? []), rehypeTaskListLabels];
291
+ return [...leadingPlugins, ...(consumerPlugins ?? []), rehypeTaskListLabels];
284
292
  };
285
293
 
286
294
  export const defineGeistdocsSourceConfig = (config = {}) => {
@@ -288,21 +296,27 @@ export const defineGeistdocsSourceConfig = (config = {}) => {
288
296
  ? config.mdxOptions.remarkPlugins
289
297
  : [];
290
298
  const existingPlugins = Array.isArray(config.plugins) ? config.plugins : [];
299
+ const { highlighter = "highlights", ...fumadocsConfig } = config;
300
+ const rehypeCodeOptions = {
301
+ ...config.mdxOptions?.rehypeCodeOptions,
302
+ themes: { light: geistShikiTheme },
303
+ defaultColor: "light",
304
+ };
305
+ // `highlights` swaps Shiki's tokenizer for @pierre/highlights; `shiki`
306
+ // keeps Fumadocs' rehypeCode.
307
+ const useHighlights = highlighter === "highlights";
291
308
 
292
309
  return defineFumadocsConfig({
293
- ...config,
310
+ ...fumadocsConfig,
294
311
  mdxOptions: {
295
312
  ...config.mdxOptions,
296
313
  remarkPlugins: (defaults) =>
297
314
  resolveGeistdocsRemarkPlugins(defaults, existingRemarkPlugins),
298
315
  rehypePlugins: resolveGeistdocsRehypePlugins(
299
- config.mdxOptions?.rehypePlugins
316
+ config.mdxOptions?.rehypePlugins,
317
+ useHighlights ? [[rehypeCodeHighlights, rehypeCodeOptions]] : []
300
318
  ),
301
- rehypeCodeOptions: {
302
- ...config.mdxOptions?.rehypeCodeOptions,
303
- themes: { light: geistShikiTheme },
304
- defaultColor: "light",
305
- },
319
+ rehypeCodeOptions: useHighlights ? false : rehypeCodeOptions,
306
320
  },
307
321
  plugins: [
308
322
  lastModified({ versionControl: getLastModified }),
@@ -1,4 +1,4 @@
1
- import { ImageResponse } from "next/og";
1
+ import { createOpenGraphImage } from "@/lib/geistdocs/og";
2
2
 
3
3
  export const alt = "Geistdocs documentation platform";
4
4
  export const contentType = "image/png";
@@ -8,33 +8,9 @@ export const size = {
8
8
  };
9
9
 
10
10
  const OpenGraphImage = () =>
11
- new ImageResponse(
12
- <div
13
- style={{
14
- alignItems: "center",
15
- background: "#000",
16
- color: "#fff",
17
- display: "flex",
18
- height: "100%",
19
- justifyContent: "center",
20
- width: "100%",
21
- }}
22
- >
23
- <div
24
- style={{
25
- display: "flex",
26
- flexDirection: "column",
27
- gap: 24,
28
- maxWidth: 920,
29
- }}
30
- >
31
- <div style={{ fontSize: 76, fontWeight: 600 }}>Geistdocs</div>
32
- <div style={{ color: "#a1a1a1", fontSize: 36, lineHeight: 1.25 }}>
33
- Package-backed documentation sites for people and agents
34
- </div>
35
- </div>
36
- </div>,
37
- size
11
+ createOpenGraphImage(
12
+ "Geistdocs",
13
+ "Package-backed documentation sites for people and agents"
38
14
  );
39
15
 
40
16
  export default OpenGraphImage;