@tiramisu-docs/kit 0.1.0

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 (99) hide show
  1. package/README.md +103 -0
  2. package/components.json +14 -0
  3. package/dist/bin/mcp.d.ts +2 -0
  4. package/dist/bin/mcp.js +4 -0
  5. package/dist/config.d.ts +99 -0
  6. package/dist/config.js +36 -0
  7. package/dist/highlight.d.ts +10 -0
  8. package/dist/highlight.js +93 -0
  9. package/dist/index.d.ts +6 -0
  10. package/dist/index.js +3 -0
  11. package/dist/lib/components/index.d.ts +16 -0
  12. package/dist/lib/components/index.js +18 -0
  13. package/dist/lib/components/tiramisu/lang-icons.d.ts +4 -0
  14. package/dist/lib/components/tiramisu/lang-icons.js +77 -0
  15. package/dist/lib/components/ui/alert/index.d.ts +5 -0
  16. package/dist/lib/components/ui/alert/index.js +6 -0
  17. package/dist/lib/components/ui/badge/index.d.ts +2 -0
  18. package/dist/lib/components/ui/badge/index.js +1 -0
  19. package/dist/lib/components/ui/button/index.d.ts +4 -0
  20. package/dist/lib/components/ui/button/index.js +2 -0
  21. package/dist/lib/components/ui/card/index.d.ts +8 -0
  22. package/dist/lib/components/ui/card/index.js +10 -0
  23. package/dist/lib/components/ui/collapsible/index.d.ts +1 -0
  24. package/dist/lib/components/ui/collapsible/index.js +1 -0
  25. package/dist/lib/components/ui/dropdown-menu/index.d.ts +18 -0
  26. package/dist/lib/components/ui/dropdown-menu/index.js +18 -0
  27. package/dist/lib/components/ui/scroll-area/index.d.ts +1 -0
  28. package/dist/lib/components/ui/scroll-area/index.js +1 -0
  29. package/dist/lib/components/ui/separator/index.d.ts +1 -0
  30. package/dist/lib/components/ui/separator/index.js +1 -0
  31. package/dist/lib/components/ui/sheet/index.d.ts +3 -0
  32. package/dist/lib/components/ui/sheet/index.js +3 -0
  33. package/dist/lib/components/ui/tabs/index.d.ts +5 -0
  34. package/dist/lib/components/ui/tabs/index.js +7 -0
  35. package/dist/lib/open-links.d.ts +22 -0
  36. package/dist/lib/open-links.js +33 -0
  37. package/dist/lib/routes/docs/[...slug]/+page.d.ts +25 -0
  38. package/dist/lib/routes/docs/[...slug]/+page.js +109 -0
  39. package/dist/lib/utils.d.ts +5 -0
  40. package/dist/lib/utils.js +5 -0
  41. package/dist/mcp.d.ts +24 -0
  42. package/dist/mcp.js +155 -0
  43. package/dist/scan.d.ts +15 -0
  44. package/dist/scan.js +72 -0
  45. package/dist/seo.d.ts +63 -0
  46. package/dist/seo.js +160 -0
  47. package/dist/tiramisu-grammar.d.ts +2 -0
  48. package/dist/tiramisu-grammar.js +77 -0
  49. package/dist/types.d.ts +66 -0
  50. package/dist/types.js +1 -0
  51. package/dist/vite.d.ts +33 -0
  52. package/dist/vite.js +406 -0
  53. package/package.json +74 -0
  54. package/src/config.ts +133 -0
  55. package/src/highlight.ts +110 -0
  56. package/src/index.ts +6 -0
  57. package/src/lib/components/DocPage.svelte +430 -0
  58. package/src/lib/components/DocsLayout.svelte +145 -0
  59. package/src/lib/components/Footer.svelte +26 -0
  60. package/src/lib/components/Navbar.svelte +117 -0
  61. package/src/lib/components/PageFooter.svelte +63 -0
  62. package/src/lib/components/PrevNextNav.svelte +83 -0
  63. package/src/lib/components/SearchDialog.svelte +130 -0
  64. package/src/lib/components/Sidebar.svelte +237 -0
  65. package/src/lib/components/TableOfContents.svelte +50 -0
  66. package/src/lib/components/TopBar.svelte +407 -0
  67. package/src/lib/components/index.ts +19 -0
  68. package/src/lib/components/tiramisu/Accordion.svelte +16 -0
  69. package/src/lib/components/tiramisu/Badge.svelte +16 -0
  70. package/src/lib/components/tiramisu/Callout.svelte +26 -0
  71. package/src/lib/components/tiramisu/CodeBlock.svelte +56 -0
  72. package/src/lib/components/tiramisu/CodeTabs.svelte +123 -0
  73. package/src/lib/components/tiramisu/Demo.svelte +15 -0
  74. package/src/lib/components/tiramisu/FileTree.svelte +67 -0
  75. package/src/lib/components/tiramisu/MathBlock.svelte +26 -0
  76. package/src/lib/components/tiramisu/Mermaid.svelte +30 -0
  77. package/src/lib/components/tiramisu/NavCard.svelte +49 -0
  78. package/src/lib/components/tiramisu/Steps.svelte +60 -0
  79. package/src/lib/components/tiramisu/Tabs.svelte +87 -0
  80. package/src/lib/components/tiramisu/ZoomImage.svelte +114 -0
  81. package/src/lib/components/tiramisu/lang-icons.ts +81 -0
  82. package/src/lib/open-links.ts +50 -0
  83. package/src/lib/routes/docs/[...slug]/+page.svelte +26 -0
  84. package/src/lib/routes/docs/[...slug]/+page.ts +117 -0
  85. package/src/lib/styles/theme.css +222 -0
  86. package/src/lib/utils.ts +10 -0
  87. package/src/mcp.ts +180 -0
  88. package/src/scan.ts +92 -0
  89. package/src/seo.ts +193 -0
  90. package/src/tiramisu-grammar.ts +80 -0
  91. package/src/types.ts +71 -0
  92. package/src/virtual.d.ts +11 -0
  93. package/src/vite.ts +478 -0
  94. package/tests/config.test.ts +60 -0
  95. package/tests/mcp.test.ts +116 -0
  96. package/tests/scan.test.ts +48 -0
  97. package/tests/seo.test.ts +174 -0
  98. package/tests/vite.test.ts +283 -0
  99. package/tsconfig.json +19 -0
package/dist/seo.js ADDED
@@ -0,0 +1,160 @@
1
+ export function generateSitemap(docs, options) {
2
+ const base = options.baseUrl.replace(/\/+$/, "");
3
+ const basePath = options.basePath ?? "/docs";
4
+ const buildDate = new Date().toISOString().split("T")[0];
5
+ const hasI18n = options.locales && options.locales.length > 0 && options.defaultLocale;
6
+ let xml = `<?xml version="1.0" encoding="UTF-8"?>\n`;
7
+ if (hasI18n) {
8
+ xml += `<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/TR/xhtml11/xhtml11_schema.html">\n`;
9
+ }
10
+ else {
11
+ xml += `<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n`;
12
+ }
13
+ for (const doc of docs) {
14
+ const slug = doc.slug === "index" ? "" : `/${doc.slug}`;
15
+ const url = `${base}${basePath}${slug}`;
16
+ xml += ` <url>\n`;
17
+ xml += ` <loc>${escapeXml(url)}</loc>\n`;
18
+ xml += ` <lastmod>${buildDate}</lastmod>\n`;
19
+ if (hasI18n) {
20
+ for (const locale of options.locales) {
21
+ const localeUrl = `${base}${basePath}/${locale.code}${slug}`;
22
+ xml += ` <xhtml:link rel="alternate" hreflang="${locale.code}" href="${escapeXml(localeUrl)}" />\n`;
23
+ }
24
+ }
25
+ xml += ` </url>\n`;
26
+ }
27
+ xml += `</urlset>\n`;
28
+ return xml;
29
+ }
30
+ function escapeXml(str) {
31
+ return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
32
+ }
33
+ export function generateLlmsTxt(docs, options) {
34
+ const base = options.baseUrl.replace(/\/+$/, "");
35
+ const basePath = options.basePath ?? "/docs";
36
+ const lines = [];
37
+ lines.push(`# ${options.title}`);
38
+ lines.push(`> ${options.description}`);
39
+ lines.push("");
40
+ const groups = new Map();
41
+ for (const doc of docs) {
42
+ const group = doc.meta.group ?? "Docs";
43
+ if (!groups.has(group))
44
+ groups.set(group, []);
45
+ groups.get(group).push(doc);
46
+ }
47
+ for (const [group, groupDocs] of groups) {
48
+ lines.push(`## ${group}`);
49
+ for (const doc of groupDocs) {
50
+ const slug = doc.slug === "index" ? "" : `/${doc.slug}`;
51
+ const url = `${base}${basePath}${slug}`;
52
+ const title = doc.meta.title ?? doc.slug;
53
+ const desc = doc.meta.description ? `: ${doc.meta.description}` : "";
54
+ lines.push(`- [${title}](${url})${desc}`);
55
+ }
56
+ lines.push("");
57
+ }
58
+ return lines.join("\n");
59
+ }
60
+ export function generateLlmsFullTxt(searchIndex, options) {
61
+ const base = options.baseUrl.replace(/\/+$/, "");
62
+ const basePath = options.basePath ?? "/docs";
63
+ const lines = [];
64
+ lines.push(`# ${options.title}`);
65
+ lines.push(`> ${options.description}`);
66
+ lines.push("");
67
+ for (const entry of searchIndex) {
68
+ const slug = entry.slug === "index" ? "" : `/${entry.slug}`;
69
+ const url = `${base}${basePath}${slug}`;
70
+ lines.push(`---`);
71
+ lines.push(`## ${entry.title}`);
72
+ lines.push(`URL: ${url}`);
73
+ lines.push(`Group: ${entry.group}`);
74
+ lines.push("");
75
+ lines.push(entry.text);
76
+ lines.push("");
77
+ }
78
+ return lines.join("\n");
79
+ }
80
+ export function buildInstantOgUrl(pageUrl, options) {
81
+ const params = new URLSearchParams({ site: options.siteId, url: pageUrl });
82
+ if (options.template)
83
+ params.set("template", options.template);
84
+ if (options.theme)
85
+ params.set("theme", options.theme);
86
+ if (options.accentColor)
87
+ params.set("accentColor", options.accentColor);
88
+ if (options.gradientBg)
89
+ params.set("gradientBg", "true");
90
+ return `https://instantog.com/api/og?${params.toString()}`;
91
+ }
92
+ export function buildCanonicalUrl(baseUrl, slug) {
93
+ return `${baseUrl.replace(/\/+$/, "")}/docs/${slug}`;
94
+ }
95
+ export function buildPageJsonLd(options) {
96
+ const url = buildCanonicalUrl(options.baseUrl, options.slug);
97
+ const ld = {
98
+ "@context": "https://schema.org",
99
+ "@type": "TechArticle",
100
+ headline: options.title,
101
+ url,
102
+ mainEntityOfPage: { "@type": "WebPage", "@id": url },
103
+ isPartOf: { "@type": "WebSite", name: options.siteName ?? undefined, url: options.baseUrl.replace(/\/+$/, "") },
104
+ };
105
+ if (options.description)
106
+ ld.description = options.description;
107
+ if (options.lastEdited)
108
+ ld.dateModified = options.lastEdited;
109
+ if (options.image)
110
+ ld.image = options.image;
111
+ if (options.author)
112
+ ld.author = { "@type": "Person", name: options.author };
113
+ return JSON.stringify(ld);
114
+ }
115
+ export function generateSkillMd(docs, options) {
116
+ const lines = [];
117
+ lines.push(`---`);
118
+ lines.push(`name: ${options.title.toLowerCase().replace(/\s+/g, "-")}-docs`);
119
+ lines.push(`description: ${options.description}`);
120
+ lines.push(`---`);
121
+ lines.push("");
122
+ lines.push(`# ${options.title} Documentation`);
123
+ lines.push("");
124
+ lines.push(options.description);
125
+ lines.push("");
126
+ // Structure by groups
127
+ const groups = new Map();
128
+ for (const doc of docs) {
129
+ const group = doc.meta.group ?? "Docs";
130
+ if (!groups.has(group))
131
+ groups.set(group, []);
132
+ groups.get(group).push(doc);
133
+ }
134
+ lines.push(`## Sections`);
135
+ lines.push("");
136
+ for (const [group, groupDocs] of groups) {
137
+ lines.push(`- **${group}** (${groupDocs.length} pages)`);
138
+ }
139
+ lines.push("");
140
+ lines.push(`## Key Pages`);
141
+ lines.push("");
142
+ for (const [group, groupDocs] of groups) {
143
+ lines.push(`### ${group}`);
144
+ for (const doc of groupDocs) {
145
+ const title = doc.meta.title ?? doc.slug;
146
+ const desc = doc.meta.description ? ` - ${doc.meta.description}` : "";
147
+ lines.push(`- **${title}** (\`${doc.slug}\`)${desc}`);
148
+ }
149
+ lines.push("");
150
+ }
151
+ lines.push(`## MCP Integration`);
152
+ lines.push("");
153
+ lines.push(`This documentation is available via MCP server. Tools:`);
154
+ lines.push(`- \`search_docs\`: Search documentation by keyword`);
155
+ lines.push(`- \`read_doc\`: Read a specific documentation page`);
156
+ lines.push(`- \`list_sections\`: List all documentation sections`);
157
+ lines.push(`- \`list_pages\`: List pages, optionally filtered by section`);
158
+ lines.push(`- \`get_table_of_contents\`: Get headings for a page`);
159
+ return lines.join("\n") + "\n";
160
+ }
@@ -0,0 +1,2 @@
1
+ import type { LanguageRegistration } from "shiki";
2
+ export declare const tiramisuGrammar: LanguageRegistration;
@@ -0,0 +1,77 @@
1
+ export const tiramisuGrammar = {
2
+ name: "tiramisu",
3
+ scopeName: "source.tiramisu",
4
+ patterns: [
5
+ { include: "#string" },
6
+ { include: "#function-call" },
7
+ ],
8
+ repository: {
9
+ string: {
10
+ patterns: [
11
+ {
12
+ name: "string.quoted.triple.tiramisu",
13
+ begin: '"""',
14
+ end: '"""',
15
+ patterns: [{ include: "#string-escape" }],
16
+ },
17
+ {
18
+ name: "string.quoted.double-double.tiramisu",
19
+ begin: '""(?!")',
20
+ end: '""',
21
+ patterns: [{ include: "#string-escape" }],
22
+ },
23
+ {
24
+ name: "string.quoted.double.tiramisu",
25
+ begin: '"(?!")',
26
+ end: '"',
27
+ patterns: [{ include: "#string-escape" }],
28
+ },
29
+ ],
30
+ },
31
+ "string-escape": {
32
+ name: "constant.character.escape.tiramisu",
33
+ match: "\\\\[,{}\\[\\]\\\\]",
34
+ },
35
+ "function-call": {
36
+ patterns: [
37
+ {
38
+ // Known built-in functions
39
+ match: "\\b(meta|h[1-6]|bold|italic|code|link|image|codeblock|list|table|callout|tabs|steps|badge|quote|tasklist|columns|col|accordion|cards|card|filetree|folder|file|math|mermaid)\\s*(?=\\{)",
40
+ captures: {
41
+ 1: { name: "support.function.builtin.tiramisu" },
42
+ },
43
+ },
44
+ {
45
+ // Custom/user functions
46
+ match: "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\s*(?=\\{)",
47
+ captures: {
48
+ 1: { name: "entity.name.function.tiramisu" },
49
+ },
50
+ },
51
+ {
52
+ // Named parameter keys
53
+ match: "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\s*(?==)",
54
+ captures: {
55
+ 1: { name: "variable.parameter.tiramisu" },
56
+ },
57
+ },
58
+ {
59
+ name: "punctuation.section.braces.tiramisu",
60
+ match: "[{}]",
61
+ },
62
+ {
63
+ name: "punctuation.section.brackets.tiramisu",
64
+ match: "[\\[\\]]",
65
+ },
66
+ {
67
+ name: "punctuation.separator.comma.tiramisu",
68
+ match: ",",
69
+ },
70
+ {
71
+ name: "keyword.operator.assignment.tiramisu",
72
+ match: "=",
73
+ },
74
+ ],
75
+ },
76
+ },
77
+ };
@@ -0,0 +1,66 @@
1
+ import type { DocMeta, Heading } from "@tiramisu-docs/core";
2
+ import type { SvelteComponent } from "svelte";
3
+ export interface SidebarItem {
4
+ type: "item";
5
+ title: string;
6
+ slug: string;
7
+ order: number;
8
+ icon?: string;
9
+ }
10
+ export interface SidebarSubgroup {
11
+ type: "subgroup";
12
+ key: string;
13
+ label: string;
14
+ slug?: string;
15
+ items: SidebarEntry[];
16
+ order: number;
17
+ icon?: string;
18
+ }
19
+ export type SidebarEntry = SidebarItem | SidebarSubgroup;
20
+ export interface SidebarGroup {
21
+ label: string;
22
+ items: SidebarEntry[];
23
+ icon?: string;
24
+ }
25
+ export interface VirtualDoc {
26
+ slug: string;
27
+ meta: DocMeta;
28
+ headings: Heading[];
29
+ lastEdited?: string;
30
+ }
31
+ export interface SearchIndexEntry {
32
+ id: string;
33
+ title: string;
34
+ group: string;
35
+ slug: string;
36
+ headings: string;
37
+ text: string;
38
+ }
39
+ export interface ResolvedSection {
40
+ label: string;
41
+ path?: string;
42
+ href?: string;
43
+ icon?: string;
44
+ children?: ResolvedSection[];
45
+ sidebar?: SidebarGroup[];
46
+ }
47
+ export interface LocaleData {
48
+ sections?: ResolvedSection[];
49
+ sidebar: SidebarGroup[];
50
+ docs: VirtualDoc[];
51
+ searchIndex: SearchIndexEntry[];
52
+ docImports: Record<string, () => Promise<{
53
+ default: typeof SvelteComponent;
54
+ }>>;
55
+ }
56
+ export interface VirtualModule {
57
+ docs: VirtualDoc[];
58
+ sidebar: SidebarGroup[];
59
+ sections?: ResolvedSection[];
60
+ docImports: Record<string, () => Promise<{
61
+ default: typeof SvelteComponent;
62
+ }>>;
63
+ searchIndex: SearchIndexEntry[];
64
+ locales?: Record<string, LocaleData>;
65
+ defaultLocale?: string;
66
+ }
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/dist/vite.d.ts ADDED
@@ -0,0 +1,33 @@
1
+ import type { DocMeta, Heading } from "@tiramisu-docs/core";
2
+ import type { Plugin } from "vite";
3
+ import type { SectionConfig, TiramisuDocsConfig } from "./config.js";
4
+ import type { SidebarGroup, ResolvedSection } from "./types.js";
5
+ export type { SidebarItem, SidebarSubgroup, SidebarEntry, SidebarGroup, ResolvedSection } from "./types.js";
6
+ export interface TiramisuPluginOptions {
7
+ docsDir?: string;
8
+ config?: TiramisuDocsConfig;
9
+ }
10
+ export declare function buildSidebarTree(docs: {
11
+ slug: string;
12
+ meta: DocMeta;
13
+ }[], groupOrder?: string[]): SidebarGroup[];
14
+ export declare function buildSectionSidebars(docs: {
15
+ slug: string;
16
+ meta: DocMeta;
17
+ }[], sections: SectionConfig[], implicitLabel?: string): ResolvedSection[];
18
+ export declare function buildLocaleData(allDocs: {
19
+ slug: string;
20
+ meta: DocMeta;
21
+ headings: Heading[];
22
+ lastEdited: string;
23
+ }[], locales: {
24
+ code: string;
25
+ }[]): Record<string, {
26
+ docs: {
27
+ slug: string;
28
+ meta: DocMeta;
29
+ headings: Heading[];
30
+ lastEdited: string;
31
+ }[];
32
+ }>;
33
+ export declare function tiramisuPlugin(options?: TiramisuPluginOptions): Plugin;