sourcey 3.4.0 → 3.4.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/client/search.js +26 -7
- package/dist/components/layout/Header.d.ts.map +1 -1
- package/dist/components/layout/Header.js +2 -2
- package/dist/components/layout/Page.d.ts.map +1 -1
- package/dist/components/layout/Page.js +4 -4
- package/dist/components/layout/Sidebar.d.ts.map +1 -1
- package/dist/components/layout/Sidebar.js +12 -8
- package/dist/components/layout/TableOfContents.d.ts.map +1 -1
- package/dist/components/layout/TableOfContents.js +2 -1
- package/dist/config.d.ts +8 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +4 -0
- package/dist/core/markdown-loader.d.ts.map +1 -1
- package/dist/core/markdown-loader.js +7 -2
- package/dist/core/search-indexer.d.ts +3 -1
- package/dist/core/search-indexer.d.ts.map +1 -1
- package/dist/core/search-indexer.js +7 -3
- package/dist/dev-server.js +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/renderer/html-builder.d.ts +2 -0
- package/dist/renderer/html-builder.d.ts.map +1 -1
- package/dist/renderer/html-builder.js +6 -0
- package/dist/renderer/llms.d.ts +6 -0
- package/dist/renderer/llms.d.ts.map +1 -0
- package/dist/renderer/llms.js +247 -0
- package/dist/themes/default/main.css +3 -0
- package/dist/themes/default/sourcey.css +65 -15
- package/dist/utils/icons.d.ts +4 -0
- package/dist/utils/icons.d.ts.map +1 -1
- package/dist/utils/icons.js +6 -0
- package/dist/utils/markdown.d.ts.map +1 -1
- package/dist/utils/markdown.js +53 -6
- package/package.json +1 -1
package/dist/client/search.js
CHANGED
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
tag: e.tab || '',
|
|
29
29
|
content: e.content || '',
|
|
30
30
|
category: e.category || '',
|
|
31
|
+
featured: !!e.featured,
|
|
31
32
|
searchText: [e.method || '', e.path || '', e.title || '', e.content || '', e.tab || ''].join(' ').toLowerCase()
|
|
32
33
|
};
|
|
33
34
|
});
|
|
@@ -39,7 +40,23 @@
|
|
|
39
40
|
});
|
|
40
41
|
}
|
|
41
42
|
|
|
43
|
+
var dialogInner = dialog.querySelector('.search-dialog-inner');
|
|
44
|
+
|
|
45
|
+
function positionDialog() {
|
|
46
|
+
if (!openBtn || !dialogInner) return;
|
|
47
|
+
var rect = openBtn.getBoundingClientRect();
|
|
48
|
+
dialogInner.style.position = 'absolute';
|
|
49
|
+
dialogInner.style.top = (rect.top - 4) + 'px';
|
|
50
|
+
var extraWidth = Math.min(rect.width * 0.5, 200);
|
|
51
|
+
dialogInner.style.left = (rect.left - extraWidth / 2) + 'px';
|
|
52
|
+
dialogInner.style.width = (rect.width + extraWidth) + 'px';
|
|
53
|
+
dialogInner.style.maxWidth = 'none';
|
|
54
|
+
dialogInner.style.transform = 'none';
|
|
55
|
+
dialogInner.style.margin = '0';
|
|
56
|
+
}
|
|
57
|
+
|
|
42
58
|
function open() {
|
|
59
|
+
positionDialog();
|
|
43
60
|
dialog.classList.add('open');
|
|
44
61
|
input.value = '';
|
|
45
62
|
input.focus();
|
|
@@ -60,20 +77,22 @@
|
|
|
60
77
|
function showResults(query) {
|
|
61
78
|
var q = query.toLowerCase().trim();
|
|
62
79
|
if (!q) {
|
|
63
|
-
|
|
80
|
+
// Show featured pages first, then endpoints
|
|
81
|
+
var featured = entries.filter(function (e) { return e.featured; });
|
|
82
|
+
var rest = entries.filter(function (e) { return !e.featured && e.category !== 'Sections'; });
|
|
83
|
+
filtered = featured.concat(rest).slice(0, 30);
|
|
64
84
|
} else {
|
|
65
85
|
var terms = q.split(/\s+/);
|
|
66
86
|
filtered = entries.filter(function (e) {
|
|
67
87
|
return terms.every(function (t) { return e.searchText.indexOf(t) !== -1; });
|
|
68
88
|
});
|
|
89
|
+
// Sort by category so groups stay together (only for search results)
|
|
90
|
+
var categoryOrder = { Pages: 0, Sections: 1, Endpoints: 2, Models: 3 };
|
|
91
|
+
filtered.sort(function (a, b) {
|
|
92
|
+
return (categoryOrder[a.category] || 9) - (categoryOrder[b.category] || 9);
|
|
93
|
+
});
|
|
69
94
|
}
|
|
70
95
|
|
|
71
|
-
// Sort by category so groups stay together
|
|
72
|
-
var categoryOrder = { Pages: 0, Sections: 1, Endpoints: 2, Models: 3 };
|
|
73
|
-
filtered.sort(function (a, b) {
|
|
74
|
-
return (categoryOrder[a.category] || 9) - (categoryOrder[b.category] || 9);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
96
|
activeIndex = filtered.length ? 0 : -1;
|
|
78
97
|
render();
|
|
79
98
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Header.d.ts","sourceRoot":"","sources":["../../../src/components/layout/Header.tsx"],"names":[],"mappings":"AA6EA;;;;;GAKG;AACH,wBAAgB,MAAM,
|
|
1
|
+
{"version":3,"file":"Header.d.ts","sourceRoot":"","sources":["../../../src/components/layout/Header.tsx"],"names":[],"mappings":"AA6EA;;;;;GAKG;AACH,wBAAgB,MAAM,iCAiIrB"}
|
|
@@ -37,9 +37,9 @@ export function Header() {
|
|
|
37
37
|
const site = useContext(SiteContext);
|
|
38
38
|
const base = options.assetBase;
|
|
39
39
|
const logoHref = site.logo?.href ?? `${base}${nav.tabs[0]?.href ?? ""}`;
|
|
40
|
-
return (_jsxs("div", { id: "navbar", class: "z-30 fixed lg:sticky top-0 w-full", children: [_jsx("div", { class: "absolute w-full h-full flex-none border-b border-[rgb(var(--color-gray-200)/0.7)] dark:border-[rgb(var(--color-gray-300)/0.06)] bg-[rgb(var(--color-background-light))] dark:bg-[rgb(var(--color-background-dark))]" }), _jsxs("div", { class: "max-w-[92rem] mx-auto relative", children: [_jsx("div", { class: "relative", children: _jsx("div", { class: "flex items-center lg:px-12 h-16 min-w-0 mx-4 lg:mx-0", children: _jsxs("div", { class: "h-full relative flex-1 flex items-center gap-x-4 min-w-0 border-b border-[rgb(var(--color-gray-500)/0.08)] dark:border-[rgb(var(--color-gray-300)/0.08)]", children: [_jsx("div", { class: "flex-1 flex items-center gap-x-4", children: _jsx(Logo, { href: logoHref, logo: site.logo, name: site.name }) }), _jsx("div", { class: "relative hidden lg:flex items-center flex-1 z-20 gap-2
|
|
40
|
+
return (_jsxs("div", { id: "navbar", class: "z-30 fixed lg:sticky top-0 w-full", children: [_jsx("div", { class: "absolute w-full h-full flex-none border-b border-[rgb(var(--color-gray-200)/0.7)] dark:border-[rgb(var(--color-gray-300)/0.06)] bg-[rgb(var(--color-background-light))] dark:bg-[rgb(var(--color-background-dark))]" }), _jsxs("div", { class: "max-w-[92rem] mx-auto relative", children: [_jsx("div", { class: "relative", children: _jsx("div", { class: "flex items-center lg:px-12 h-16 min-w-0 mx-4 lg:mx-0", children: _jsxs("div", { class: "h-full relative flex-1 flex items-center gap-x-4 min-w-0 border-b border-[rgb(var(--color-gray-500)/0.08)] dark:border-[rgb(var(--color-gray-300)/0.08)]", children: [_jsx("div", { class: "flex-1 flex items-center gap-x-4", children: _jsx(Logo, { href: logoHref, logo: site.logo, name: site.name }) }), _jsx("div", { class: "relative hidden lg:flex items-center flex-1 z-20 gap-2", children: _jsx("button", { id: "search-open", type: "button", "aria-label": "Search", class: "group flex pointer-events-auto rounded-lg w-full items-center text-sm leading-6 h-9 pl-3.5 pr-3 text-[rgb(var(--color-gray-500))] dark:text-[rgb(var(--color-gray-400))] ring-1 ring-[rgb(var(--color-gray-400)/0.3)] hover:ring-[rgb(var(--color-gray-600)/0.3)] dark:ring-[rgb(var(--color-gray-600)/0.3)] dark:hover:ring-[rgb(var(--color-gray-500)/0.3)] justify-between truncate gap-2 min-w-[43px] cursor-pointer bg-[rgb(var(--color-background-light))] dark:bg-[rgb(var(--color-background-dark))] dark:brightness-110 dark:hover:brightness-125", children: _jsxs("div", { class: "flex items-center gap-2 min-w-[42px]", children: [_jsx(SearchIcon, {}), _jsxs("div", { class: "truncate min-w-0", children: ["Type ", _jsx("kbd", { children: "/" }), " to search"] })] }) }) }), _jsxs("div", { class: "flex-1 relative hidden lg:flex items-center ml-auto justify-end space-x-4", children: [_jsx("nav", { class: "text-sm", children: _jsxs("ul", { class: "flex space-x-6 items-center", children: [site.navbar.links.map((link) => (_jsx("li", { children: _jsx("a", { href: link.href, target: "_blank", rel: "noopener noreferrer", class: "text-[rgb(var(--color-gray-400))] hover:text-[rgb(var(--color-gray-600))] dark:hover:text-[rgb(var(--color-gray-300))]", children: link.type === "link"
|
|
41
41
|
? (link.label ?? link.href)
|
|
42
|
-
: (_jsxs(_Fragment, { children: [_jsx(SocialIcon, { type: link.type }), link.label && _jsx("span", { class: "ml-1", children: link.label })] })) }) }, link.href))), site.navbar.primary && (_jsx("li", { children: _jsxs("a", { href: site.navbar.primary.href, target: "_blank", class: "group px-4 py-1.5 relative inline-flex items-center text-sm font-medium", children: [_jsx("span", { class: "absolute inset-0 bg-[rgb(var(--color-primary-dark))] rounded-lg group-hover:opacity-90" }), _jsx("span", { class: "z-10 text-white", children: site.navbar.primary.label })] }) }))] }) }),
|
|
42
|
+
: (_jsxs(_Fragment, { children: [_jsx(SocialIcon, { type: link.type }), link.label && _jsx("span", { class: "ml-1", children: link.label })] })) }) }, link.href))), site.navbar.primary && (_jsx("li", { children: _jsxs("a", { href: site.navbar.primary.href, target: "_blank", class: "group px-4 py-1.5 relative inline-flex items-center text-sm font-medium", children: [_jsx("span", { class: "absolute inset-0 bg-[rgb(var(--color-primary-dark))] rounded-lg group-hover:opacity-90" }), _jsx("span", { class: "z-10 text-white", children: site.navbar.primary.label })] }) }))] }) }), _jsxs("button", { id: "theme-toggle", type: "button", "aria-label": "Toggle theme", class: "p-2 flex items-center justify-center cursor-pointer text-[rgb(var(--color-gray-400))] hover:text-[rgb(var(--color-gray-600))] dark:text-[rgb(var(--color-gray-500))] dark:hover:text-[rgb(var(--color-gray-300))]", children: [_jsx(SunIcon, {}), _jsx(MoonIcon, {})] })] }), _jsxs("div", { class: "flex lg:hidden items-center gap-3", children: [_jsx("button", { id: "search-open-mobile", type: "button", "aria-label": "Search", class: "text-[rgb(var(--color-gray-500))] w-8 h-8 flex items-center justify-center", children: _jsx(SearchIcon, {}) }), _jsx("button", { type: "button", "data-drawer-slide": "right", "aria-label": "Open menu", class: "text-[rgb(var(--color-gray-500))] w-8 h-8 flex items-center justify-center hover:text-[rgb(var(--color-gray-600))]", children: _jsx("svg", { class: "h-4", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 448 512", children: _jsx("path", { d: "M0 96C0 78.3 14.3 64 32 64H416c17.7 0 32 14.3 32 32s-14.3 32-32 32H32C14.3 128 0 113.7 0 96zM0 256c0-17.7 14.3-32 32-32H416c17.7 0 32 14.3 32 32s-14.3 32-32 32H32c-17.7 0-32-14.3-32-32zM448 416c0 17.7-14.3 32-32 32H32c-17.7 0-32-14.3-32-32s14.3-32 32-32H416c17.7 0 32 14.3 32 32z" }) }) })] })] }) }) }), _jsx(MobileBreadcrumbs, { nav: nav }), nav.tabs.length > 1 && (_jsx("div", { class: "hidden lg:flex px-12 h-12", children: _jsx("div", { class: "h-full flex text-sm gap-x-6", children: nav.tabs.map((tab) => {
|
|
43
43
|
const isActive = tab.slug === nav.activeTabSlug;
|
|
44
44
|
return (_jsxs("a", { href: `${base}${tab.href}`, class: `group relative h-full gap-2 flex items-center font-medium cursor-pointer transition-colors ${isActive
|
|
45
45
|
? "text-[rgb(var(--color-gray-800))] dark:text-[rgb(var(--color-gray-200))]"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Page.d.ts","sourceRoot":"","sources":["../../../src/components/layout/Page.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Page.d.ts","sourceRoot":"","sources":["../../../src/components/layout/Page.tsx"],"names":[],"mappings":"AAgPA,wBAAgB,IAAI,iCAqCnB"}
|
|
@@ -20,7 +20,7 @@ function MarkdownPageContent({ page, className = "" }) {
|
|
|
20
20
|
const activeTab = nav.tabs.find((t) => t.slug === nav.activeTabSlug);
|
|
21
21
|
const activeGroup = activeTab?.groups.find((g) => g.items.some((item) => item.id === nav.activePageSlug));
|
|
22
22
|
const eyebrow = activeGroup?.label;
|
|
23
|
-
return (_jsxs("div", { class: `relative grow box-border flex-col w-full mx-auto px-1 min-w-0 ${className}`, id: "content-area", children: [_jsxs("header", { class: "relative leading-none", children: [_jsxs("div", { class: "mt-0.5 space-y-2.5", children: [eyebrow && (_jsx("div", { class: "h-5 text-[rgb(var(--color-primary))] dark:text-[rgb(var(--color-primary-light))] text-sm font-semibold", children: eyebrow })), _jsx("div", { class: "flex flex-col sm:flex-row items-start sm:items-center relative gap-2 min-w-0", children: _jsx("h1", { class: "text-2xl sm:text-3xl text-[rgb(var(--color-gray-900))] tracking-tight dark:text-[rgb(var(--color-gray-200))] font-bold", style: "overflow-wrap: anywhere", children: page.title }) })] }), page.description && (_jsx("div", { class: "mt-2 text-lg prose prose-gray dark:prose-invert", style: "overflow-wrap: anywhere", children: _jsx(Markdown, { content: page.description, inline: true }) }))] }), _jsx("div", { class: "prose prose-gray dark:prose-invert relative mt-8 mb-14 max-w-none", dangerouslySetInnerHTML: { __html: page.html } }), _jsx(PageNavigation, {}), _jsx(ContentFooter, {})] }));
|
|
23
|
+
return (_jsxs("div", { class: `relative grow box-border flex-col w-full mx-auto px-1 min-w-0 ${className}`, id: "content-area", children: [_jsxs("header", { class: "relative leading-none", children: [_jsxs("div", { class: "mt-0.5 space-y-2.5", children: [eyebrow && (_jsx("div", { class: "h-5 text-[rgb(var(--color-primary))] dark:text-[rgb(var(--color-primary-light))] text-sm font-semibold", children: eyebrow })), _jsx("div", { class: "flex flex-col sm:flex-row items-start sm:items-center relative gap-2 min-w-0", children: _jsx("h1", { class: "text-2xl sm:text-3xl text-[rgb(var(--color-gray-900))] tracking-tight dark:text-[rgb(var(--color-gray-200))] font-bold", style: "overflow-wrap: anywhere", children: page.title }) })] }), page.description && (_jsx("div", { class: "page-description mt-2 text-lg prose prose-gray dark:prose-invert", style: "overflow-wrap: anywhere", children: _jsx(Markdown, { content: page.description, inline: true }) }))] }), _jsx("div", { class: "prose prose-gray dark:prose-invert relative mt-8 mb-14 max-w-none", dangerouslySetInnerHTML: { __html: page.html } }), _jsx(PageNavigation, {}), _jsx(ContentFooter, {})] }));
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* OpenAPI spec page content.
|
|
@@ -61,7 +61,7 @@ function ContentFooter() {
|
|
|
61
61
|
editUrl = `${repoBase}/edit/${site.editBranch}/${basePath}${page.markdown.sourcePath}`;
|
|
62
62
|
}
|
|
63
63
|
const linkStyle = "hover:text-[rgb(var(--color-gray-600))] dark:hover:text-[rgb(var(--color-gray-300))] transition-colors";
|
|
64
|
-
return (_jsxs("div", { class: "mt-16 mb-8 flex items-center justify-between border-t border-[rgb(var(--color-gray-200)/0.7)] dark:border-[rgb(var(--color-gray-800)/0.5)] pt-6 text-xs text-[rgb(var(--color-gray-400))]", children: [_jsxs("
|
|
64
|
+
return (_jsxs("div", { class: "mt-16 mb-8 flex items-center justify-between border-t border-[rgb(var(--color-gray-200)/0.7)] dark:border-[rgb(var(--color-gray-800)/0.5)] pt-6 text-xs text-[rgb(var(--color-gray-400))]", children: [_jsxs("a", { href: "https://sourcey.com", target: "_blank", rel: "noopener noreferrer", class: `flex items-center gap-1.5 ${linkStyle}`, children: ["Built with", _jsx("img", { src: "https://sourcey.com/sourcey-logo.png", alt: "Sourcey", class: "h-4 w-4" })] }), _jsxs("div", { class: "flex items-center gap-4", children: [editUrl && (_jsxs("a", { href: editUrl, target: "_blank", rel: "noopener noreferrer", class: `${linkStyle} flex items-center gap-1`, children: [_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", "stroke-width": "1.5", stroke: "currentColor", class: "w-3 h-3 mr-0.5", children: _jsx("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L6.832 19.82a4.5 4.5 0 0 1-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 0 1 1.13-1.897L16.863 4.487Zm0 0L19.5 7.125" }) }), "Edit this page"] })), links.map((link) => (_jsx("a", { href: link.href, target: "_blank", rel: "noopener noreferrer", class: linkStyle, children: link.type === "link"
|
|
65
65
|
? (link.label ?? link.href)
|
|
66
66
|
: (_jsxs(_Fragment, { children: [_jsx(SocialIcon, { type: link.type }), link.label && _jsx("span", { class: "ml-1", children: link.label })] })) }, link.href)))] })] }));
|
|
67
67
|
}
|
|
@@ -70,7 +70,7 @@ function ContentFooter() {
|
|
|
70
70
|
// ---------------------------------------------------------------------------
|
|
71
71
|
function DefaultLayout() {
|
|
72
72
|
const page = useContext(PageContext);
|
|
73
|
-
return (_jsxs("div", { class: "max-w-[92rem] mx-auto relative px-4 lg:px-
|
|
73
|
+
return (_jsxs("div", { class: "max-w-[92rem] mx-auto relative px-4 lg:px-12", children: [_jsx(Sidebar, {}), _jsx("div", { id: "docs", class: "pt-[8.5rem] lg:pt-10", children: page.kind === "markdown" ? (_jsxs("div", { class: "flex flex-row-reverse gap-12 box-border w-full", children: [_jsx(TableOfContents, { headings: page.markdown.headings }), _jsx(MarkdownPageContent, { page: page.markdown, className: "lg:pl-[23.7rem] lg:-ml-12 xl:w-[calc(100%-28rem)]" })] })) : (_jsx(SpecPageContent, { className: "lg:pl-[23.7rem] lg:-ml-12" })) })] }));
|
|
74
74
|
}
|
|
75
75
|
function MinimalLayout() {
|
|
76
76
|
const page = useContext(PageContext);
|
|
@@ -78,7 +78,7 @@ function MinimalLayout() {
|
|
|
78
78
|
}
|
|
79
79
|
function ApiFirstLayout() {
|
|
80
80
|
const page = useContext(PageContext);
|
|
81
|
-
return (_jsxs("div", { class: "max-w-[92rem] mx-auto relative px-4 lg:px-
|
|
81
|
+
return (_jsxs("div", { class: "max-w-[92rem] mx-auto relative px-4 lg:px-12", children: [_jsx(Sidebar, {}), _jsx("div", { id: "docs", class: "pt-[8.5rem] lg:pt-10", children: page.kind === "markdown" ? (_jsxs("div", { class: "flex flex-row-reverse gap-12 box-border w-full", children: [_jsx(TableOfContents, { headings: page.markdown.headings }), _jsx(MarkdownPageContent, { page: page.markdown, className: "lg:pl-[23.7rem] lg:-ml-12 xl:w-[calc(100%-28rem)]" })] })) : (_jsx(SpecPageContent, { className: "lg:pl-[23.7rem] lg:-ml-12" })) })] }));
|
|
82
82
|
}
|
|
83
83
|
// ---------------------------------------------------------------------------
|
|
84
84
|
// Page shell
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sidebar.d.ts","sourceRoot":"","sources":["../../../src/components/layout/Sidebar.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Sidebar.d.ts","sourceRoot":"","sources":["../../../src/components/layout/Sidebar.tsx"],"names":[],"mappings":"AA+FA;;GAEG;AACH,wBAAgB,OAAO,wCAuGtB"}
|
|
@@ -4,11 +4,20 @@ import { NavigationContext, OptionsContext, SiteContext } from "../../renderer/c
|
|
|
4
4
|
import { SocialIcon, socialLabels } from "../ui/SocialIcon.js";
|
|
5
5
|
import { Logo } from "../ui/Logo.js";
|
|
6
6
|
/**
|
|
7
|
-
* Colored method
|
|
7
|
+
* Colored method indicator for API sidebar items.
|
|
8
|
+
* HTTP methods render as text pills. MCP methods render as coloured dots.
|
|
8
9
|
*/
|
|
9
10
|
function MethodPill({ method }) {
|
|
10
11
|
const m = method.toUpperCase();
|
|
11
|
-
const
|
|
12
|
+
const dotColors = {
|
|
13
|
+
TOOL: "bg-purple-500 dark:bg-purple-400",
|
|
14
|
+
RESOURCE: "bg-green-500 dark:bg-green-400",
|
|
15
|
+
PROMPT: "bg-blue-500 dark:bg-blue-400",
|
|
16
|
+
};
|
|
17
|
+
if (dotColors[m]) {
|
|
18
|
+
return (_jsx("span", { class: "flex items-center w-4 h-[1lh] shrink-0 justify-center", children: _jsx("span", { class: `w-1.5 h-1.5 rounded-full ${dotColors[m]}` }) }));
|
|
19
|
+
}
|
|
20
|
+
const label = m === "DELETE" ? "DEL" : m;
|
|
12
21
|
const colors = {
|
|
13
22
|
GET: "bg-green-400/20 dark:bg-green-400/20 text-green-700 dark:text-green-400",
|
|
14
23
|
POST: "bg-blue-400/20 dark:bg-blue-400/20 text-blue-700 dark:text-blue-400",
|
|
@@ -16,11 +25,6 @@ function MethodPill({ method }) {
|
|
|
16
25
|
DELETE: "bg-red-400/20 dark:bg-red-400/20 text-red-700 dark:text-red-400",
|
|
17
26
|
DEL: "bg-red-400/20 dark:bg-red-400/20 text-red-700 dark:text-red-400",
|
|
18
27
|
PATCH: "bg-orange-400/20 dark:bg-orange-400/20 text-orange-700 dark:text-orange-400",
|
|
19
|
-
TOOL: "bg-purple-400/20 dark:bg-purple-400/20 text-purple-700 dark:text-purple-400",
|
|
20
|
-
RESOURCE: "bg-green-400/20 dark:bg-green-400/20 text-green-700 dark:text-green-400",
|
|
21
|
-
RES: "bg-green-400/20 dark:bg-green-400/20 text-green-700 dark:text-green-400",
|
|
22
|
-
PROMPT: "bg-blue-400/20 dark:bg-blue-400/20 text-blue-700 dark:text-blue-400",
|
|
23
|
-
PRMT: "bg-blue-400/20 dark:bg-blue-400/20 text-blue-700 dark:text-blue-400",
|
|
24
28
|
};
|
|
25
29
|
return (_jsx("span", { class: "flex items-center w-8 h-[1lh] shrink-0", children: _jsx("span", { class: `px-1 py-0.5 rounded-md text-[0.55rem] leading-tight font-bold ${colors[m] ?? "bg-gray-400/20 text-gray-700"}`, children: label }) }));
|
|
26
30
|
}
|
|
@@ -28,7 +32,7 @@ function MethodPill({ method }) {
|
|
|
28
32
|
* Shared nav group rendering used by both desktop sidebar and mobile drawer.
|
|
29
33
|
*/
|
|
30
34
|
function NavGroups({ groups, activePageSlug, base }) {
|
|
31
|
-
return (_jsx(_Fragment, { children: groups.map((group, gi) => (_jsxs("div", { class: gi > 0 ? "mt-5" : "", children: [group.label && (_jsx("h5", { class: "nav-group-label", children: group.label })), _jsx("ul", { children: group.items.map((item) => {
|
|
35
|
+
return (_jsx(_Fragment, { children: groups.map((group, gi) => (_jsxs("div", { class: gi > 0 ? "mt-5" : "", children: [group.label && (_jsx("h5", { class: "nav-group-label", children: group.label })), _jsx("ul", { class: "space-y-0.5", children: group.items.map((item) => {
|
|
32
36
|
const isActive = item.id === activePageSlug;
|
|
33
37
|
return (_jsx("li", { children: _jsxs("a", { href: `${base}${item.href}`, class: `nav-link${isActive ? " active" : ""}`, children: [item.method && _jsx(MethodPill, { method: item.method }), _jsx("span", { class: "flex-1 break-words [word-break:break-word]", children: item.label })] }) }, item.id));
|
|
34
38
|
}) })] }, group.label))) }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableOfContents.d.ts","sourceRoot":"","sources":["../../../src/components/layout/TableOfContents.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"TableOfContents.d.ts","sourceRoot":"","sources":["../../../src/components/layout/TableOfContents.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAyCjE,wBAAgB,eAAe,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,WAAW,EAAE,CAAA;CAAE,uCAuBxE"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
|
+
import { iconPath } from "../../utils/icons.js";
|
|
2
3
|
/**
|
|
3
4
|
* Right-sidebar table of contents for prose pages.
|
|
4
5
|
* TOC layout: w-[19rem] outer, w-[16.5rem] inner,
|
|
@@ -21,5 +22,5 @@ function TocList({ headings }) {
|
|
|
21
22
|
export function TableOfContents({ headings }) {
|
|
22
23
|
if (headings.length === 0)
|
|
23
24
|
return null;
|
|
24
|
-
return (_jsx("aside", { id: "toc", class: "hidden xl:flex self-start sticky xl:flex-col max-w-[28rem] z-[21]", style: "height: calc(100vh - var(--header-height) - 2.5rem); top: calc(var(--header-height) + 2.5rem)", children: _jsx("div", { class: "z-10 hidden xl:flex box-border max-h-full pl-10 w-[19rem]", children: _jsxs("div", { class: "text-[rgb(var(--color-gray-600))] text-sm leading-6 w-[16.5rem] overflow-y-auto space-y-2 pb-4 -mt-10 pt-10", children: [
|
|
25
|
+
return (_jsx("aside", { id: "toc", class: "hidden xl:flex self-start sticky xl:flex-col max-w-[28rem] z-[21]", style: "height: calc(100vh - var(--header-height) - 2.5rem); top: calc(var(--header-height) + 2.5rem)", children: _jsx("div", { class: "z-10 hidden xl:flex box-border max-h-full pl-10 w-[19rem]", children: _jsxs("div", { class: "text-[rgb(var(--color-gray-600))] text-sm leading-6 w-[16.5rem] overflow-y-auto space-y-2 pb-4 -mt-10 pt-10", children: [_jsxs("h5", { class: "font-semibold text-[rgb(var(--color-gray-900))] dark:text-[rgb(var(--color-gray-200))] flex items-center gap-1.5", children: [_jsx("svg", { class: "shrink-0", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "1.5", dangerouslySetInnerHTML: { __html: iconPath("book") ?? "" } }), "On this page"] }), _jsx("nav", { children: _jsx(TocList, { headings: headings }) })] }) }) }));
|
|
25
26
|
}
|
package/dist/config.d.ts
CHANGED
|
@@ -52,6 +52,11 @@ export interface SourceyConfig {
|
|
|
52
52
|
footer?: {
|
|
53
53
|
links?: NavbarLink[];
|
|
54
54
|
};
|
|
55
|
+
/** Search configuration. */
|
|
56
|
+
search?: {
|
|
57
|
+
/** Page slugs to feature at the top of search results when no query is entered. */
|
|
58
|
+
featured?: string[];
|
|
59
|
+
};
|
|
55
60
|
}
|
|
56
61
|
export type DoxygenIndexStyle = "auto" | "rich" | "structured" | "flat" | "none";
|
|
57
62
|
export interface DoxygenConfig {
|
|
@@ -135,6 +140,9 @@ export interface ResolvedConfig {
|
|
|
135
140
|
footer: {
|
|
136
141
|
links: NavbarLink[];
|
|
137
142
|
};
|
|
143
|
+
search: {
|
|
144
|
+
featured: string[];
|
|
145
|
+
};
|
|
138
146
|
}
|
|
139
147
|
export interface ResolvedDoxygenConfig {
|
|
140
148
|
xml: string;
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,CAAC;AAE9D,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,MAAM,CAAC,EAAE;QACP,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;IACF,KAAK,CAAC,EAAE;QACN,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;IACF,MAAM,CAAC,EAAE;QACP,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,GAAG;QACd,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;IACF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6DAA6D;IAC7D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,sHAAsH;IACtH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iJAAiJ;IACjJ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,UAAU,EAAE;QACV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AAM,GAAG,MAAM,CAE7D;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAO5C"}
|
package/dist/config.js
CHANGED
|
@@ -59,6 +59,7 @@ export function configFromSpec(specPath) {
|
|
|
59
59
|
tabs: [{ label: "API Reference", slug: "api", openapi: absSpec }],
|
|
60
60
|
navbar: { links: [] },
|
|
61
61
|
footer: { links: [] },
|
|
62
|
+
search: { featured: [] },
|
|
62
63
|
};
|
|
63
64
|
}
|
|
64
65
|
// ---------------------------------------------------------------------------
|
|
@@ -85,6 +86,9 @@ export async function resolveConfigFromRaw(raw, configDir) {
|
|
|
85
86
|
footer: {
|
|
86
87
|
links: raw.footer?.links ?? [],
|
|
87
88
|
},
|
|
89
|
+
search: {
|
|
90
|
+
featured: raw.search?.featured ?? [],
|
|
91
|
+
},
|
|
88
92
|
};
|
|
89
93
|
}
|
|
90
94
|
const VALID_PRESETS = ["default", "minimal", "api-first"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-loader.d.ts","sourceRoot":"","sources":["../../src/core/markdown-loader.ts"],"names":[],"mappings":"AAKA,OAAO,EAAmC,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAMzF,MAAM,WAAW,YAAY;IAC3B,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,WAAW,EAAE,MAAM,CAAC;IACpB,qDAAqD;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,yBAAyB;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,qDAAqD;IACrD,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,sEAAsE;IACtE,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"markdown-loader.d.ts","sourceRoot":"","sources":["../../src/core/markdown-loader.ts"],"names":[],"mappings":"AAKA,OAAO,EAAmC,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAMzF,MAAM,WAAW,YAAY;IAC3B,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,WAAW,EAAE,MAAM,CAAC;IACpB,qDAAqD;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,yBAAyB;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,qDAAqD;IACrD,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,sEAAsE;IACtE,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AA4TxD;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,YAAY,CAAC,CAmBvB;AAUD;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAIrD"}
|
|
@@ -220,8 +220,13 @@ ${content.trim()}
|
|
|
220
220
|
</div>
|
|
221
221
|
</details>\n\n`;
|
|
222
222
|
});
|
|
223
|
-
// Auto-wrap consecutive accordion items in an accordion-group
|
|
224
|
-
html = html.replace(/(<details class="accordion-item">[\s\S]*?<\/details>\s*){2,}/g, (match) =>
|
|
223
|
+
// Auto-wrap consecutive accordion items in an accordion-group (skip already-wrapped)
|
|
224
|
+
html = html.replace(/(<details class="accordion-item">[\s\S]*?<\/details>\s*){2,}/g, (match, _p1, offset) => {
|
|
225
|
+
const before = html.slice(Math.max(0, offset - 40), offset);
|
|
226
|
+
if (before.includes("accordion-group"))
|
|
227
|
+
return match;
|
|
228
|
+
return `<div class="accordion-group not-prose">\n${match.trim()}\n</div>`;
|
|
229
|
+
});
|
|
225
230
|
return html;
|
|
226
231
|
}
|
|
227
232
|
// ---------------------------------------------------------------------------
|
|
@@ -16,10 +16,12 @@ export interface SearchEntry {
|
|
|
16
16
|
tab: string;
|
|
17
17
|
/** Category for grouping results */
|
|
18
18
|
category: string;
|
|
19
|
+
/** Featured in default search results */
|
|
20
|
+
featured?: boolean;
|
|
19
21
|
}
|
|
20
22
|
/**
|
|
21
23
|
* Build a search index from specs and markdown pages.
|
|
22
24
|
* Returns a JSON string ready to write to disk.
|
|
23
25
|
*/
|
|
24
|
-
export declare function buildSearchIndex(specs: Map<string, NormalizedSpec>, pages: Map<string, MarkdownPage[]>, navigation: SiteNavigation, assetBase?: string): string;
|
|
26
|
+
export declare function buildSearchIndex(specs: Map<string, NormalizedSpec>, pages: Map<string, MarkdownPage[]>, navigation: SiteNavigation, assetBase?: string, featuredSlugs?: string[]): string;
|
|
25
27
|
//# sourceMappingURL=search-indexer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-indexer.d.ts","sourceRoot":"","sources":["../../src/core/search-indexer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAOtD,MAAM,WAAW,WAAW;IAC1B,oBAAoB;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAC;IAChB,mDAAmD;IACnD,GAAG,EAAE,MAAM,CAAC;IACZ,qCAAqC;IACrC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8BAA8B;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gCAAgC;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,oCAAoC;IACpC,QAAQ,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"search-indexer.d.ts","sourceRoot":"","sources":["../../src/core/search-indexer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAOtD,MAAM,WAAW,WAAW;IAC1B,oBAAoB;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAC;IAChB,mDAAmD;IACnD,GAAG,EAAE,MAAM,CAAC;IACZ,qCAAqC;IACrC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8BAA8B;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gCAAgC;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,oCAAoC;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,yCAAyC;IACzC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAMD;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,EAClC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,EAAE,CAAC,EAClC,UAAU,EAAE,cAAc,EAC1B,SAAS,SAAM,EACf,aAAa,GAAE,MAAM,EAAO,GAC3B,MAAM,CAoER"}
|
|
@@ -6,8 +6,9 @@ import { htmlId } from "../utils/html-id.js";
|
|
|
6
6
|
* Build a search index from specs and markdown pages.
|
|
7
7
|
* Returns a JSON string ready to write to disk.
|
|
8
8
|
*/
|
|
9
|
-
export function buildSearchIndex(specs, pages, navigation, assetBase = "/") {
|
|
9
|
+
export function buildSearchIndex(specs, pages, navigation, assetBase = "/", featuredSlugs = []) {
|
|
10
10
|
const base = assetBase.endsWith("/") ? assetBase : assetBase + "/";
|
|
11
|
+
const featuredSet = new Set(featuredSlugs);
|
|
11
12
|
const entries = [];
|
|
12
13
|
// Index OpenAPI specs
|
|
13
14
|
for (const [tabSlug, spec] of specs) {
|
|
@@ -43,19 +44,22 @@ export function buildSearchIndex(specs, pages, navigation, assetBase = "/") {
|
|
|
43
44
|
const tabLabel = tab?.label ?? tabSlug;
|
|
44
45
|
for (const page of tabPages) {
|
|
45
46
|
// Page itself
|
|
47
|
+
const pageBase = tabSlug ? `${base}${tabSlug}/` : base;
|
|
48
|
+
const isFeatured = featuredSet.has(page.slug);
|
|
46
49
|
entries.push({
|
|
47
50
|
title: page.title,
|
|
48
51
|
content: page.description || stripHtml(page.html).slice(0, 200),
|
|
49
|
-
url: `${
|
|
52
|
+
url: `${pageBase}${page.slug}.html`,
|
|
50
53
|
tab: tabLabel,
|
|
51
54
|
category: "Pages",
|
|
55
|
+
...(isFeatured && { featured: true }),
|
|
52
56
|
});
|
|
53
57
|
// Headings within page
|
|
54
58
|
for (const heading of page.headings) {
|
|
55
59
|
entries.push({
|
|
56
60
|
title: heading.text,
|
|
57
61
|
content: `${page.title} — ${heading.text}`,
|
|
58
|
-
url: `${
|
|
62
|
+
url: `${pageBase}${page.slug}.html#${heading.id}`,
|
|
59
63
|
tab: tabLabel,
|
|
60
64
|
category: "Sections",
|
|
61
65
|
});
|
package/dist/dev-server.js
CHANGED
|
@@ -286,7 +286,7 @@ export async function startDevServer(options) {
|
|
|
286
286
|
markdownPagesByTab.set(tab.slug, tabPages);
|
|
287
287
|
}
|
|
288
288
|
}
|
|
289
|
-
return buildSearchIndex(specsBySlug, markdownPagesByTab, navigation);
|
|
289
|
+
return buildSearchIndex(specsBySlug, markdownPagesByTab, navigation, "/", config.search.featured);
|
|
290
290
|
}
|
|
291
291
|
const viteConfig = {
|
|
292
292
|
root: process.cwd(),
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,KAAK,EAAE,cAAc,EAAe,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO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12
|
import { loadDoxygenTab } from "./core/doxygen-loader.js";
|
|
13
13
|
import { buildNavFromSpec, buildNavFromPages, buildSiteNavigation } from "./core/navigation.js";
|
|
14
14
|
import { buildSearchIndex } from "./core/search-indexer.js";
|
|
15
|
+
import { generateLlmsTxt, generateLlmsFullTxt } from "./renderer/llms.js";
|
|
15
16
|
/**
|
|
16
17
|
* Build API documentation from a single OpenAPI/Swagger spec.
|
|
17
18
|
* Wraps the spec in a single-tab site and renders through the modern layout.
|
|
@@ -117,10 +118,14 @@ export async function buildSiteDocs(options = {}) {
|
|
|
117
118
|
markdownPagesByTab.set(tab.slug, tabPages);
|
|
118
119
|
}
|
|
119
120
|
}
|
|
120
|
-
const searchIndex = buildSearchIndex(specsBySlug, markdownPagesByTab, navigation);
|
|
121
|
+
const searchIndex = buildSearchIndex(specsBySlug, markdownPagesByTab, navigation, "/", config.search.featured);
|
|
122
|
+
const llmsTxt = generateLlmsTxt(sitePages, navigation, site);
|
|
123
|
+
const llmsFullTxt = generateLlmsFullTxt(sitePages, navigation, site);
|
|
121
124
|
if (!options.skipWrite) {
|
|
122
125
|
await buildSiteHtml(sitePages, navigation, outputDir, site, {
|
|
123
126
|
searchIndex,
|
|
127
|
+
llmsTxt,
|
|
128
|
+
llmsFullTxt,
|
|
124
129
|
embeddable: options.embeddable,
|
|
125
130
|
});
|
|
126
131
|
}
|
|
@@ -18,5 +18,7 @@ export interface SitePage {
|
|
|
18
18
|
export declare function buildSite(pages: SitePage[], navigation: SiteNavigation, outputDir: string, site: SiteConfig, options?: {
|
|
19
19
|
embeddable?: boolean;
|
|
20
20
|
searchIndex?: string;
|
|
21
|
+
llmsTxt?: string;
|
|
22
|
+
llmsFullTxt?: string;
|
|
21
23
|
}): Promise<BuildOutput>;
|
|
22
24
|
//# sourceMappingURL=html-builder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-builder.d.ts","sourceRoot":"","sources":["../../src/renderer/html-builder.ts"],"names":[],"mapp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M,CAAC;CAClB;AAED;;GAEG;AACH,wBAAsB,SAAS,CAC7B,KAAK,EAAE,QAAQ,EAAE,EACjB,UAAU,EAAE,cAAc,EAC1B,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,UAAU,EAChB,OAAO,CAAC,EAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,GAC/F,OAAO,CAAC,WAAW,CAAC,CAsDtB"}
|
|
@@ -60,6 +60,12 @@ export async function buildSite(pages, navigation, outputDir, site, options) {
|
|
|
60
60
|
if (options?.searchIndex) {
|
|
61
61
|
await writeFile(resolve(resolvedDir, "search-index.json"), options.searchIndex, "utf-8");
|
|
62
62
|
}
|
|
63
|
+
if (options?.llmsTxt) {
|
|
64
|
+
await writeFile(resolve(resolvedDir, "llms.txt"), options.llmsTxt, "utf-8");
|
|
65
|
+
}
|
|
66
|
+
if (options?.llmsFullTxt) {
|
|
67
|
+
await writeFile(resolve(resolvedDir, "llms-full.txt"), options.llmsFullTxt, "utf-8");
|
|
68
|
+
}
|
|
63
69
|
const urls = pages.map(p => ` <url><loc>${p.outputPath}</loc></url>`);
|
|
64
70
|
const sitemap = [
|
|
65
71
|
`<?xml version="1.0" encoding="UTF-8"?>`,
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SiteNavigation } from "../core/navigation.js";
|
|
2
|
+
import type { SiteConfig } from "./context.js";
|
|
3
|
+
import type { SitePage } from "./html-builder.js";
|
|
4
|
+
export declare function generateLlmsTxt(pages: SitePage[], navigation: SiteNavigation, site: SiteConfig): string;
|
|
5
|
+
export declare function generateLlmsFullTxt(pages: SitePage[], navigation: SiteNavigation, site: SiteConfig): string;
|
|
6
|
+
//# sourceMappingURL=llms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llms.d.ts","sourceRoot":"","sources":["../../src/renderer/llms.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAG5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,wBAAgB,eAAe,CAC7B,KAAK,EAAE,QAAQ,EAAE,EACjB,UAAU,EAAE,cAAc,EAC1B,IAAI,EAAE,UAAU,GACf,MAAM,CA4CR;AAED,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,QAAQ,EAAE,EACjB,UAAU,EAAE,cAAc,EAC1B,IAAI,EAAE,UAAU,GACf,MAAM,CA8BR"}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { htmlId } from "../utils/html-id.js";
|
|
2
|
+
export function generateLlmsTxt(pages, navigation, site) {
|
|
3
|
+
const lines = [];
|
|
4
|
+
const title = resolveSiteTitle(pages, site);
|
|
5
|
+
const summary = resolveSiteSummary(pages, site);
|
|
6
|
+
lines.push(`# ${title}`);
|
|
7
|
+
lines.push("");
|
|
8
|
+
if (summary) {
|
|
9
|
+
lines.push(`> ${firstLine(summary)}`);
|
|
10
|
+
lines.push("");
|
|
11
|
+
}
|
|
12
|
+
for (const tab of navigation.tabs) {
|
|
13
|
+
const tabPages = pages.filter((page) => page.tabSlug === tab.slug);
|
|
14
|
+
if (!tabPages.length)
|
|
15
|
+
continue;
|
|
16
|
+
lines.push(`## ${tab.label}`);
|
|
17
|
+
lines.push("");
|
|
18
|
+
for (const page of tabPages) {
|
|
19
|
+
if (page.currentPage.kind === "markdown" && page.currentPage.markdown) {
|
|
20
|
+
const doc = page.currentPage.markdown;
|
|
21
|
+
const desc = doc.description || excerpt(stripHtml(doc.html));
|
|
22
|
+
lines.push(`- [${doc.title}](${page.outputPath})${desc ? `: ${desc}` : ""}`);
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
const spec = page.currentPage.spec ?? page.spec;
|
|
26
|
+
const overview = spec.info.description ? firstLine(spec.info.description) : `${spec.operations.length} documented operations`;
|
|
27
|
+
lines.push(`- [${spec.info.title}](${page.outputPath})${overview ? `: ${overview}` : ""}`);
|
|
28
|
+
for (const op of spec.operations) {
|
|
29
|
+
if (op.hidden)
|
|
30
|
+
continue;
|
|
31
|
+
const opLabel = op.summary ?? operationDisplayName(op);
|
|
32
|
+
const opSummary = [operationKind(op), firstLine(op.description)].filter(Boolean).join(" — ");
|
|
33
|
+
lines.push(`- [${opLabel}](${page.outputPath}#${operationAnchor(op)})${opSummary ? `: ${opSummary}` : ""}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
lines.push("");
|
|
37
|
+
}
|
|
38
|
+
return lines.join("\n");
|
|
39
|
+
}
|
|
40
|
+
export function generateLlmsFullTxt(pages, navigation, site) {
|
|
41
|
+
const lines = [];
|
|
42
|
+
const title = resolveSiteTitle(pages, site);
|
|
43
|
+
const summary = resolveSiteSummary(pages, site);
|
|
44
|
+
lines.push(`# ${title}`);
|
|
45
|
+
lines.push("");
|
|
46
|
+
if (summary) {
|
|
47
|
+
lines.push(summary);
|
|
48
|
+
lines.push("");
|
|
49
|
+
}
|
|
50
|
+
for (const tab of navigation.tabs) {
|
|
51
|
+
const tabPages = pages.filter((page) => page.tabSlug === tab.slug);
|
|
52
|
+
if (!tabPages.length)
|
|
53
|
+
continue;
|
|
54
|
+
lines.push(`## ${tab.label}`);
|
|
55
|
+
lines.push("");
|
|
56
|
+
for (const page of tabPages) {
|
|
57
|
+
if (page.currentPage.kind === "markdown" && page.currentPage.markdown) {
|
|
58
|
+
appendMarkdownPage(lines, page);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
appendSpecPage(lines, page);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return lines.join("\n");
|
|
66
|
+
}
|
|
67
|
+
function appendMarkdownPage(lines, page) {
|
|
68
|
+
const doc = page.currentPage.markdown;
|
|
69
|
+
lines.push(`### ${doc.title}`);
|
|
70
|
+
lines.push("");
|
|
71
|
+
lines.push(`Path: \`${page.outputPath}\``);
|
|
72
|
+
lines.push("");
|
|
73
|
+
if (doc.description) {
|
|
74
|
+
lines.push(doc.description);
|
|
75
|
+
lines.push("");
|
|
76
|
+
}
|
|
77
|
+
const body = stripHtml(doc.html);
|
|
78
|
+
if (body) {
|
|
79
|
+
lines.push(body);
|
|
80
|
+
lines.push("");
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function appendSpecPage(lines, page) {
|
|
84
|
+
const spec = page.currentPage.spec ?? page.spec;
|
|
85
|
+
lines.push(`### ${spec.info.title}`);
|
|
86
|
+
lines.push("");
|
|
87
|
+
lines.push(`Path: \`${page.outputPath}\``);
|
|
88
|
+
if (spec.info.version) {
|
|
89
|
+
lines.push(`Version: ${spec.info.version}`);
|
|
90
|
+
}
|
|
91
|
+
lines.push("");
|
|
92
|
+
if (spec.info.description) {
|
|
93
|
+
lines.push(spec.info.description);
|
|
94
|
+
lines.push("");
|
|
95
|
+
}
|
|
96
|
+
if (spec.operations.length) {
|
|
97
|
+
lines.push("#### Operations");
|
|
98
|
+
lines.push("");
|
|
99
|
+
for (const op of spec.operations) {
|
|
100
|
+
if (op.hidden)
|
|
101
|
+
continue;
|
|
102
|
+
appendOperation(lines, op);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const schemas = Object.entries(spec.schemas);
|
|
106
|
+
if (schemas.length) {
|
|
107
|
+
lines.push("#### Models");
|
|
108
|
+
lines.push("");
|
|
109
|
+
for (const [name, schema] of schemas) {
|
|
110
|
+
const desc = schema.description ? `: ${schema.description}` : "";
|
|
111
|
+
lines.push(`- ${name}${desc}`);
|
|
112
|
+
}
|
|
113
|
+
lines.push("");
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function appendOperation(lines, op) {
|
|
117
|
+
lines.push(`##### ${operationDisplayName(op)}`);
|
|
118
|
+
lines.push("");
|
|
119
|
+
if (op.summary && op.summary !== operationDisplayName(op)) {
|
|
120
|
+
lines.push(`Summary: ${op.summary}`);
|
|
121
|
+
lines.push("");
|
|
122
|
+
}
|
|
123
|
+
if (op.description) {
|
|
124
|
+
lines.push(op.description);
|
|
125
|
+
lines.push("");
|
|
126
|
+
}
|
|
127
|
+
if (op.parameters.length) {
|
|
128
|
+
lines.push("Parameters:");
|
|
129
|
+
for (const param of op.parameters) {
|
|
130
|
+
const req = param.required ? "required" : "optional";
|
|
131
|
+
const type = param.schema ? formatSchemaType(param.schema) : "unknown";
|
|
132
|
+
const desc = param.description ? ` — ${firstLine(param.description)}` : "";
|
|
133
|
+
lines.push(`- \`${param.name}\` (${param.in}, ${type}, ${req})${desc}`);
|
|
134
|
+
}
|
|
135
|
+
lines.push("");
|
|
136
|
+
}
|
|
137
|
+
if (op.requestBody) {
|
|
138
|
+
const mediaTypes = Object.keys(op.requestBody.content);
|
|
139
|
+
if (mediaTypes.length) {
|
|
140
|
+
lines.push(`Request body: ${mediaTypes.join(", ")}`);
|
|
141
|
+
lines.push("");
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (op.mcpExtras?.outputSchema) {
|
|
145
|
+
lines.push("Returns:");
|
|
146
|
+
lines.push("```json");
|
|
147
|
+
lines.push(JSON.stringify(op.mcpExtras.outputSchema, null, 2));
|
|
148
|
+
lines.push("```");
|
|
149
|
+
lines.push("");
|
|
150
|
+
}
|
|
151
|
+
else if (op.responses.length) {
|
|
152
|
+
lines.push("Responses:");
|
|
153
|
+
for (const response of op.responses) {
|
|
154
|
+
lines.push(`- ${formatResponse(response)}`);
|
|
155
|
+
}
|
|
156
|
+
lines.push("");
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function resolveSiteTitle(pages, site) {
|
|
160
|
+
if (site.name && site.name !== "API Reference")
|
|
161
|
+
return site.name;
|
|
162
|
+
const specPages = pages.filter((page) => page.currentPage.kind === "spec");
|
|
163
|
+
if (specPages.length === 1) {
|
|
164
|
+
const spec = specPages[0].currentPage.spec ?? specPages[0].spec;
|
|
165
|
+
if (spec.info.title)
|
|
166
|
+
return spec.info.title;
|
|
167
|
+
}
|
|
168
|
+
const firstMarkdown = pages.find((page) => page.currentPage.kind === "markdown" && page.currentPage.markdown);
|
|
169
|
+
if (firstMarkdown?.currentPage.markdown?.title)
|
|
170
|
+
return firstMarkdown.currentPage.markdown.title;
|
|
171
|
+
return site.name || "Documentation";
|
|
172
|
+
}
|
|
173
|
+
function resolveSiteSummary(pages, site) {
|
|
174
|
+
const firstMarkdown = pages.find((page) => page.currentPage.kind === "markdown" && page.currentPage.markdown?.description);
|
|
175
|
+
if (firstMarkdown?.currentPage.markdown?.description)
|
|
176
|
+
return firstMarkdown.currentPage.markdown.description;
|
|
177
|
+
const firstSpec = pages.find((page) => page.currentPage.kind === "spec");
|
|
178
|
+
const spec = firstSpec ? (firstSpec.currentPage.spec ?? firstSpec.spec) : undefined;
|
|
179
|
+
if (spec?.info.description)
|
|
180
|
+
return spec.info.description;
|
|
181
|
+
return site.name ? `${site.name} documentation generated by Sourcey.` : undefined;
|
|
182
|
+
}
|
|
183
|
+
function operationDisplayName(op) {
|
|
184
|
+
if (op.mcpExtras?.type === "tool")
|
|
185
|
+
return `TOOL ${op.path}`;
|
|
186
|
+
if (op.mcpExtras?.type === "resource")
|
|
187
|
+
return `RESOURCE ${op.path}`;
|
|
188
|
+
if (op.mcpExtras?.type === "prompt")
|
|
189
|
+
return `PROMPT ${op.path}`;
|
|
190
|
+
return `${op.method.toUpperCase()} ${op.path}`;
|
|
191
|
+
}
|
|
192
|
+
function operationKind(op) {
|
|
193
|
+
if (op.mcpExtras?.type === "tool")
|
|
194
|
+
return "tool";
|
|
195
|
+
if (op.mcpExtras?.type === "resource")
|
|
196
|
+
return "resource";
|
|
197
|
+
if (op.mcpExtras?.type === "prompt")
|
|
198
|
+
return "prompt";
|
|
199
|
+
return `${op.method.toUpperCase()} ${op.path}`;
|
|
200
|
+
}
|
|
201
|
+
function operationAnchor(op) {
|
|
202
|
+
return `operation-${htmlId(op.path)}-${htmlId(op.method)}`;
|
|
203
|
+
}
|
|
204
|
+
function formatResponse(response) {
|
|
205
|
+
const desc = response.description ? firstLine(response.description) : "";
|
|
206
|
+
return desc ? `${response.statusCode}: ${desc}` : response.statusCode;
|
|
207
|
+
}
|
|
208
|
+
function formatSchemaType(schema) {
|
|
209
|
+
if (Array.isArray(schema.type))
|
|
210
|
+
return schema.type.join(" | ");
|
|
211
|
+
if (schema.type)
|
|
212
|
+
return schema.type;
|
|
213
|
+
if (schema.oneOf?.length)
|
|
214
|
+
return schema.oneOf.map(formatSchemaType).join(" | ");
|
|
215
|
+
if (schema.anyOf?.length)
|
|
216
|
+
return schema.anyOf.map(formatSchemaType).join(" | ");
|
|
217
|
+
if (schema.allOf?.length)
|
|
218
|
+
return "object";
|
|
219
|
+
if (schema.properties)
|
|
220
|
+
return "object";
|
|
221
|
+
return "unknown";
|
|
222
|
+
}
|
|
223
|
+
function stripHtml(html) {
|
|
224
|
+
return decodeEntities(html)
|
|
225
|
+
.replace(/<pre[\s\S]*?<\/pre>/gi, (match) => match.replace(/<[^>]+>/g, " "))
|
|
226
|
+
.replace(/<code[\s\S]*?<\/code>/gi, (match) => match.replace(/<[^>]+>/g, " "))
|
|
227
|
+
.replace(/<[^>]+>/g, " ")
|
|
228
|
+
.replace(/\s+/g, " ")
|
|
229
|
+
.trim();
|
|
230
|
+
}
|
|
231
|
+
function decodeEntities(text) {
|
|
232
|
+
return text
|
|
233
|
+
.replace(/ /g, " ")
|
|
234
|
+
.replace(/&/g, "&")
|
|
235
|
+
.replace(/</g, "<")
|
|
236
|
+
.replace(/>/g, ">")
|
|
237
|
+
.replace(/"/g, "\"")
|
|
238
|
+
.replace(/'/g, "'");
|
|
239
|
+
}
|
|
240
|
+
function excerpt(text, max = 140) {
|
|
241
|
+
if (text.length <= max)
|
|
242
|
+
return text;
|
|
243
|
+
return `${text.slice(0, max - 1).trimEnd()}…`;
|
|
244
|
+
}
|
|
245
|
+
function firstLine(text) {
|
|
246
|
+
return text?.split("\n").map((line) => line.trim()).find(Boolean) ?? "";
|
|
247
|
+
}
|
|
@@ -65,6 +65,9 @@
|
|
|
65
65
|
--method-put: #d97706;
|
|
66
66
|
--method-delete: #dc2626;
|
|
67
67
|
--method-patch: #9333ea;
|
|
68
|
+
--method-tool: #9333ea;
|
|
69
|
+
--method-resource: #16a34a;
|
|
70
|
+
--method-prompt: #2563eb;
|
|
68
71
|
|
|
69
72
|
/* Typography */
|
|
70
73
|
--font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
|
|
@@ -7,6 +7,38 @@
|
|
|
7
7
|
* utilities in generated HTML.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
/* ── Page Description (display font) ─────────────────────────────── */
|
|
11
|
+
|
|
12
|
+
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital@0;1&display=swap');
|
|
13
|
+
|
|
14
|
+
#sourcey .page-description {
|
|
15
|
+
font-family: 'Playfair Display', Georgia, serif;
|
|
16
|
+
font-size: 1.375rem;
|
|
17
|
+
line-height: 1.4;
|
|
18
|
+
font-style: italic;
|
|
19
|
+
color: rgb(var(--color-gray-600));
|
|
20
|
+
}
|
|
21
|
+
.dark #sourcey .page-description {
|
|
22
|
+
color: rgb(var(--color-gray-400));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/* ── Page Top Gradient ────────────────────────────────────────────── */
|
|
26
|
+
|
|
27
|
+
#sourcey #page::before {
|
|
28
|
+
content: "";
|
|
29
|
+
position: fixed;
|
|
30
|
+
top: 0;
|
|
31
|
+
left: 0;
|
|
32
|
+
right: 0;
|
|
33
|
+
height: 400px;
|
|
34
|
+
background: linear-gradient(to bottom, rgb(var(--color-primary) / 0.03), transparent);
|
|
35
|
+
pointer-events: none;
|
|
36
|
+
z-index: -1;
|
|
37
|
+
}
|
|
38
|
+
.dark #sourcey #page::before {
|
|
39
|
+
background: none;
|
|
40
|
+
}
|
|
41
|
+
|
|
10
42
|
/* ── Scroll Offset (clears fixed navbar on anchor clicks) ──────────── */
|
|
11
43
|
|
|
12
44
|
[data-traverse-target],
|
|
@@ -74,6 +106,24 @@ h1[id], h2[id], h3[id], h4[id], h5[id], h6[id] {
|
|
|
74
106
|
height: 100%;
|
|
75
107
|
}
|
|
76
108
|
|
|
109
|
+
/* ── Prose Iframe (::iframe directive) ────────────────────────────── */
|
|
110
|
+
|
|
111
|
+
#sourcey .prose-iframe {
|
|
112
|
+
width: 100%;
|
|
113
|
+
margin: 1.5rem 0;
|
|
114
|
+
border-radius: var(--radius);
|
|
115
|
+
overflow: hidden;
|
|
116
|
+
border: 1px solid rgb(var(--color-stone-950) / 0.1);
|
|
117
|
+
}
|
|
118
|
+
.dark #sourcey .prose-iframe {
|
|
119
|
+
border-color: rgb(255 255 255 / 0.1);
|
|
120
|
+
}
|
|
121
|
+
#sourcey .prose-iframe iframe {
|
|
122
|
+
width: 100%;
|
|
123
|
+
height: 100%;
|
|
124
|
+
display: block;
|
|
125
|
+
}
|
|
126
|
+
|
|
77
127
|
/* ── Prose Code Block (fenced code in markdown pages) ─────────────── */
|
|
78
128
|
|
|
79
129
|
#sourcey .prose-code-block {
|
|
@@ -509,7 +559,7 @@ h1[id], h2[id], h3[id], h4[id], h5[id], h6[id] {
|
|
|
509
559
|
|
|
510
560
|
#sourcey .steps {
|
|
511
561
|
margin-left: 0.875rem;
|
|
512
|
-
margin-top:
|
|
562
|
+
margin-top: 1rem;
|
|
513
563
|
margin-bottom: 1.5rem;
|
|
514
564
|
}
|
|
515
565
|
|
|
@@ -1108,30 +1158,25 @@ h1[id], h2[id], h3[id], h4[id], h5[id], h6[id] {
|
|
|
1108
1158
|
position: fixed;
|
|
1109
1159
|
inset: 0;
|
|
1110
1160
|
z-index: 500;
|
|
1111
|
-
background:
|
|
1112
|
-
backdrop-filter: blur(4px);
|
|
1113
|
-
-webkit-backdrop-filter: blur(4px);
|
|
1114
|
-
align-items: flex-start;
|
|
1115
|
-
justify-content: center;
|
|
1116
|
-
padding-top: 15vh;
|
|
1161
|
+
background: transparent;
|
|
1117
1162
|
}
|
|
1118
1163
|
|
|
1119
1164
|
#sourcey #search-dialog.open {
|
|
1120
|
-
display:
|
|
1165
|
+
display: block;
|
|
1121
1166
|
}
|
|
1122
1167
|
|
|
1123
1168
|
#sourcey .search-dialog-inner {
|
|
1124
|
-
|
|
1125
|
-
max-width: 540px;
|
|
1169
|
+
position: absolute;
|
|
1126
1170
|
background: rgb(var(--color-background-light));
|
|
1127
1171
|
border-radius: var(--radius);
|
|
1128
|
-
|
|
1172
|
+
border: 1px solid rgb(var(--color-gray-200) / 0.7);
|
|
1173
|
+
box-shadow: 0 8px 32px rgb(var(--color-overlay) / 0.12);
|
|
1129
1174
|
overflow: hidden;
|
|
1130
|
-
margin: 0 1rem;
|
|
1131
1175
|
}
|
|
1132
1176
|
.dark #sourcey .search-dialog-inner {
|
|
1133
1177
|
background: rgb(var(--color-gray-900));
|
|
1134
|
-
|
|
1178
|
+
border-color: rgb(var(--color-gray-700) / 0.5);
|
|
1179
|
+
box-shadow: 0 8px 32px rgb(var(--color-overlay) / 0.4);
|
|
1135
1180
|
}
|
|
1136
1181
|
|
|
1137
1182
|
#sourcey .search-input-row {
|
|
@@ -1201,7 +1246,8 @@ h1[id], h2[id], h3[id], h4[id], h5[id], h6[id] {
|
|
|
1201
1246
|
gap: 0.25rem;
|
|
1202
1247
|
}
|
|
1203
1248
|
|
|
1204
|
-
#sourcey .search-footer kbd
|
|
1249
|
+
#sourcey .search-footer kbd,
|
|
1250
|
+
#sourcey #search-open kbd {
|
|
1205
1251
|
display: inline-flex;
|
|
1206
1252
|
align-items: center;
|
|
1207
1253
|
justify-content: center;
|
|
@@ -1216,7 +1262,8 @@ h1[id], h2[id], h3[id], h4[id], h5[id], h6[id] {
|
|
|
1216
1262
|
background: rgb(var(--color-gray-50));
|
|
1217
1263
|
color: rgb(var(--color-gray-500));
|
|
1218
1264
|
}
|
|
1219
|
-
.dark #sourcey .search-footer kbd
|
|
1265
|
+
.dark #sourcey .search-footer kbd,
|
|
1266
|
+
.dark #sourcey #search-open kbd {
|
|
1220
1267
|
border-color: rgb(var(--color-gray-700));
|
|
1221
1268
|
background: rgb(var(--color-gray-800));
|
|
1222
1269
|
color: rgb(var(--color-gray-400));
|
|
@@ -1277,6 +1324,9 @@ h1[id], h2[id], h3[id], h4[id], h5[id], h6[id] {
|
|
|
1277
1324
|
#sourcey .search-result-method.method-put { background: var(--method-put); }
|
|
1278
1325
|
#sourcey .search-result-method.method-delete { background: var(--method-delete); }
|
|
1279
1326
|
#sourcey .search-result-method.method-patch { background: var(--method-patch); }
|
|
1327
|
+
#sourcey .search-result-method.method-tool { background: var(--method-tool); }
|
|
1328
|
+
#sourcey .search-result-method.method-resource { background: var(--method-resource); }
|
|
1329
|
+
#sourcey .search-result-method.method-prompt { background: var(--method-prompt); }
|
|
1280
1330
|
|
|
1281
1331
|
#sourcey .search-result-path {
|
|
1282
1332
|
font-family: var(--font-mono);
|
package/dist/utils/icons.d.ts
CHANGED
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
* Each value is the inner path content (no wrapping <svg>).
|
|
7
7
|
* Render with: `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">${path}</svg>`
|
|
8
8
|
*/
|
|
9
|
+
/**
|
|
10
|
+
* Return raw inner SVG content for a named icon, or undefined.
|
|
11
|
+
*/
|
|
12
|
+
export declare function iconPath(name: string): string | undefined;
|
|
9
13
|
/**
|
|
10
14
|
* Render a Heroicon as an inline SVG string.
|
|
11
15
|
* Returns empty string if the icon name is not found.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icons.d.ts","sourceRoot":"","sources":["../../src/utils/icons.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAgFH;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAI/C"}
|
|
1
|
+
{"version":3,"file":"icons.d.ts","sourceRoot":"","sources":["../../src/utils/icons.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAgFH;;GAEG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEzD;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAI/C"}
|
package/dist/utils/icons.js
CHANGED
|
@@ -46,6 +46,12 @@ const icons = {
|
|
|
46
46
|
info: '<path stroke-linecap="round" stroke-linejoin="round" d="m11.25 11.25.041-.02a.75.75 0 0 1 1.063.852l-.708 2.836a.75.75 0 0 0 1.063.853l.041-.021M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9-3.75h.008v.008H12V8.25Z"/>',
|
|
47
47
|
warning: '<path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126ZM12 15.75h.007v.008H12v-.008Z"/>',
|
|
48
48
|
};
|
|
49
|
+
/**
|
|
50
|
+
* Return raw inner SVG content for a named icon, or undefined.
|
|
51
|
+
*/
|
|
52
|
+
export function iconPath(name) {
|
|
53
|
+
return icons[name];
|
|
54
|
+
}
|
|
49
55
|
/**
|
|
50
56
|
* Render a Heroicon as an inline SVG string.
|
|
51
57
|
* Returns empty string if the icon name is not found.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/utils/markdown.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CASnE;AAED,4CAA4C;AAC5C,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ;
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/utils/markdown.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CASnE;AAED,4CAA4C;AAC5C,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ;AAgJD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,EAAE,CAe5D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAGrD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAG3D"}
|
package/dist/utils/markdown.js
CHANGED
|
@@ -16,6 +16,27 @@ export function renderCodeBlock(text, lang) {
|
|
|
16
16
|
<div class="prose-code-content">${shiki}</div>
|
|
17
17
|
</div>`;
|
|
18
18
|
}
|
|
19
|
+
/* ── Shared directive helpers ─────────────────────────────────────── */
|
|
20
|
+
function parseDirectiveAttrs(raw) {
|
|
21
|
+
const attrs = {};
|
|
22
|
+
for (const [, k, v] of raw.matchAll(/(\w+)="([^"]*)"/g))
|
|
23
|
+
attrs[k] = v;
|
|
24
|
+
return attrs;
|
|
25
|
+
}
|
|
26
|
+
function escAttr(s) {
|
|
27
|
+
return s.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<");
|
|
28
|
+
}
|
|
29
|
+
function requireHttps(url) {
|
|
30
|
+
try {
|
|
31
|
+
const u = new URL(url);
|
|
32
|
+
if (u.protocol !== "https:" && u.protocol !== "http:")
|
|
33
|
+
return null;
|
|
34
|
+
return u.href;
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
19
40
|
function parseVideoUrl(url) {
|
|
20
41
|
// YouTube
|
|
21
42
|
let m = url.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/);
|
|
@@ -42,15 +63,13 @@ const videoExtension = {
|
|
|
42
63
|
const match = src.match(/^::video\[([^\]]+)\](?:\{([^}]*)\})?/);
|
|
43
64
|
if (!match)
|
|
44
65
|
return undefined;
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
const titleMatch = attrs.match(/title="([^"]*)"/);
|
|
48
|
-
return { type: "video", raw: match[0], url, title: titleMatch?.[1] ?? "" };
|
|
66
|
+
const attrs = parseDirectiveAttrs(match[2] ?? "");
|
|
67
|
+
return { type: "video", raw: match[0], url: match[1], title: attrs.title ?? "" };
|
|
49
68
|
},
|
|
50
69
|
renderer(token) {
|
|
51
70
|
const { url, title } = token;
|
|
52
71
|
const parsed = parseVideoUrl(url);
|
|
53
|
-
const safeTitle = title
|
|
72
|
+
const safeTitle = escAttr(title);
|
|
54
73
|
if (parsed.type === "iframe") {
|
|
55
74
|
return `<div class="prose-video not-prose">
|
|
56
75
|
<iframe src="${parsed.src}" title="${safeTitle}" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen loading="lazy"></iframe>
|
|
@@ -65,8 +84,36 @@ const videoExtension = {
|
|
|
65
84
|
},
|
|
66
85
|
],
|
|
67
86
|
};
|
|
87
|
+
const iframeExtension = {
|
|
88
|
+
extensions: [
|
|
89
|
+
{
|
|
90
|
+
name: "iframe",
|
|
91
|
+
level: "block",
|
|
92
|
+
start(src) {
|
|
93
|
+
return src.match(/::iframe\[/)?.index;
|
|
94
|
+
},
|
|
95
|
+
tokenizer(src) {
|
|
96
|
+
const match = src.match(/^::iframe\[([^\]]+)\](?:\{([^}]*)\})?/);
|
|
97
|
+
if (!match)
|
|
98
|
+
return undefined;
|
|
99
|
+
const attrs = parseDirectiveAttrs(match[2] ?? "");
|
|
100
|
+
const height = parseInt(attrs.height ?? "", 10);
|
|
101
|
+
return { type: "iframe", raw: match[0], url: match[1], title: attrs.title ?? "", height: Number.isFinite(height) ? height : 400 };
|
|
102
|
+
},
|
|
103
|
+
renderer(token) {
|
|
104
|
+
const { url, title, height } = token;
|
|
105
|
+
const safeUrl = requireHttps(url);
|
|
106
|
+
if (!safeUrl)
|
|
107
|
+
return `<p>[iframe: invalid URL]</p>\n`;
|
|
108
|
+
return `<div class="prose-iframe not-prose" style="height:${height}px">
|
|
109
|
+
<iframe src="${escAttr(safeUrl)}" title="${escAttr(title)}" frameborder="0" loading="lazy" allowfullscreen></iframe>
|
|
110
|
+
</div>\n`;
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
};
|
|
68
115
|
/** Singleton Marked instance — code blocks get Shiki + prose wrapper, headings get IDs. */
|
|
69
|
-
const marked = new Marked(videoExtension, {
|
|
116
|
+
const marked = new Marked(videoExtension, iframeExtension, {
|
|
70
117
|
renderer: {
|
|
71
118
|
code({ text, lang }) {
|
|
72
119
|
return renderCodeBlock(text, lang);
|