@alliance-droid/svelte-docs-system 0.0.2 → 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.
- package/README.md +155 -23
- package/dist/components/APITable.svelte.d.ts +21 -0
- package/dist/components/Breadcrumbs.svelte.d.ts +14 -0
- package/dist/components/Callout.svelte.d.ts +15 -0
- package/dist/components/CodeBlock.svelte.d.ts +12 -0
- package/{src/lib → dist}/components/DocLayout.svelte +18 -6
- package/dist/components/DocLayout.svelte.d.ts +18 -0
- package/dist/components/DocsPage.svelte +39 -0
- package/dist/components/DocsPage.svelte.d.ts +8 -0
- package/dist/components/Documentation.svelte +639 -0
- package/dist/components/Footer.svelte.d.ts +10 -0
- package/dist/components/Image.svelte.d.ts +15 -0
- package/{src/lib → dist}/components/Navbar.svelte +4 -4
- package/dist/components/Navbar.svelte.d.ts +10 -0
- package/{src/lib → dist}/components/Search.svelte +2 -2
- package/dist/components/Search.svelte.d.ts +6 -0
- package/{template-starter/src/lib → dist}/components/Sidebar.svelte +2 -2
- package/dist/components/Sidebar.svelte.d.ts +9 -0
- package/dist/components/Tabs.svelte.d.ts +16 -0
- package/dist/config.d.ts +93 -0
- package/dist/config.js +89 -0
- package/dist/configLoader.d.ts +48 -0
- package/dist/configLoader.js +187 -0
- package/dist/configParser.d.ts +27 -0
- package/dist/configParser.js +208 -0
- package/{template-starter/src/lib/index.ts → dist/index.d.ts} +6 -7
- package/dist/index.js +18 -0
- package/dist/navigationBuilder.d.ts +64 -0
- package/dist/navigationBuilder.js +225 -0
- package/dist/plugin.d.ts +30 -0
- package/dist/plugin.js +172 -0
- package/dist/routing.d.ts +48 -0
- package/dist/routing.js +92 -0
- package/dist/stores/i18n.d.ts +20 -0
- package/dist/stores/i18n.js +119 -0
- package/dist/stores/nav.d.ts +20 -0
- package/dist/stores/nav.js +15 -0
- package/dist/stores/search.d.ts +49 -0
- package/dist/stores/search.js +127 -0
- package/dist/stores/theme.d.ts +7 -0
- package/dist/stores/theme.js +152 -0
- package/dist/stores/version.d.ts +18 -0
- package/dist/stores/version.js +93 -0
- package/dist/themeCustomization.d.ts +46 -0
- package/dist/themeCustomization.js +188 -0
- package/dist/utils/highlight.d.ts +13 -0
- package/dist/utils/highlight.js +83 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/markdown.d.ts +40 -0
- package/dist/utils/markdown.js +165 -0
- package/package.json +44 -23
- package/COMPONENTS.md +0 -365
- package/COVERAGE_REPORT.md +0 -663
- package/SEARCH_VERIFICATION.md +0 -229
- package/TEST_SUMMARY.md +0 -344
- package/bin/init.js +0 -821
- package/docs/COMPONENT_LIBRARY_INTEGRATION_REPORT.md +0 -153
- package/docs/DARK_MODE_AUDIT_REPORT.md +0 -403
- package/docs/E2E_TESTS.md +0 -354
- package/docs/TESTING.md +0 -754
- package/docs/THEME_INHERITANCE.md +0 -192
- package/docs/de/index.md +0 -41
- package/docs/en/COMPONENTS.md +0 -443
- package/docs/en/api/examples.md +0 -100
- package/docs/en/api/overview.md +0 -69
- package/docs/en/components/index.md +0 -622
- package/docs/en/config/navigation.md +0 -505
- package/docs/en/config/theme-and-colors.md +0 -395
- package/docs/en/getting-started/integration.md +0 -406
- package/docs/en/guides/common-setups.md +0 -651
- package/docs/en/index.md +0 -243
- package/docs/en/markdown.md +0 -102
- package/docs/en/routing.md +0 -64
- package/docs/en/setup.md +0 -52
- package/docs/en/troubleshooting.md +0 -704
- package/docs/es/index.md +0 -41
- package/docs/fr/index.md +0 -41
- package/docs/ja/index.md +0 -41
- package/pagefind.toml +0 -8
- package/postcss.config.js +0 -5
- package/src/app.css +0 -119
- package/src/app.d.ts +0 -13
- package/src/app.html +0 -11
- package/src/lib/components/APITable.test.ts +0 -153
- package/src/lib/components/Breadcrumbs.test.ts +0 -148
- package/src/lib/components/Callout.test.ts +0 -100
- package/src/lib/components/CodeBlock.test.ts +0 -133
- package/src/lib/components/Image.test.ts +0 -163
- package/src/lib/components/Sidebar.svelte +0 -110
- package/src/lib/components/Tabs.test.ts +0 -102
- package/src/lib/config.test.ts +0 -140
- package/src/lib/config.ts +0 -179
- package/src/lib/configIntegration.test.ts +0 -272
- package/src/lib/configLoader.ts +0 -231
- package/src/lib/configParser.test.ts +0 -217
- package/src/lib/configParser.ts +0 -234
- package/src/lib/index.ts +0 -37
- package/src/lib/integration.test.ts +0 -426
- package/src/lib/navigationBuilder.test.ts +0 -338
- package/src/lib/navigationBuilder.ts +0 -268
- package/src/lib/performance.test.ts +0 -369
- package/src/lib/routing.test.ts +0 -202
- package/src/lib/routing.ts +0 -127
- package/src/lib/search-functionality.test.ts +0 -493
- package/src/lib/stores/i18n.test.ts +0 -180
- package/src/lib/stores/i18n.ts +0 -143
- package/src/lib/stores/nav.ts +0 -36
- package/src/lib/stores/search.test.ts +0 -140
- package/src/lib/stores/search.ts +0 -162
- package/src/lib/stores/theme.test.ts +0 -117
- package/src/lib/stores/theme.ts +0 -167
- package/src/lib/stores/version.test.ts +0 -139
- package/src/lib/stores/version.ts +0 -111
- package/src/lib/themeCustomization.test.ts +0 -223
- package/src/lib/themeCustomization.ts +0 -212
- package/src/lib/utils/highlight.test.ts +0 -136
- package/src/lib/utils/highlight.ts +0 -100
- package/src/lib/utils/index.ts +0 -7
- package/src/lib/utils/markdown.test.ts +0 -357
- package/src/lib/utils/markdown.ts +0 -77
- package/src/routes/+layout.server.ts +0 -1
- package/src/routes/+layout.svelte +0 -29
- package/src/routes/+page.svelte +0 -165
- package/src/routes/quote-demo/+page.svelte +0 -141
- package/static/robots.txt +0 -3
- package/svelte.config.js +0 -15
- package/tailwind.config.ts +0 -55
- package/template-starter/.github/workflows/build.yml +0 -40
- package/template-starter/.github/workflows/deploy-github-pages.yml +0 -47
- package/template-starter/.github/workflows/deploy-netlify.yml +0 -41
- package/template-starter/.github/workflows/deploy-vercel.yml +0 -64
- package/template-starter/NPM-PACKAGE-SETUP.md +0 -233
- package/template-starter/README.md +0 -320
- package/template-starter/docs/_config.json +0 -39
- package/template-starter/docs/api/components.md +0 -257
- package/template-starter/docs/api/overview.md +0 -169
- package/template-starter/docs/guides/configuration.md +0 -145
- package/template-starter/docs/guides/github-pages-deployment.md +0 -254
- package/template-starter/docs/guides/netlify-deployment.md +0 -159
- package/template-starter/docs/guides/vercel-deployment.md +0 -131
- package/template-starter/docs/index.md +0 -49
- package/template-starter/docs/setup.md +0 -149
- package/template-starter/package.json +0 -31
- package/template-starter/pagefind.toml +0 -3
- package/template-starter/postcss.config.js +0 -5
- package/template-starter/src/app.css +0 -34
- package/template-starter/src/app.d.ts +0 -13
- package/template-starter/src/app.html +0 -11
- package/template-starter/src/lib/components/APITable.svelte +0 -120
- package/template-starter/src/lib/components/APITable.test.ts +0 -96
- package/template-starter/src/lib/components/Breadcrumbs.svelte +0 -85
- package/template-starter/src/lib/components/Breadcrumbs.test.ts +0 -82
- package/template-starter/src/lib/components/Callout.svelte +0 -60
- package/template-starter/src/lib/components/Callout.test.ts +0 -91
- package/template-starter/src/lib/components/CodeBlock.svelte +0 -68
- package/template-starter/src/lib/components/CodeBlock.test.ts +0 -62
- package/template-starter/src/lib/components/DocLayout.svelte +0 -84
- package/template-starter/src/lib/components/Footer.svelte +0 -78
- package/template-starter/src/lib/components/Image.svelte +0 -100
- package/template-starter/src/lib/components/Image.test.ts +0 -81
- package/template-starter/src/lib/components/Navbar.svelte +0 -141
- package/template-starter/src/lib/components/Search.svelte +0 -248
- package/template-starter/src/lib/components/Tabs.svelte +0 -48
- package/template-starter/src/lib/components/Tabs.test.ts +0 -89
- package/template-starter/src/routes/+layout.svelte +0 -28
- package/template-starter/src/routes/+page.svelte +0 -92
- package/template-starter/svelte.config.js +0 -17
- package/template-starter/tailwind.config.ts +0 -17
- package/template-starter/tsconfig.json +0 -13
- package/template-starter/vite.config.ts +0 -6
- package/tests/e2e/example.spec.ts +0 -345
- package/tsconfig.json +0 -20
- package/vite.config.ts +0 -6
- package/vitest.config.ts +0 -33
- package/vitest.setup.ts +0 -21
- /package/{src/lib → dist}/assets/favicon.svg +0 -0
- /package/{src/lib → dist}/components/APITable.svelte +0 -0
- /package/{src/lib → dist}/components/Breadcrumbs.svelte +0 -0
- /package/{src/lib → dist}/components/Callout.svelte +0 -0
- /package/{src/lib → dist}/components/CodeBlock.svelte +0 -0
- /package/{src/lib → dist}/components/Footer.svelte +0 -0
- /package/{src/lib → dist}/components/Image.svelte +0 -0
- /package/{src/lib → dist}/components/Tabs.svelte +0 -0
- /package/{src/lib → dist}/svelte-component-library.d.ts +0 -0
|
@@ -1,357 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach } from 'vitest';
|
|
2
|
-
import {
|
|
3
|
-
renderMarkdown,
|
|
4
|
-
extractMetadata,
|
|
5
|
-
getExcerpt,
|
|
6
|
-
type MarkdownResult,
|
|
7
|
-
type MarkdownMetadata
|
|
8
|
-
} from './markdown';
|
|
9
|
-
|
|
10
|
-
describe('Markdown Utilities', () => {
|
|
11
|
-
describe('renderMarkdown', () => {
|
|
12
|
-
it('should render basic markdown to HTML', async () => {
|
|
13
|
-
const content = '# Hello World';
|
|
14
|
-
const result = await renderMarkdown(content);
|
|
15
|
-
|
|
16
|
-
expect(result.html).toBeTruthy();
|
|
17
|
-
expect(result.html).toContain('Hello World');
|
|
18
|
-
expect(result.html).toContain('<h1>');
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('should parse frontmatter metadata', async () => {
|
|
22
|
-
const content = `---
|
|
23
|
-
title: Test Page
|
|
24
|
-
description: A test page
|
|
25
|
-
author: John Doe
|
|
26
|
-
---
|
|
27
|
-
|
|
28
|
-
# Content`;
|
|
29
|
-
|
|
30
|
-
const result = await renderMarkdown(content);
|
|
31
|
-
|
|
32
|
-
expect(result.metadata.title).toBe('Test Page');
|
|
33
|
-
expect(result.metadata.description).toBe('A test page');
|
|
34
|
-
expect(result.metadata.author).toBe('John Doe');
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('should handle content without frontmatter', async () => {
|
|
38
|
-
const content = '## Section\n\nSome content here';
|
|
39
|
-
const result = await renderMarkdown(content);
|
|
40
|
-
|
|
41
|
-
expect(result.html).toBeTruthy();
|
|
42
|
-
expect(result.metadata).toEqual({});
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('should convert markdown formatting to HTML', async () => {
|
|
46
|
-
const content = `
|
|
47
|
-
# Heading 1
|
|
48
|
-
## Heading 2
|
|
49
|
-
**Bold text**
|
|
50
|
-
*Italic text*
|
|
51
|
-
\`code\`
|
|
52
|
-
`;
|
|
53
|
-
|
|
54
|
-
const result = await renderMarkdown(content);
|
|
55
|
-
|
|
56
|
-
expect(result.html).toContain('<h1>');
|
|
57
|
-
expect(result.html).toContain('<h2>');
|
|
58
|
-
expect(result.html).toContain('<strong>');
|
|
59
|
-
expect(result.html).toContain('<em>');
|
|
60
|
-
expect(result.html).toContain('<code>');
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('should handle code blocks', async () => {
|
|
64
|
-
const content = `\`\`\`javascript
|
|
65
|
-
const x = 42;
|
|
66
|
-
console.log(x);
|
|
67
|
-
\`\`\``;
|
|
68
|
-
|
|
69
|
-
const result = await renderMarkdown(content);
|
|
70
|
-
|
|
71
|
-
expect(result.html).toContain('<pre>');
|
|
72
|
-
expect(result.html).toContain('<code');
|
|
73
|
-
expect(result.html).toContain('const x = 42');
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it('should handle lists', async () => {
|
|
77
|
-
const content = `
|
|
78
|
-
- Item 1
|
|
79
|
-
- Item 2
|
|
80
|
-
- Item 3
|
|
81
|
-
|
|
82
|
-
1. First
|
|
83
|
-
2. Second
|
|
84
|
-
3. Third
|
|
85
|
-
`;
|
|
86
|
-
|
|
87
|
-
const result = await renderMarkdown(content);
|
|
88
|
-
|
|
89
|
-
expect(result.html).toContain('<li>');
|
|
90
|
-
expect(result.html).toContain('Item 1');
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('should handle links', async () => {
|
|
94
|
-
const content = '[Visit Example](https://example.com)';
|
|
95
|
-
const result = await renderMarkdown(content);
|
|
96
|
-
|
|
97
|
-
expect(result.html).toContain('<a');
|
|
98
|
-
expect(result.html).toContain('https://example.com');
|
|
99
|
-
expect(result.html).toContain('Visit Example');
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it('should handle images', async () => {
|
|
103
|
-
const content = '';
|
|
104
|
-
const result = await renderMarkdown(content);
|
|
105
|
-
|
|
106
|
-
expect(result.html).toContain('<img');
|
|
107
|
-
expect(result.html).toContain('./image.png');
|
|
108
|
-
expect(result.html).toContain('Alt text');
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('should handle blockquotes', async () => {
|
|
112
|
-
const content = '> This is a quote';
|
|
113
|
-
const result = await renderMarkdown(content);
|
|
114
|
-
|
|
115
|
-
expect(result.html).toContain('<blockquote');
|
|
116
|
-
expect(result.html).toContain('This is a quote');
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it('should handle tables', async () => {
|
|
120
|
-
const content = `
|
|
121
|
-
| Header 1 | Header 2 |
|
|
122
|
-
|----------|----------|
|
|
123
|
-
| Cell 1 | Cell 2 |
|
|
124
|
-
| Cell 3 | Cell 4 |
|
|
125
|
-
`;
|
|
126
|
-
|
|
127
|
-
const result = await renderMarkdown(content);
|
|
128
|
-
|
|
129
|
-
expect(result.html).toContain('<table');
|
|
130
|
-
expect(result.html).toContain('Header 1');
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it('should return result type with html and metadata', async () => {
|
|
134
|
-
const content = `---
|
|
135
|
-
title: Test
|
|
136
|
-
---
|
|
137
|
-
Content`;
|
|
138
|
-
|
|
139
|
-
const result = await renderMarkdown(content);
|
|
140
|
-
|
|
141
|
-
expect(result).toHaveProperty('html');
|
|
142
|
-
expect(result).toHaveProperty('metadata');
|
|
143
|
-
expect(typeof result.html).toBe('string');
|
|
144
|
-
expect(typeof result.metadata).toBe('object');
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it('should handle empty content', async () => {
|
|
148
|
-
const result = await renderMarkdown('');
|
|
149
|
-
expect(result.html).toBeDefined();
|
|
150
|
-
expect(result.metadata).toBeDefined();
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
it('should handle very long content', async () => {
|
|
154
|
-
const longContent = Array(100).fill('# Heading\n\nContent').join('\n');
|
|
155
|
-
const result = await renderMarkdown(longContent);
|
|
156
|
-
|
|
157
|
-
expect(result.html).toBeTruthy();
|
|
158
|
-
expect(result.html.length).toBeGreaterThan(0);
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
it('should preserve custom metadata fields', async () => {
|
|
162
|
-
const content = `---
|
|
163
|
-
title: Test
|
|
164
|
-
custom_field: custom_value
|
|
165
|
-
tags: [tag1, tag2]
|
|
166
|
-
---
|
|
167
|
-
Content`;
|
|
168
|
-
|
|
169
|
-
const result = await renderMarkdown(content);
|
|
170
|
-
|
|
171
|
-
expect(result.metadata.custom_field).toBe('custom_value');
|
|
172
|
-
expect(Array.isArray(result.metadata.tags)).toBe(true);
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
describe('extractMetadata', () => {
|
|
177
|
-
it('should extract metadata from content', () => {
|
|
178
|
-
const content = `---
|
|
179
|
-
title: Page Title
|
|
180
|
-
description: Page description
|
|
181
|
-
author: John Doe
|
|
182
|
-
date: 2024-01-01
|
|
183
|
-
---
|
|
184
|
-
Content`;
|
|
185
|
-
|
|
186
|
-
const metadata = extractMetadata(content);
|
|
187
|
-
|
|
188
|
-
expect(metadata.title).toBe('Page Title');
|
|
189
|
-
expect(metadata.description).toBe('Page description');
|
|
190
|
-
expect(metadata.author).toBe('John Doe');
|
|
191
|
-
// YAML parses dates as Date objects, convert to ISO string
|
|
192
|
-
expect(metadata.date instanceof Date || typeof metadata.date === 'string').toBe(true);
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
it('should return empty object if no frontmatter', () => {
|
|
196
|
-
const content = '# Just content\n\nNo metadata here';
|
|
197
|
-
const metadata = extractMetadata(content);
|
|
198
|
-
|
|
199
|
-
expect(Object.keys(metadata).length).toBe(0);
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
it('should handle empty frontmatter', () => {
|
|
203
|
-
const content = `---
|
|
204
|
-
---
|
|
205
|
-
Content`;
|
|
206
|
-
|
|
207
|
-
const metadata = extractMetadata(content);
|
|
208
|
-
expect(metadata).toBeDefined();
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
it('should support various data types in metadata', () => {
|
|
212
|
-
const content = `---
|
|
213
|
-
string_field: value
|
|
214
|
-
number_field: 42
|
|
215
|
-
boolean_field: true
|
|
216
|
-
array_field: [1, 2, 3]
|
|
217
|
-
object_field:
|
|
218
|
-
nested: value
|
|
219
|
-
---
|
|
220
|
-
Content`;
|
|
221
|
-
|
|
222
|
-
const metadata = extractMetadata(content);
|
|
223
|
-
|
|
224
|
-
expect(metadata.string_field).toBe('value');
|
|
225
|
-
expect(metadata.number_field).toBe(42);
|
|
226
|
-
expect(metadata.boolean_field).toBe(true);
|
|
227
|
-
expect(Array.isArray(metadata.array_field)).toBe(true);
|
|
228
|
-
expect(metadata.object_field.nested).toBe('value');
|
|
229
|
-
});
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
describe('getExcerpt', () => {
|
|
233
|
-
it('should extract excerpt from markdown content', () => {
|
|
234
|
-
const content = `---
|
|
235
|
-
title: Test
|
|
236
|
-
---
|
|
237
|
-
|
|
238
|
-
This is the first paragraph with some content.
|
|
239
|
-
|
|
240
|
-
This is the second paragraph.`;
|
|
241
|
-
|
|
242
|
-
const excerpt = getExcerpt(content);
|
|
243
|
-
|
|
244
|
-
expect(excerpt).toContain('This is the first paragraph');
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
it('should remove markdown formatting from excerpt', () => {
|
|
248
|
-
const content = `**Bold** and *italic* with [links](https://example.com)`;
|
|
249
|
-
const excerpt = getExcerpt(content);
|
|
250
|
-
|
|
251
|
-
expect(excerpt).not.toContain('**');
|
|
252
|
-
expect(excerpt).not.toContain('*');
|
|
253
|
-
expect(excerpt).not.toContain('[');
|
|
254
|
-
expect(excerpt).toContain('Bold');
|
|
255
|
-
expect(excerpt).toContain('links');
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
it('should remove header formatting from excerpt', () => {
|
|
259
|
-
const content = `This is the actual content without headers.`;
|
|
260
|
-
|
|
261
|
-
const excerpt = getExcerpt(content);
|
|
262
|
-
|
|
263
|
-
expect(excerpt).toContain('This is the actual content');
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
it('should remove inline code from excerpt', () => {
|
|
267
|
-
const content = 'This is `code` in the text';
|
|
268
|
-
const excerpt = getExcerpt(content);
|
|
269
|
-
|
|
270
|
-
expect(excerpt).not.toContain('`');
|
|
271
|
-
expect(excerpt).toContain('This is code in the text');
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
it('should respect word limit', () => {
|
|
275
|
-
const longContent = Array(50).fill('word').join(' ');
|
|
276
|
-
const excerpt = getExcerpt(longContent, 10);
|
|
277
|
-
|
|
278
|
-
const wordCount = excerpt.split(/\s+/).length;
|
|
279
|
-
expect(wordCount).toBeLessThanOrEqual(11); // 10 words + ellipsis might add spaces
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
it('should add ellipsis if content is truncated', () => {
|
|
283
|
-
const longContent = Array(200).fill('word').join(' ');
|
|
284
|
-
const excerpt = getExcerpt(longContent, 10);
|
|
285
|
-
|
|
286
|
-
expect(excerpt).toContain('...');
|
|
287
|
-
});
|
|
288
|
-
|
|
289
|
-
it('should not add ellipsis if content fits', () => {
|
|
290
|
-
const shortContent = 'Short content';
|
|
291
|
-
const excerpt = getExcerpt(shortContent, 100);
|
|
292
|
-
|
|
293
|
-
expect(excerpt).not.toContain('...');
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
it('should handle content with frontmatter', () => {
|
|
297
|
-
const content = `---
|
|
298
|
-
title: Test
|
|
299
|
-
---
|
|
300
|
-
|
|
301
|
-
This is the excerpt content.`;
|
|
302
|
-
|
|
303
|
-
const excerpt = getExcerpt(content);
|
|
304
|
-
|
|
305
|
-
expect(excerpt).toContain('This is the excerpt content');
|
|
306
|
-
expect(excerpt).not.toContain('title');
|
|
307
|
-
});
|
|
308
|
-
|
|
309
|
-
it('should handle empty content', () => {
|
|
310
|
-
const excerpt = getExcerpt('');
|
|
311
|
-
expect(excerpt).toBe('');
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
it('should handle content with only whitespace', () => {
|
|
315
|
-
const excerpt = getExcerpt(' \n\n ');
|
|
316
|
-
expect(excerpt.trim()).toBe('');
|
|
317
|
-
});
|
|
318
|
-
|
|
319
|
-
it('should handle default word limit', () => {
|
|
320
|
-
const content = Array(200).fill('word').join(' ');
|
|
321
|
-
const excerpt = getExcerpt(content); // Uses default 150
|
|
322
|
-
|
|
323
|
-
expect(excerpt).toBeTruthy();
|
|
324
|
-
});
|
|
325
|
-
});
|
|
326
|
-
|
|
327
|
-
describe('Edge Cases', () => {
|
|
328
|
-
it('should handle malformed markdown gracefully', async () => {
|
|
329
|
-
const content = '[unclosed link]](extra';
|
|
330
|
-
const result = await renderMarkdown(content);
|
|
331
|
-
|
|
332
|
-
expect(result.html).toBeDefined();
|
|
333
|
-
expect(result.metadata).toBeDefined();
|
|
334
|
-
});
|
|
335
|
-
|
|
336
|
-
it('should handle special characters in content', async () => {
|
|
337
|
-
const content = '< > & " \' `special characters`';
|
|
338
|
-
const result = await renderMarkdown(content);
|
|
339
|
-
|
|
340
|
-
expect(result.html).toBeTruthy();
|
|
341
|
-
});
|
|
342
|
-
|
|
343
|
-
it('should handle unicode content', async () => {
|
|
344
|
-
const content = '# 你好世界\n\n日本語テスト';
|
|
345
|
-
const result = await renderMarkdown(content);
|
|
346
|
-
|
|
347
|
-
expect(result.html).toContain('你好世界');
|
|
348
|
-
});
|
|
349
|
-
|
|
350
|
-
it('should handle nested formatting', async () => {
|
|
351
|
-
const content = '***Bold and italic***';
|
|
352
|
-
const result = await renderMarkdown(content);
|
|
353
|
-
|
|
354
|
-
expect(result.html).toBeTruthy();
|
|
355
|
-
});
|
|
356
|
-
});
|
|
357
|
-
});
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { marked } from 'marked';
|
|
2
|
-
import matter from 'gray-matter';
|
|
3
|
-
|
|
4
|
-
export interface MarkdownMetadata {
|
|
5
|
-
title?: string;
|
|
6
|
-
description?: string;
|
|
7
|
-
author?: string;
|
|
8
|
-
date?: string;
|
|
9
|
-
[key: string]: any;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface MarkdownResult {
|
|
13
|
-
html: string;
|
|
14
|
-
metadata: MarkdownMetadata;
|
|
15
|
-
slug?: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Parse markdown content with frontmatter
|
|
20
|
-
* Returns HTML content and metadata
|
|
21
|
-
*/
|
|
22
|
-
export async function renderMarkdown(content: string): Promise<MarkdownResult> {
|
|
23
|
-
try {
|
|
24
|
-
// Parse frontmatter and content
|
|
25
|
-
const { data, content: markdownContent } = matter(content);
|
|
26
|
-
|
|
27
|
-
// Convert markdown to HTML (marked is async in v17+)
|
|
28
|
-
const html = await marked(markdownContent);
|
|
29
|
-
|
|
30
|
-
return {
|
|
31
|
-
html,
|
|
32
|
-
metadata: data as MarkdownMetadata
|
|
33
|
-
};
|
|
34
|
-
} catch (error) {
|
|
35
|
-
console.error('Error rendering markdown:', error);
|
|
36
|
-
return {
|
|
37
|
-
html: '<p>Error rendering markdown</p>',
|
|
38
|
-
metadata: {}
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Extract metadata from markdown content
|
|
45
|
-
*/
|
|
46
|
-
export function extractMetadata(content: string): MarkdownMetadata {
|
|
47
|
-
try {
|
|
48
|
-
const { data } = matter(content);
|
|
49
|
-
return data as MarkdownMetadata;
|
|
50
|
-
} catch (error) {
|
|
51
|
-
return {};
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Get excerpt from markdown content (first paragraph)
|
|
57
|
-
*/
|
|
58
|
-
export function getExcerpt(content: string, wordLimit = 150): string {
|
|
59
|
-
try {
|
|
60
|
-
const { content: markdownContent } = matter(content);
|
|
61
|
-
|
|
62
|
-
// Remove markdown syntax and get first paragraph
|
|
63
|
-
const text = markdownContent
|
|
64
|
-
.replace(/#{1,6}\s/g, '') // Remove headers
|
|
65
|
-
.replace(/[*_]{1,2}(.*?)[*_]{1,2}/g, '$1') // Remove bold/italic
|
|
66
|
-
.replace(/\[([^\]]+)\]\([^)]+\)/g, '$1') // Remove links
|
|
67
|
-
.replace(/`([^`]+)`/g, '$1') // Remove inline code
|
|
68
|
-
.trim();
|
|
69
|
-
|
|
70
|
-
const words = text.split(/\s+/);
|
|
71
|
-
const excerpt = words.slice(0, wordLimit).join(' ');
|
|
72
|
-
|
|
73
|
-
return excerpt.length < text.length ? excerpt + '...' : excerpt;
|
|
74
|
-
} catch (error) {
|
|
75
|
-
return '';
|
|
76
|
-
}
|
|
77
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const prerender = true;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import '@fortawesome/fontawesome-free/css/all.min.css';
|
|
3
|
-
import '../app.css';
|
|
4
|
-
|
|
5
|
-
let { children } = $props();
|
|
6
|
-
</script>
|
|
7
|
-
|
|
8
|
-
<svelte:window
|
|
9
|
-
on:resize={() => {
|
|
10
|
-
// Handle window resize if needed
|
|
11
|
-
}}
|
|
12
|
-
/>
|
|
13
|
-
|
|
14
|
-
<div class="app">
|
|
15
|
-
{@render children?.()}
|
|
16
|
-
</div>
|
|
17
|
-
|
|
18
|
-
<style>
|
|
19
|
-
:global(body) {
|
|
20
|
-
margin: 0;
|
|
21
|
-
padding: 0;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.app {
|
|
25
|
-
display: flex;
|
|
26
|
-
flex-direction: column;
|
|
27
|
-
min-height: 100vh;
|
|
28
|
-
}
|
|
29
|
-
</style>
|
package/src/routes/+page.svelte
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { Callout, Tabs, CodeBlock, Image, APITable, Breadcrumbs } from '$lib';
|
|
3
|
-
|
|
4
|
-
const exampleCode = `function greet(name) {
|
|
5
|
-
return \`Hello, \${name}!\`;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
console.log(greet('World'));`;
|
|
9
|
-
|
|
10
|
-
const apiTableColumns = [
|
|
11
|
-
{ key: 'name', label: 'Parameter Name' },
|
|
12
|
-
{ key: 'type', label: 'Type' },
|
|
13
|
-
{ key: 'required', label: 'Required' },
|
|
14
|
-
{ key: 'description', label: 'Description', width: '40%' }
|
|
15
|
-
];
|
|
16
|
-
|
|
17
|
-
const apiTableRows = [
|
|
18
|
-
{
|
|
19
|
-
name: 'variant',
|
|
20
|
-
type: 'string',
|
|
21
|
-
required: false,
|
|
22
|
-
description: 'The callout type: info, warning, success, or error'
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
name: 'title',
|
|
26
|
-
type: 'string',
|
|
27
|
-
required: false,
|
|
28
|
-
description: 'Optional title for the callout'
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
name: 'children',
|
|
32
|
-
type: 'HTMLContent',
|
|
33
|
-
required: true,
|
|
34
|
-
description: 'The content to display inside the callout'
|
|
35
|
-
}
|
|
36
|
-
];
|
|
37
|
-
|
|
38
|
-
const breadcrumbItems = [
|
|
39
|
-
{ label: 'Home', href: '/' },
|
|
40
|
-
{ label: 'Components', href: '/components' },
|
|
41
|
-
{ label: 'Callout' }
|
|
42
|
-
];
|
|
43
|
-
|
|
44
|
-
const tabItems = [
|
|
45
|
-
{ label: 'JavaScript', content: '<code>const x = 42;</code>' },
|
|
46
|
-
{ label: 'Python', content: '<code>x = 42</code>' },
|
|
47
|
-
{ label: 'Rust', content: '<code>let x = 42;</code>' }
|
|
48
|
-
];
|
|
49
|
-
</script>
|
|
50
|
-
|
|
51
|
-
<main class="mx-auto max-w-4xl px-6 py-12">
|
|
52
|
-
<h1 class="mb-2 text-4xl font-bold">Documentation Components</h1>
|
|
53
|
-
<p class="mb-8 text-gray-600">A collection of reusable Svelte components for building beautiful documentation.</p>
|
|
54
|
-
|
|
55
|
-
<!-- Breadcrumbs Section -->
|
|
56
|
-
<section class="mb-12">
|
|
57
|
-
<h2 class="mb-4 text-2xl font-bold">Breadcrumbs Navigation</h2>
|
|
58
|
-
<Breadcrumbs items={breadcrumbItems} />
|
|
59
|
-
</section>
|
|
60
|
-
|
|
61
|
-
<!-- Callout Section -->
|
|
62
|
-
<section class="mb-12">
|
|
63
|
-
<h2 class="mb-4 text-2xl font-bold">Callout Components</h2>
|
|
64
|
-
|
|
65
|
-
<h3 class="mb-3 text-xl font-semibold">Info Callout</h3>
|
|
66
|
-
<Callout variant="info" title="Information">
|
|
67
|
-
This is an informational message to guide users through the documentation.
|
|
68
|
-
</Callout>
|
|
69
|
-
|
|
70
|
-
<h3 class="mb-3 mt-6 text-xl font-semibold">Warning Callout</h3>
|
|
71
|
-
<Callout variant="warning" title="Warning">
|
|
72
|
-
Be careful! This action might have unexpected consequences.
|
|
73
|
-
</Callout>
|
|
74
|
-
|
|
75
|
-
<h3 class="mb-3 mt-6 text-xl font-semibold">Success Callout</h3>
|
|
76
|
-
<Callout variant="success" title="Success">
|
|
77
|
-
Great job! Your configuration has been saved successfully.
|
|
78
|
-
</Callout>
|
|
79
|
-
|
|
80
|
-
<h3 class="mb-3 mt-6 text-xl font-semibold">Error Callout</h3>
|
|
81
|
-
<Callout variant="error" title="Error">
|
|
82
|
-
Something went wrong. Please check your input and try again.
|
|
83
|
-
</Callout>
|
|
84
|
-
</section>
|
|
85
|
-
|
|
86
|
-
<!-- CodeBlock Section -->
|
|
87
|
-
<section class="mb-12">
|
|
88
|
-
<h2 class="mb-4 text-2xl font-bold">Code Block</h2>
|
|
89
|
-
<CodeBlock code={exampleCode} language="javascript" filename="example.js" />
|
|
90
|
-
</section>
|
|
91
|
-
|
|
92
|
-
<!-- Tabs Section -->
|
|
93
|
-
<section class="mb-12">
|
|
94
|
-
<h2 class="mb-4 text-2xl font-bold">Tabs Component</h2>
|
|
95
|
-
<Tabs items={tabItems} />
|
|
96
|
-
</section>
|
|
97
|
-
|
|
98
|
-
<!-- API Table Section -->
|
|
99
|
-
<section class="mb-12">
|
|
100
|
-
<h2 class="mb-4 text-2xl font-bold">API Reference Table</h2>
|
|
101
|
-
<APITable title="Callout Component Props" columns={apiTableColumns} rows={apiTableRows} />
|
|
102
|
-
</section>
|
|
103
|
-
|
|
104
|
-
<!-- Image Section -->
|
|
105
|
-
<section class="mb-12">
|
|
106
|
-
<h2 class="mb-4 text-2xl font-bold">Image Component</h2>
|
|
107
|
-
<Image
|
|
108
|
-
src="https://via.placeholder.com/600x400"
|
|
109
|
-
alt="Example placeholder image"
|
|
110
|
-
caption="This is an example image with a caption"
|
|
111
|
-
zoomable={true}
|
|
112
|
-
/>
|
|
113
|
-
</section>
|
|
114
|
-
</main>
|
|
115
|
-
|
|
116
|
-
<style>
|
|
117
|
-
:global(body) {
|
|
118
|
-
background-color: white;
|
|
119
|
-
color: #333;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
:global(.dark) :global(body) {
|
|
123
|
-
background-color: #030712;
|
|
124
|
-
color: #f3f4f6;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
main {
|
|
128
|
-
max-width: 56rem;
|
|
129
|
-
margin: 0 auto;
|
|
130
|
-
padding: 3rem 1.5rem;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
h1 {
|
|
134
|
-
margin-bottom: 0.5rem;
|
|
135
|
-
font-size: 2.25rem;
|
|
136
|
-
font-weight: 700;
|
|
137
|
-
color: #111827;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
:global(.dark) h1 {
|
|
141
|
-
color: white;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
h2 {
|
|
145
|
-
margin-bottom: 1rem;
|
|
146
|
-
font-size: 1.5rem;
|
|
147
|
-
font-weight: 700;
|
|
148
|
-
color: #111827;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
:global(.dark) h2 {
|
|
152
|
-
color: white;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
h3 {
|
|
156
|
-
margin-bottom: 0.75rem;
|
|
157
|
-
font-size: 1.25rem;
|
|
158
|
-
font-weight: 600;
|
|
159
|
-
color: #111827;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
:global(.dark) h3 {
|
|
163
|
-
color: white;
|
|
164
|
-
}
|
|
165
|
-
</style>
|