@farming-labs/svelte 0.1.84 → 0.1.86
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/server.d.ts +1 -0
- package/dist/server.js +26 -8
- package/package.json +2 -2
package/dist/server.d.ts
CHANGED
package/dist/server.js
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
import fs from "node:fs";
|
|
31
31
|
import path from "node:path";
|
|
32
32
|
import matter from "gray-matter";
|
|
33
|
-
import { applySidebarFolderIndexBehavior, buildDocsAskAIContext, buildDocsAgentDiscoverySpec, createDocsSitemapResponse, createDocsAgentTraceContext, createDocsAgentTraceId, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, formatDocsAskAIPackageHints, findDocsMarkdownPage, getDocsMarkdownVaryHeader, isDocsAgentDiscoveryRequest, isDocsSkillRequest, normalizeDocsRelated, performDocsSearch, renderDocsMarkdownDocument, renderDocsMarkdownNotFound, renderDocsSkillDocument, readDocsSitemapManifestFromContentMap, stripGeneratedAgentProvenance, resolveDocsAgentMdxContent, resolvePageSidebarFolderIndexBehavior, resolveAskAISearchRequestConfig, resolveSearchRequestConfig, resolveDocsI18n, resolveDocsLlmsTxtFormat, resolveDocsLocale, resolveDocsMarkdownRequest, resolveDocsPath, resolvePageReadingTime, resolveReadingTimeOptions, resolveDocsSkillFormat, } from "@farming-labs/docs";
|
|
33
|
+
import { applySidebarFolderIndexBehavior, buildDocsAskAIContext, buildDocsAgentDiscoverySpec, createDocsSitemapResponse, createDocsAgentTraceContext, createDocsAgentTraceId, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, formatDocsAskAIPackageHints, findDocsMarkdownPage, getDocsMarkdownVaryHeader, isDocsAgentDiscoveryRequest, isDocsSkillRequest, normalizeDocsRelated, performDocsSearch, renderDocsMarkdownDocument, renderDocsMarkdownNotFound, renderDocsSkillDocument, readDocsSitemapManifestFromContentMap, stripGeneratedAgentProvenance, resolveDocsAgentMdxContent, resolvePageSidebarFolderIndexBehavior, resolveAskAISearchRequestConfig, resolveSearchRequestConfig, resolveDocsI18n, resolveDocsLlmsTxtFormat, resolveDocsLocale, resolveDocsMarkdownRequest, resolveDocsMetadataBaseUrl, resolveDocsPath, resolvePageReadingTime, resolveReadingTimeOptions, resolveDocsSitemapPageLastmod, resolveDocsSkillFormat, renderDocsPageStructuredDataJson, toDocsMarkdownUrl, } from "@farming-labs/docs";
|
|
34
34
|
import { createDocsMcpHttpHandler, readDocsSitemapManifest, resolveDocsMcpConfig, serializeDocsIconRegistry, serializeOpenDocsProviders, } from "@farming-labs/docs/server";
|
|
35
35
|
import { loadDocsNavTree, loadDocsContent, flattenNavTree } from "./content.js";
|
|
36
36
|
import { renderMarkdown } from "./markdown.js";
|
|
@@ -365,6 +365,7 @@ export function createDocsServer(config = {}) {
|
|
|
365
365
|
const preloaded = rawPreloaded
|
|
366
366
|
? Object.fromEntries(Object.entries(rawPreloaded).map(([k, v]) => [k.startsWith("/") ? k : `/${k}`, v]))
|
|
367
367
|
: undefined;
|
|
368
|
+
const preloadedSitemapManifest = readDocsSitemapManifestFromContentMap(preloaded);
|
|
368
369
|
const ordering = config.ordering;
|
|
369
370
|
const aiConfig = config.ai ?? {};
|
|
370
371
|
// Allow top-level apiKey as a shorthand
|
|
@@ -432,9 +433,11 @@ export function createDocsServer(config = {}) {
|
|
|
432
433
|
const flatPages = flattenNavTree(tree);
|
|
433
434
|
const slug = ctx.slug;
|
|
434
435
|
const isIndex = slug === "";
|
|
436
|
+
const currentUrl = isIndex ? `/${entry}` : `/${entry}/${slug}`;
|
|
435
437
|
let raw;
|
|
436
438
|
let relPath;
|
|
437
439
|
let lastModified;
|
|
440
|
+
let lastModifiedIso;
|
|
438
441
|
if (preloaded) {
|
|
439
442
|
const result = findPageInMap(preloaded, ctx.dirPrefix, slug);
|
|
440
443
|
if (!result) {
|
|
@@ -444,11 +447,16 @@ export function createDocsServer(config = {}) {
|
|
|
444
447
|
}
|
|
445
448
|
raw = result.raw;
|
|
446
449
|
relPath = result.relPath;
|
|
447
|
-
|
|
450
|
+
const manifestLastmod = resolveDocsSitemapPageLastmod(preloadedSitemapManifest, currentUrl);
|
|
451
|
+
const lastModifiedDate = manifestLastmod
|
|
452
|
+
? new Date(`${manifestLastmod}T00:00:00`)
|
|
453
|
+
: new Date();
|
|
454
|
+
lastModified = lastModifiedDate.toLocaleDateString("en-US", {
|
|
448
455
|
year: "numeric",
|
|
449
456
|
month: "long",
|
|
450
457
|
day: "numeric",
|
|
451
458
|
});
|
|
459
|
+
lastModifiedIso = manifestLastmod ? `${manifestLastmod}T00:00:00.000Z` : undefined;
|
|
452
460
|
}
|
|
453
461
|
else {
|
|
454
462
|
let filePath = null;
|
|
@@ -487,6 +495,7 @@ export function createDocsServer(config = {}) {
|
|
|
487
495
|
}
|
|
488
496
|
raw = fs.readFileSync(filePath, "utf-8");
|
|
489
497
|
const stat = fs.statSync(filePath);
|
|
498
|
+
lastModifiedIso = stat.mtime.toISOString();
|
|
490
499
|
lastModified = stat.mtime.toLocaleDateString("en-US", {
|
|
491
500
|
year: "numeric",
|
|
492
501
|
month: "long",
|
|
@@ -506,7 +515,6 @@ export function createDocsServer(config = {}) {
|
|
|
506
515
|
? config.pageActions.openDocs.providers
|
|
507
516
|
: undefined),
|
|
508
517
|
});
|
|
509
|
-
const currentUrl = isIndex ? `/${entry}` : `/${entry}/${slug}`;
|
|
510
518
|
const currentIndex = flatPages.findIndex((p) => p.url === currentUrl);
|
|
511
519
|
const previousPage = currentIndex > 0 ? flatPages[currentIndex - 1] : null;
|
|
512
520
|
const nextPage = currentIndex < flatPages.length - 1 ? flatPages[currentIndex + 1] : null;
|
|
@@ -519,12 +527,22 @@ export function createDocsServer(config = {}) {
|
|
|
519
527
|
const fallbackTitle = isIndex
|
|
520
528
|
? "Documentation"
|
|
521
529
|
: (slug.split("/").pop()?.replace(/-/g, " ") ?? "Documentation");
|
|
530
|
+
const title = data.title ?? fallbackTitle;
|
|
531
|
+
const description = data.description;
|
|
532
|
+
const structuredData = renderDocsPageStructuredDataJson({
|
|
533
|
+
title,
|
|
534
|
+
description,
|
|
535
|
+
url: currentUrl,
|
|
536
|
+
baseUrl: resolveDocsMetadataBaseUrl(config),
|
|
537
|
+
entry,
|
|
538
|
+
dateModified: lastModifiedIso,
|
|
539
|
+
});
|
|
522
540
|
return {
|
|
523
541
|
tree,
|
|
524
542
|
flatPages,
|
|
525
543
|
url: currentUrl,
|
|
526
|
-
title
|
|
527
|
-
description
|
|
544
|
+
title,
|
|
545
|
+
description,
|
|
528
546
|
html,
|
|
529
547
|
readingTime,
|
|
530
548
|
entry,
|
|
@@ -534,6 +552,7 @@ export function createDocsServer(config = {}) {
|
|
|
534
552
|
nextPage,
|
|
535
553
|
editOnGithub,
|
|
536
554
|
lastModified,
|
|
555
|
+
structuredData,
|
|
537
556
|
};
|
|
538
557
|
}
|
|
539
558
|
// ─── Search index ──────────────────────────────────────────
|
|
@@ -578,7 +597,7 @@ export function createDocsServer(config = {}) {
|
|
|
578
597
|
}
|
|
579
598
|
llmsTxt += `## Pages\n\n`;
|
|
580
599
|
for (const page of pages) {
|
|
581
|
-
llmsTxt += `- [${page.title}](${llmsBaseUrl}${page.url})`;
|
|
600
|
+
llmsTxt += `- [${page.title}](${llmsBaseUrl}${toDocsMarkdownUrl(page.url)})`;
|
|
582
601
|
if (page.description)
|
|
583
602
|
llmsTxt += `: ${page.description}`;
|
|
584
603
|
llmsTxt += `\n`;
|
|
@@ -665,8 +684,7 @@ export function createDocsServer(config = {}) {
|
|
|
665
684
|
siteTitle: llmsTitle,
|
|
666
685
|
baseUrl: llmsBaseUrl || event.url.origin,
|
|
667
686
|
pages: getSearchIndex(ctx),
|
|
668
|
-
manifest:
|
|
669
|
-
readDocsSitemapManifest(rootDir, config.sitemap),
|
|
687
|
+
manifest: preloadedSitemapManifest ?? readDocsSitemapManifest(rootDir, config.sitemap),
|
|
670
688
|
});
|
|
671
689
|
if (sitemapResponse)
|
|
672
690
|
return sitemapResponse;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farming-labs/svelte",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.86",
|
|
4
4
|
"description": "SvelteKit adapter for @farming-labs/docs — content loading and navigation utilities",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"docs",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@types/node": "^22.10.0",
|
|
58
58
|
"typescript": "^5.9.3",
|
|
59
|
-
"@farming-labs/docs": "0.1.
|
|
59
|
+
"@farming-labs/docs": "0.1.86"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"@farming-labs/docs": "*"
|