@vercel/geistdocs 2.14.0 → 2.14.1
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.
- package/dist/assets/icons/icon-brain.d.ts +26 -0
- package/dist/assets/icons/icon-brain.d.ts.map +1 -0
- package/dist/assets/icons/icon-brain.js +25 -0
- package/dist/assets/icons/icon-buildings.d.ts +26 -0
- package/dist/assets/icons/icon-buildings.d.ts.map +1 -0
- package/dist/assets/icons/icon-buildings.js +25 -0
- package/dist/assets/icons/icon-chart-activity.d.ts +26 -0
- package/dist/assets/icons/icon-chart-activity.d.ts.map +1 -0
- package/dist/assets/icons/icon-chart-activity.js +25 -0
- package/dist/assets/icons/icon-code.d.ts +26 -0
- package/dist/assets/icons/icon-code.d.ts.map +1 -0
- package/dist/assets/icons/icon-code.js +25 -0
- package/dist/assets/icons/icon-git-merge.d.ts +26 -0
- package/dist/assets/icons/icon-git-merge.d.ts.map +1 -0
- package/dist/assets/icons/icon-git-merge.js +25 -0
- package/dist/assets/icons/icon-git-pull-request.d.ts +26 -0
- package/dist/assets/icons/icon-git-pull-request.d.ts.map +1 -0
- package/dist/assets/icons/icon-git-pull-request.js +25 -0
- package/dist/assets/icons/icon-headset.d.ts +26 -0
- package/dist/assets/icons/icon-headset.d.ts.map +1 -0
- package/dist/assets/icons/icon-headset.js +25 -0
- package/dist/assets/icons/icon-magnifying-glass.d.ts +26 -0
- package/dist/assets/icons/icon-magnifying-glass.d.ts.map +1 -0
- package/dist/assets/icons/icon-magnifying-glass.js +25 -0
- package/dist/assets/icons/icon-target.d.ts +26 -0
- package/dist/assets/icons/icon-target.d.ts.map +1 -0
- package/dist/assets/icons/icon-target.js +26 -0
- package/dist/assets/icons/icon-warning.d.ts +26 -0
- package/dist/assets/icons/icon-warning.d.ts.map +1 -0
- package/dist/assets/icons/icon-warning.js +25 -0
- package/dist/assets/icons/index.d.ts +10 -0
- package/dist/assets/icons/index.d.ts.map +1 -1
- package/dist/assets/icons/index.js +10 -0
- package/dist/cli/index.js +1 -1
- package/dist/components/code-block-tabs.d.ts.map +1 -1
- package/dist/components/code-block-tabs.js +4 -1
- package/dist/controls.d.ts.map +1 -1
- package/dist/controls.js +2 -2
- package/dist/internal/chat/dots-spinner.d.ts.map +1 -1
- package/dist/internal/chat/dots-spinner.js +4 -1
- package/dist/internal/chat/page-attachment.js +1 -1
- package/dist/internal/chat/shell.d.ts.map +1 -1
- package/dist/internal/chat/shell.js +65 -9
- package/dist/internal/navbar/desktop-menu.d.ts.map +1 -1
- package/dist/internal/navbar/desktop-menu.js +3 -1
- package/dist/internal/navbar/mobile-menu.d.ts.map +1 -1
- package/dist/internal/navbar/mobile-menu.js +28 -9
- package/dist/internal/navbar/navbar-logo.d.ts +3 -2
- package/dist/internal/navbar/navbar-logo.d.ts.map +1 -1
- package/dist/internal/navbar/navbar-logo.js +6 -3
- package/dist/internal/navbar/use-server-panel-mount.d.ts +9 -0
- package/dist/internal/navbar/use-server-panel-mount.d.ts.map +1 -0
- package/dist/internal/navbar/use-server-panel-mount.js +11 -0
- package/dist/internal/provider-client.d.ts.map +1 -1
- package/dist/internal/provider-client.js +24 -12
- package/dist/internal/search.d.ts.map +1 -1
- package/dist/internal/search.js +36 -4
- package/dist/source-config.d.ts +6 -0
- package/dist/source-config.d.ts.map +1 -1
- package/dist/source-config.js +13 -0
- package/docs/agents.md +1 -1
- package/docs/llms.txt +1 -1
- package/docs/manifest.json +1 -1
- package/package.json +3 -1
- package/rehype-task-list-labels.d.ts +9 -0
- package/rehype-task-list-labels.js +52 -0
- package/source-config.js +14 -0
- package/template/package.json +1 -1
|
@@ -22,18 +22,26 @@ const GeistdocsProviderInner = ({ config, search, theme: _theme, lang, ...props
|
|
|
22
22
|
if (!enabled) {
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
setIsOpen(false);
|
|
34
|
-
}
|
|
25
|
+
// Escape listens in the bubble phase and skips handled events, so a
|
|
26
|
+
// dialog, menu, or tooltip layered over the page closes first. Radix
|
|
27
|
+
// layers dismiss in the capture phase and mark the event handled.
|
|
28
|
+
const handleEscape = (event) => {
|
|
29
|
+
if (event.key !== "Escape" ||
|
|
30
|
+
!isOpen ||
|
|
31
|
+
event.defaultPrevented ||
|
|
32
|
+
event.isComposing) {
|
|
35
33
|
return;
|
|
36
34
|
}
|
|
35
|
+
event.preventDefault();
|
|
36
|
+
// The first Escape returns an expanded desktop panel to the sidebar.
|
|
37
|
+
if (isExpanded && !isMobile) {
|
|
38
|
+
setIsExpanded(false);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
setIsOpen(false);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const handleShortcut = (event) => {
|
|
37
45
|
if ((event.metaKey || event.ctrlKey) &&
|
|
38
46
|
!event.altKey &&
|
|
39
47
|
!event.shiftKey &&
|
|
@@ -42,8 +50,12 @@ const GeistdocsProviderInner = ({ config, search, theme: _theme, lang, ...props
|
|
|
42
50
|
setIsOpen((open) => !open);
|
|
43
51
|
}
|
|
44
52
|
};
|
|
45
|
-
document.addEventListener("keydown",
|
|
46
|
-
|
|
53
|
+
document.addEventListener("keydown", handleEscape);
|
|
54
|
+
document.addEventListener("keydown", handleShortcut, true);
|
|
55
|
+
return () => {
|
|
56
|
+
document.removeEventListener("keydown", handleEscape);
|
|
57
|
+
document.removeEventListener("keydown", handleShortcut, true);
|
|
58
|
+
};
|
|
47
59
|
}, [enabled, isExpanded, isMobile, isOpen, setIsExpanded, setIsOpen]);
|
|
48
60
|
// fumadocs spreads the provider's `search.options` onto the dialog, which is
|
|
49
61
|
// how a consumer reaches `tag`. Typed here so it survives the hand-off.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/internal/search.tsx"],"names":[],"mappings":"AAIA,OAAO,EAWL,KAAK,WAAW,
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/internal/search.tsx"],"names":[],"mappings":"AAIA,OAAO,EAWL,KAAK,WAAW,EAIjB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AA+C3D,eAAO,MAAM,qBAAqB,GAAI,4DAOnC,WAAW,GAAG;IACf;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAChD;;;;;;;;;;;;;OAaG;IACH,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC;CAClB,4CAqGA,CAAC"}
|
package/dist/internal/search.js
CHANGED
|
@@ -2,12 +2,33 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useDocsSearch } from "fumadocs-core/search/client";
|
|
4
4
|
import { useOnChange } from "fumadocs-core/utils/use-on-change";
|
|
5
|
-
import { SearchDialog as FumadocsSearchDialog, SearchDialogClose, SearchDialogContent, SearchDialogFooter, SearchDialogHeader, SearchDialogIcon, SearchDialogInput, SearchDialogList, SearchDialogListItem, SearchDialogOverlay, TagsList, TagsListItem, } from "fumadocs-ui/components/dialog/search";
|
|
5
|
+
import { SearchDialog as FumadocsSearchDialog, SearchDialogClose, SearchDialogContent, SearchDialogFooter, SearchDialogHeader, SearchDialogIcon, SearchDialogInput, SearchDialogList, SearchDialogListItem, SearchDialogOverlay, TagsList, TagsListItem, useSearchList, } from "fumadocs-ui/components/dialog/search";
|
|
6
6
|
import { useI18n } from "fumadocs-ui/contexts/i18n";
|
|
7
|
-
import { useState } from "react";
|
|
7
|
+
import { useEffect, useId, useState } from "react";
|
|
8
8
|
import { getPublicPath } from "../config";
|
|
9
|
+
const WHITESPACE_PATTERN = /\s/g;
|
|
10
|
+
const getOptionId = (listId, itemId) => `${listId}-${itemId.replaceAll(WHITESPACE_PATTERN, "-")}`;
|
|
11
|
+
/**
|
|
12
|
+
* A result rendered as a real component, since fumadocs calls `Item` as a
|
|
13
|
+
* plain function. It reports the arrow-key selection to the input's
|
|
14
|
+
* `aria-activedescendant`, and follows Tab focus so Enter opens the result
|
|
15
|
+
* the reader focused rather than the arrow-key selection.
|
|
16
|
+
*/
|
|
17
|
+
const SearchResult = ({ item, listId, onActiveChange, ...props }) => {
|
|
18
|
+
const { active, setActive } = useSearchList();
|
|
19
|
+
const id = getOptionId(listId, item.id);
|
|
20
|
+
const isActive = active === item.id;
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (isActive) {
|
|
23
|
+
onActiveChange(id);
|
|
24
|
+
}
|
|
25
|
+
}, [id, isActive, onActiveChange]);
|
|
26
|
+
return (_jsx(SearchDialogListItem, { ...props, id: id, item: item, onFocus: () => setActive(item.id), role: "option" }));
|
|
27
|
+
};
|
|
9
28
|
export const GeistdocsSearchDialog = ({ allowClear = false, basePath, onTagChange, tag, tags, ...props }) => {
|
|
10
|
-
const { locale } = useI18n();
|
|
29
|
+
const { locale, text } = useI18n();
|
|
30
|
+
const listId = useId();
|
|
31
|
+
const [activeOptionId, setActiveOptionId] = useState();
|
|
11
32
|
const hasTags = tags !== undefined && tags.length > 0;
|
|
12
33
|
// Holds whatever scope is in force, which is not always a pill: an array scope
|
|
13
34
|
// has no single pill to select, and it stays in force until a reader picks
|
|
@@ -24,7 +45,18 @@ export const GeistdocsSearchDialog = ({ allowClear = false, basePath, onTagChang
|
|
|
24
45
|
tag: hasTags ? selected : tag,
|
|
25
46
|
api: getPublicPath("/api/search", basePath),
|
|
26
47
|
});
|
|
27
|
-
|
|
48
|
+
const results = Array.isArray(query.data) ? query.data : null;
|
|
49
|
+
const hasResults = results !== null && results.length > 0;
|
|
50
|
+
let resultStatus = "";
|
|
51
|
+
if (results && !query.isLoading) {
|
|
52
|
+
resultStatus = hasResults
|
|
53
|
+
? `${results.length} ${results.length === 1 ? "result" : "results"}`
|
|
54
|
+
: text.searchNoResult;
|
|
55
|
+
}
|
|
56
|
+
return (_jsxs(FumadocsSearchDialog, { isLoading: query.isLoading, onSearchChange: setSearch, search: search, ...props, children: [_jsx(SearchDialogOverlay, { className: "bg-background-100/80 backdrop-blur-none" }), _jsxs(SearchDialogContent, { className: "w-[640px] max-w-[calc(100vw-1rem)] border-none shadow-[var(--ds-shadow-modal)]", "data-geistdocs-command-modal": true, onEscapeKeyDown: () => props.onOpenChange(false), children: [_jsxs(SearchDialogHeader, { children: [_jsx(SearchDialogIcon, {}), _jsx(SearchDialogInput, { "aria-activedescendant": hasResults ? activeOptionId : undefined, "aria-autocomplete": "list", "aria-controls": listId, "aria-expanded": hasResults, "aria-label": text.search, role: "combobox" }), _jsx(SearchDialogClose, {}), _jsx("p", { "aria-live": "polite", className: "sr-only", role: "status", children: resultStatus })] }), _jsx(SearchDialogList, { "aria-label": hasResults ? "Search results" : undefined, Item: (itemProps) => (_jsx(SearchResult, { ...itemProps, listId: listId, onActiveChange: setActiveOptionId })), id: listId, items: query.data === "empty" ? null : query.data,
|
|
57
|
+
// Only a listbox while it holds options: the empty state is a
|
|
58
|
+
// message, announced through the status region instead.
|
|
59
|
+
role: hasResults ? "listbox" : undefined }), hasTags ? (_jsx(SearchDialogFooter, { children: _jsx(TagsList, { allowClear: allowClear, onTagChange: (value) => {
|
|
28
60
|
setSelected(value);
|
|
29
61
|
onTagChange?.(value);
|
|
30
62
|
}, tag: typeof selected === "string" ? selected : undefined, children: tags.map((item) => (_jsx(TagsListItem, { value: item.value, children: item.name }, item.value))) }) })) : null] })] }));
|
package/dist/source-config.d.ts
CHANGED
|
@@ -76,6 +76,12 @@ export declare const geistdocsMetaSchema: z.ZodObject<{
|
|
|
76
76
|
defaultOpen: z.ZodOptional<z.ZodBoolean>;
|
|
77
77
|
icon: z.ZodOptional<z.ZodString>;
|
|
78
78
|
}, z.core.$strip>;
|
|
79
|
+
/**
|
|
80
|
+
* Adds Geistdocs rehype plugins after the consumer's. An array is handed to
|
|
81
|
+
* Fumadocs, which places it among its defaults; a function receives those
|
|
82
|
+
* defaults and returns the final list.
|
|
83
|
+
*/
|
|
84
|
+
export declare const resolveGeistdocsRehypePlugins: (consumerPlugins: DefaultMDXOptions["rehypePlugins"]) => NonNullable<DefaultMDXOptions["rehypePlugins"]>;
|
|
79
85
|
export declare const defineGeistdocsSourceConfig: (config?: GeistdocsSourceConfigOptions) => import("fumadocs-mdx/config").GlobalConfig;
|
|
80
86
|
export {};
|
|
81
87
|
//# sourceMappingURL=source-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-config.d.ts","sourceRoot":"","sources":["../src/source-config.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,KAAK,iBAAiB,EACtB,YAAY,IAAI,oBAAoB,EAGrC,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"source-config.d.ts","sourceRoot":"","sources":["../src/source-config.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,KAAK,iBAAiB,EACtB,YAAY,IAAI,oBAAoB,EAGrC,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,KAAK,mBAAmB,GAAG,WAAW,CACpC,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAC3C,CAAC;AAEF,MAAM,WAAW,4BAA4B;IAC3C,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC/B,OAAO,CAAC,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC;CAC1C;AAQD;;;;;;;GAOG;AACH,eAAO,MAAM,6BAA6B,GACxC,UAAU,SAAS,EAAE,EACrB,kBAAiB,SAAS,EAAO,KAChC,SAAS,EAgBX,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;CAsG3B,CAAC;AAEF,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAwCrC,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;iBAAa,CAAC;AAE9C;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,GACxC,iBAAiB,iBAAiB,CAAC,eAAe,CAAC,KAClD,WAAW,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAKhD,CAAC;AAEF,eAAO,MAAM,2BAA2B,GACtC,SAAQ,4BAAiC,+CA2B1C,CAAC"}
|
package/dist/source-config.js
CHANGED
|
@@ -2,6 +2,7 @@ import { remarkHeading, remarkMdxMermaid, remarkSteps, remarkStructure, } from "
|
|
|
2
2
|
import { defineConfig as defineFumadocsConfig, frontmatterSchema, metaSchema, } from "fumadocs-mdx/config";
|
|
3
3
|
import lastModified from "fumadocs-mdx/plugins/last-modified";
|
|
4
4
|
import { z } from "zod";
|
|
5
|
+
import { rehypeTaskListLabels } from "../rehype-task-list-labels.js";
|
|
5
6
|
import { remarkDetails } from "../remark-details.js";
|
|
6
7
|
import { getLastModified } from "./internal/last-modified.js";
|
|
7
8
|
const pluginOf = (entry) => Array.isArray(entry) ? entry[0] : entry;
|
|
@@ -163,6 +164,17 @@ export const geistdocsFrontmatterSchema = frontmatterSchema.extend({
|
|
|
163
164
|
.optional(),
|
|
164
165
|
});
|
|
165
166
|
export const geistdocsMetaSchema = metaSchema;
|
|
167
|
+
/**
|
|
168
|
+
* Adds Geistdocs rehype plugins after the consumer's. An array is handed to
|
|
169
|
+
* Fumadocs, which places it among its defaults; a function receives those
|
|
170
|
+
* defaults and returns the final list.
|
|
171
|
+
*/
|
|
172
|
+
export const resolveGeistdocsRehypePlugins = (consumerPlugins) => {
|
|
173
|
+
if (typeof consumerPlugins === "function") {
|
|
174
|
+
return (defaults) => [...consumerPlugins(defaults), rehypeTaskListLabels];
|
|
175
|
+
}
|
|
176
|
+
return [...(consumerPlugins ?? []), rehypeTaskListLabels];
|
|
177
|
+
};
|
|
166
178
|
export const defineGeistdocsSourceConfig = (config = {}) => {
|
|
167
179
|
const existingRemarkPlugins = Array.isArray(config.mdxOptions?.remarkPlugins)
|
|
168
180
|
? config.mdxOptions.remarkPlugins
|
|
@@ -173,6 +185,7 @@ export const defineGeistdocsSourceConfig = (config = {}) => {
|
|
|
173
185
|
mdxOptions: {
|
|
174
186
|
...config.mdxOptions,
|
|
175
187
|
remarkPlugins: (defaults) => resolveGeistdocsRemarkPlugins(defaults, existingRemarkPlugins),
|
|
188
|
+
rehypePlugins: resolveGeistdocsRehypePlugins(config.mdxOptions?.rehypePlugins),
|
|
176
189
|
rehypeCodeOptions: {
|
|
177
190
|
...config.mdxOptions?.rehypeCodeOptions,
|
|
178
191
|
themes: { light: geistShikiTheme, dark: geistShikiTheme },
|
package/docs/agents.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Geistdocs Package Docs
|
|
2
2
|
|
|
3
|
-
These docs are bundled with `@vercel/geistdocs` 2.14.
|
|
3
|
+
These docs are bundled with `@vercel/geistdocs` 2.14.1 so agents can understand the installed package without web access.
|
|
4
4
|
They are generated from `apps/template/content/docs` during the package build.
|
|
5
5
|
|
|
6
6
|
## How to use these files
|
package/docs/llms.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Geistdocs Package Documentation
|
|
2
2
|
|
|
3
|
-
These docs are bundled with `@vercel/geistdocs` 2.14.
|
|
3
|
+
These docs are bundled with `@vercel/geistdocs` 2.14.1.
|
|
4
4
|
They describe how to build package-backed Geistdocs sites and how to use the package APIs from generated project adapters.
|
|
5
5
|
|
|
6
6
|
## Documentation Index
|
package/docs/manifest.json
CHANGED
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.14.
|
|
4
|
+
"version": "2.14.1",
|
|
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-task-list-labels.d.ts",
|
|
31
|
+
"rehype-task-list-labels.js",
|
|
30
32
|
"remark-details.d.ts",
|
|
31
33
|
"remark-details.js",
|
|
32
34
|
"source-config.js",
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const NESTED_LIST_TAGS = new Set(["ol", "ul"]);
|
|
2
|
+
|
|
3
|
+
const hasClass = (node, name) => {
|
|
4
|
+
const className = node.properties?.className;
|
|
5
|
+
return Array.isArray(className) && className.includes(name);
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const isTaskCheckbox = (node) =>
|
|
9
|
+
node.type === "element" &&
|
|
10
|
+
node.tagName === "input" &&
|
|
11
|
+
node.properties?.type === "checkbox";
|
|
12
|
+
|
|
13
|
+
// Text of a task item, without nested lists: their items label themselves.
|
|
14
|
+
const textOf = (node) => {
|
|
15
|
+
if (node.type === "text") {
|
|
16
|
+
return node.value ?? "";
|
|
17
|
+
}
|
|
18
|
+
if (NESTED_LIST_TAGS.has(node.tagName)) {
|
|
19
|
+
return "";
|
|
20
|
+
}
|
|
21
|
+
return (node.children ?? []).map(textOf).join("");
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const visit = (node, inTaskItem) => {
|
|
25
|
+
const children = node.children ?? [];
|
|
26
|
+
const isTaskItem =
|
|
27
|
+
node.type === "element" &&
|
|
28
|
+
node.tagName === "li" &&
|
|
29
|
+
hasClass(node, "task-list-item");
|
|
30
|
+
|
|
31
|
+
for (const child of children) {
|
|
32
|
+
if (
|
|
33
|
+
(inTaskItem || isTaskItem) &&
|
|
34
|
+
isTaskCheckbox(child) &&
|
|
35
|
+
child.properties.ariaLabel === undefined
|
|
36
|
+
) {
|
|
37
|
+
const label = children.map(textOf).join("").trim();
|
|
38
|
+
if (label) {
|
|
39
|
+
child.properties.ariaLabel = label;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
// A loose task item wraps its checkbox in the item's first paragraph.
|
|
43
|
+
visit(child, isTaskItem && child.tagName === "p");
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// Names GFM task-list checkboxes (`- [x] Item`) after their item text.
|
|
48
|
+
// remark-gfm renders a bare `<input type="checkbox" disabled>`, which screen
|
|
49
|
+
// readers announce as an unlabeled checkbox.
|
|
50
|
+
export const rehypeTaskListLabels = () => (tree) => {
|
|
51
|
+
visit(tree, false);
|
|
52
|
+
};
|
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 { rehypeTaskListLabels } from "./rehype-task-list-labels.js";
|
|
18
19
|
import { remarkDetails } from "./remark-details.js";
|
|
19
20
|
|
|
20
21
|
// Mirrors src/internal/last-modified.ts. This file must stay dependency-free
|
|
@@ -272,6 +273,16 @@ export const resolveGeistdocsRemarkPlugins = (
|
|
|
272
273
|
return list;
|
|
273
274
|
};
|
|
274
275
|
|
|
276
|
+
// Mirrors src/source-config.ts. Geistdocs rehype plugins run after the
|
|
277
|
+
// consumer's: an array is handed to Fumadocs, which places it among its
|
|
278
|
+
// defaults; a function receives those defaults and returns the final list.
|
|
279
|
+
export const resolveGeistdocsRehypePlugins = (consumerPlugins) => {
|
|
280
|
+
if (typeof consumerPlugins === "function") {
|
|
281
|
+
return (defaults) => [...consumerPlugins(defaults), rehypeTaskListLabels];
|
|
282
|
+
}
|
|
283
|
+
return [...(consumerPlugins ?? []), rehypeTaskListLabels];
|
|
284
|
+
};
|
|
285
|
+
|
|
275
286
|
export const defineGeistdocsSourceConfig = (config = {}) => {
|
|
276
287
|
const existingRemarkPlugins = Array.isArray(config.mdxOptions?.remarkPlugins)
|
|
277
288
|
? config.mdxOptions.remarkPlugins
|
|
@@ -284,6 +295,9 @@ export const defineGeistdocsSourceConfig = (config = {}) => {
|
|
|
284
295
|
...config.mdxOptions,
|
|
285
296
|
remarkPlugins: (defaults) =>
|
|
286
297
|
resolveGeistdocsRemarkPlugins(defaults, existingRemarkPlugins),
|
|
298
|
+
rehypePlugins: resolveGeistdocsRehypePlugins(
|
|
299
|
+
config.mdxOptions?.rehypePlugins
|
|
300
|
+
),
|
|
287
301
|
rehypeCodeOptions: {
|
|
288
302
|
...config.mdxOptions?.rehypeCodeOptions,
|
|
289
303
|
themes: { light: geistShikiTheme, dark: geistShikiTheme },
|
package/template/package.json
CHANGED