@farming-labs/svelte 0.0.2-beta.21 → 0.0.2-beta.22
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/content.js +1 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/markdown.js +2 -7
- package/dist/server.js +8 -10
- package/package.json +13 -13
package/dist/content.js
CHANGED
|
@@ -35,9 +35,7 @@ export function loadDocsContent(contentDir, entry = "docs") {
|
|
|
35
35
|
const { data, content } = matter(raw);
|
|
36
36
|
const baseName = name.replace(/\.(md|mdx|svx)$/, "");
|
|
37
37
|
const isIndex = baseName === "index" || baseName === "page" || baseName === "+page";
|
|
38
|
-
const slug = isIndex
|
|
39
|
-
? slugParts.join("/")
|
|
40
|
-
: [...slugParts, baseName].join("/");
|
|
38
|
+
const slug = isIndex ? slugParts.join("/") : [...slugParts, baseName].join("/");
|
|
41
39
|
const url = slug ? `/${entry}/${slug}` : `/${entry}`;
|
|
42
40
|
const title = data.title ??
|
|
43
41
|
baseName.replace(/-/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Provides content loading, navigation tree building, search,
|
|
6
6
|
* and server-side markdown rendering for SvelteKit-based documentation sites.
|
|
7
7
|
*/
|
|
8
|
-
export { loadDocsContent, loadDocsNavTree, flattenNavTree, type NavNode, type NavTree, type PageNode, type FolderNode } from "./content.js";
|
|
8
|
+
export { loadDocsContent, loadDocsNavTree, flattenNavTree, type NavNode, type NavTree, type PageNode, type FolderNode, } from "./content.js";
|
|
9
9
|
export { createMdsvexConfig } from "./config.js";
|
|
10
10
|
export { renderMarkdown } from "./markdown.js";
|
|
11
11
|
export { createDocsServer, type DocsServer } from "./server.js";
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Provides content loading, navigation tree building, search,
|
|
6
6
|
* and server-side markdown rendering for SvelteKit-based documentation sites.
|
|
7
7
|
*/
|
|
8
|
-
export { loadDocsContent, loadDocsNavTree, flattenNavTree } from "./content.js";
|
|
8
|
+
export { loadDocsContent, loadDocsNavTree, flattenNavTree, } from "./content.js";
|
|
9
9
|
export { createMdsvexConfig } from "./config.js";
|
|
10
10
|
export { renderMarkdown } from "./markdown.js";
|
|
11
11
|
export { createDocsServer } from "./server.js";
|
package/dist/markdown.js
CHANGED
|
@@ -74,10 +74,7 @@ function highlightCode(hl, code, lang) {
|
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
76
|
catch {
|
|
77
|
-
const escaped = trimmedCode
|
|
78
|
-
.replace(/&/g, "&")
|
|
79
|
-
.replace(/</g, "<")
|
|
80
|
-
.replace(/>/g, ">");
|
|
77
|
+
const escaped = trimmedCode.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
81
78
|
return {
|
|
82
79
|
html: `<pre class="shiki"><code>${escaped}</code></pre>`,
|
|
83
80
|
raw: trimmedCode,
|
|
@@ -128,9 +125,7 @@ export async function renderMarkdown(content) {
|
|
|
128
125
|
// ── Tabs blocks: <Tabs items={[...]}> ... </Tabs> ──
|
|
129
126
|
const tabsBlocks = [];
|
|
130
127
|
result = result.replace(/<Tabs\s+items=\{?\[([^\]]+)\]\}?>([\s\S]*?)<\/Tabs>/g, (_, itemsStr, body) => {
|
|
131
|
-
const items = itemsStr
|
|
132
|
-
.split(",")
|
|
133
|
-
.map((s) => s.trim().replace(/^["']|["']$/g, ""));
|
|
128
|
+
const items = itemsStr.split(",").map((s) => s.trim().replace(/^["']|["']$/g, ""));
|
|
134
129
|
const panels = [];
|
|
135
130
|
const tabRegex = /<Tab\s+value=["']([^"']+)["']>([\s\S]*?)<\/Tab>/g;
|
|
136
131
|
let tabMatch;
|
package/dist/server.js
CHANGED
|
@@ -65,9 +65,7 @@ function navTreeFromMap(contentMap, dirPrefix, entry, ordering) {
|
|
|
65
65
|
const slug = dirParts.join("/");
|
|
66
66
|
const url = slug ? `/${entry}/${slug}` : `/${entry}`;
|
|
67
67
|
const fallbackTitle = dirParts.length > 0
|
|
68
|
-
? dirParts[dirParts.length - 1]
|
|
69
|
-
.replace(/-/g, " ")
|
|
70
|
-
.replace(/\b\w/g, (c) => c.toUpperCase())
|
|
68
|
+
? dirParts[dirParts.length - 1].replace(/-/g, " ").replace(/\b\w/g, (c) => c.toUpperCase())
|
|
71
69
|
: "Documentation";
|
|
72
70
|
dirs.push({
|
|
73
71
|
parts: dirParts,
|
|
@@ -206,8 +204,7 @@ function searchIndexFromMap(contentMap, dirPrefix, entry) {
|
|
|
206
204
|
const slug = isIdx ? segments.join("/") : [...segments, base].join("/");
|
|
207
205
|
const url = slug ? `/${entry}/${slug}` : `/${entry}`;
|
|
208
206
|
const { data, content } = matter(raw);
|
|
209
|
-
const title = data.title ??
|
|
210
|
-
base.replace(/-/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
|
|
207
|
+
const title = data.title ?? base.replace(/-/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
|
|
211
208
|
pages.push({
|
|
212
209
|
slug,
|
|
213
210
|
url,
|
|
@@ -252,9 +249,7 @@ function findPageInMap(contentMap, dirPrefix, slug) {
|
|
|
252
249
|
export function createDocsServer(config = {}) {
|
|
253
250
|
const entry = config.entry ?? "docs";
|
|
254
251
|
const githubRaw = config.github;
|
|
255
|
-
const github = typeof githubRaw === "string"
|
|
256
|
-
? { url: githubRaw }
|
|
257
|
-
: githubRaw ?? null;
|
|
252
|
+
const github = typeof githubRaw === "string" ? { url: githubRaw } : (githubRaw ?? null);
|
|
258
253
|
const githubRepo = github?.url;
|
|
259
254
|
const githubBranch = github?.branch ?? "main";
|
|
260
255
|
const githubContentPath = github?.directory;
|
|
@@ -350,7 +345,7 @@ export function createDocsServer(config = {}) {
|
|
|
350
345
|
}
|
|
351
346
|
const fallbackTitle = isIndex
|
|
352
347
|
? "Documentation"
|
|
353
|
-
: slug.split("/").pop()?.replace(/-/g, " ") ?? "Documentation";
|
|
348
|
+
: (slug.split("/").pop()?.replace(/-/g, " ") ?? "Documentation");
|
|
354
349
|
return {
|
|
355
350
|
tree,
|
|
356
351
|
flatPages,
|
|
@@ -456,7 +451,10 @@ export function createDocsServer(config = {}) {
|
|
|
456
451
|
}
|
|
457
452
|
const lastUserMessage = [...messages].reverse().find((m) => m.role === "user");
|
|
458
453
|
if (!lastUserMessage) {
|
|
459
|
-
return new Response(JSON.stringify({ error: "At least one user message is required." }), {
|
|
454
|
+
return new Response(JSON.stringify({ error: "At least one user message is required." }), {
|
|
455
|
+
status: 400,
|
|
456
|
+
headers: { "Content-Type": "application/json" },
|
|
457
|
+
});
|
|
460
458
|
}
|
|
461
459
|
const maxResults = aiConfig.maxResults ?? 5;
|
|
462
460
|
const scored = searchByQuery(lastUserMessage.content.toLowerCase()).slice(0, maxResults);
|
package/package.json
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farming-labs/svelte",
|
|
3
|
-
"version": "0.0.2-beta.
|
|
3
|
+
"version": "0.0.2-beta.22",
|
|
4
4
|
"description": "SvelteKit adapter for @farming-labs/docs — content loading and navigation utilities",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"docs",
|
|
7
|
+
"documentation",
|
|
8
|
+
"svelte",
|
|
9
|
+
"sveltekit"
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"author": "Farming Labs",
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
5
16
|
"type": "module",
|
|
6
17
|
"main": "./dist/index.js",
|
|
7
18
|
"types": "./dist/index.d.ts",
|
|
@@ -32,17 +43,6 @@
|
|
|
32
43
|
"default": "./dist/server.js"
|
|
33
44
|
}
|
|
34
45
|
},
|
|
35
|
-
"files": [
|
|
36
|
-
"dist"
|
|
37
|
-
],
|
|
38
|
-
"keywords": [
|
|
39
|
-
"docs",
|
|
40
|
-
"svelte",
|
|
41
|
-
"sveltekit",
|
|
42
|
-
"documentation"
|
|
43
|
-
],
|
|
44
|
-
"author": "Farming Labs",
|
|
45
|
-
"license": "MIT",
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"gray-matter": "^4.0.3",
|
|
48
48
|
"shiki": "^3.2.1"
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/node": "^22.10.0",
|
|
52
52
|
"typescript": "^5.9.3",
|
|
53
|
-
"@farming-labs/docs": "0.0.2-beta.
|
|
53
|
+
"@farming-labs/docs": "0.0.2-beta.22"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"@farming-labs/docs": "*"
|