@farming-labs/theme 0.1.131 → 0.1.133

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 (2) hide show
  1. package/dist/docs-api.mjs +18 -4
  2. package/package.json +2 -2
package/dist/docs-api.mjs CHANGED
@@ -3,7 +3,7 @@ import { getNextAppDir } from "./get-app-dir.mjs";
3
3
  import fs from "node:fs";
4
4
  import path from "node:path";
5
5
  import matter from "gray-matter";
6
- import { DEFAULT_SITEMAP_MD_DOCS_ROUTE, buildDocsAskAIContext, createDocsAgentTraceContext, createDocsAgentTraceId, createDocsRobotsResponse, createDocsSitemapResponse, detectDocsMarkdownAgentRequest, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, formatDocsAskAIPackageHints, getDocsLlmsTxtMaxCharsIssue, getDocsMarkdownVaryHeader, hasDocsMarkdownSignatureAgent, normalizeDocsRelated, performDocsSearch, renderDocsLlmsTxt, renderDocsMarkdownDocument, renderDocsMarkdownNotFound, resolveAskAISearchRequestConfig, resolveChangelogConfig, resolveDocsI18n, resolveDocsLlmsTxtRequest, resolveDocsLlmsTxtSections, resolveDocsLocale, resolveDocsMarkdownRecovery, resolveDocsSitemapConfig, resolvePageSidebarFolderIndexBehavior, resolveSearchRequestConfig, selectDocsLlmsTxtContent } from "@farming-labs/docs";
6
+ import { DEFAULT_SITEMAP_MD_DOCS_ROUTE, buildDocsAskAIContext, createDocsAgentTraceContext, createDocsAgentTraceId, createDocsRobotsResponse, createDocsSitemapResponse, detectDocsMarkdownAgentRequest, emitDocsAgentTraceEvent, emitDocsAnalyticsEvent, formatDocsAskAIPackageHints, getDocsLlmsTxtMaxCharsIssue, getDocsMarkdownVaryHeader, hasDocsMarkdownSignatureAgent, normalizeDocsRelated, performDocsSearch, renderDocsLlmsTxt, renderDocsMarkdownDocument, renderDocsMarkdownNotFound, resolveAskAISearchRequestConfig, resolveChangelogConfig, resolveDocsI18n, resolveDocsLlmsTxtRequest, resolveDocsLlmsTxtSections, resolveDocsLocale, resolveDocsMarkdownRecovery, resolveDocsMetadataBaseUrl, resolveDocsSitemapConfig, resolvePageSidebarFolderIndexBehavior, resolveSearchRequestConfig, selectDocsLlmsTxtContent } from "@farming-labs/docs";
7
7
  import { buildApiReferenceOpenApiDocumentAsync, createDocsMcpHttpHandler, createFilesystemDocsMcpSource, readDocsSitemapManifest, resolveApiReferenceConfig, resolveDocsMcpConfig } from "@farming-labs/docs/server";
8
8
 
9
9
  //#region src/docs-api.ts
@@ -1121,6 +1121,7 @@ function resolvePublicMarkdownRequest(entry, docsPath, url, request) {
1121
1121
  function renderMarkdownDocument(page, options = {}) {
1122
1122
  return renderDocsMarkdownDocument(page, {
1123
1123
  llms: options.llmsEnabled !== false,
1124
+ origin: options.origin,
1124
1125
  sitemap: options.sitemap
1125
1126
  });
1126
1127
  }
@@ -1913,6 +1914,14 @@ function createDocsAPI(options) {
1913
1914
  const llmsConfig = resolveLlmsTxtConfig(options?.llmsTxt, readLlmsTxtConfig(root));
1914
1915
  const sitemapConfig = options?.sitemap ?? readSitemapConfig(root);
1915
1916
  const robotsConfig = options?.robots ?? readRobotsConfig(root);
1917
+ const markdownMetadataBaseUrl = resolveDocsMetadataBaseUrl({
1918
+ ...options,
1919
+ entry,
1920
+ ai: aiConfig,
1921
+ llmsTxt: llmsConfig,
1922
+ sitemap: sitemapConfig,
1923
+ robots: robotsConfig
1924
+ });
1916
1925
  const apiReferenceConfig = options?.apiReference ?? readApiReferenceConfig(root);
1917
1926
  const apiReferenceDocsConfig = {
1918
1927
  ...options,
@@ -2015,7 +2024,7 @@ function createDocsAPI(options) {
2015
2024
  markdownSourcesByLocale.set(key, sources);
2016
2025
  return sources;
2017
2026
  }
2018
- async function getMarkdownDocument(ctx, requestedPath) {
2027
+ async function getMarkdownDocument(ctx, requestedPath, origin) {
2019
2028
  const normalizedRequest = normalizeRequestedMarkdownPath(ctx.entryPath, requestedPath);
2020
2029
  const normalizedPublicRequest = normalizePublicRequestedMarkdownPath(ctx, requestedPath);
2021
2030
  const normalizedEntry = `/${normalizePathSegment(ctx.entryPath)}`;
@@ -2025,6 +2034,7 @@ function createDocsAPI(options) {
2025
2034
  const page = findDocsMcpPage(ctx.entryPath, await source.getPages(), requestedPath);
2026
2035
  if (page) return renderMarkdownDocument(withPublicDocsUrl(page, ctx), {
2027
2036
  llmsEnabled: llmsConfig.enabled,
2037
+ origin,
2028
2038
  sitemap: sitemapConfig
2029
2039
  });
2030
2040
  }
@@ -2034,11 +2044,13 @@ function createDocsAPI(options) {
2034
2044
  });
2035
2045
  if (fallbackPage) return renderMarkdownDocument(withPublicDocsUrl(fallbackPage, ctx), {
2036
2046
  llmsEnabled: llmsConfig.enabled,
2047
+ origin,
2037
2048
  sitemap: sitemapConfig
2038
2049
  });
2039
2050
  const requestedSlug = normalizePublicDocsSlug(ctx, normalizedPublicRequest);
2040
2051
  for (const page of getIndexes(ctx)) if (normalizePublicDocsSlug(ctx, page.url) === requestedSlug) return renderMarkdownDocument(withPublicDocsUrl(page, ctx), {
2041
2052
  llmsEnabled: llmsConfig.enabled,
2053
+ origin,
2042
2054
  sitemap: sitemapConfig
2043
2055
  });
2044
2056
  return null;
@@ -2197,10 +2209,11 @@ function createDocsAPI(options) {
2197
2209
  if (sitemapResponse) return sitemapResponse;
2198
2210
  const markdownRequest = resolveMarkdownRequest(entry, url, request) ?? resolvePublicMarkdownRequest(entry, docsPath, url, request);
2199
2211
  if (markdownRequest) {
2200
- const document = await getMarkdownDocument(ctx, markdownRequest.requestedPath);
2212
+ const markdownOrigin = markdownMetadataBaseUrl || url.origin;
2213
+ const document = await getMarkdownDocument(ctx, markdownRequest.requestedPath, markdownOrigin);
2201
2214
  const varyHeader = getDocsMarkdownVaryHeader(request);
2202
2215
  const canonicalLinkHeader = getPublicMarkdownCanonicalLinkHeader({
2203
- origin: url.origin,
2216
+ origin: markdownOrigin,
2204
2217
  ctx,
2205
2218
  requestedPath: markdownRequest.requestedPath
2206
2219
  });
@@ -2247,6 +2260,7 @@ function createDocsAPI(options) {
2247
2260
  return new Response(renderDocsMarkdownNotFound({
2248
2261
  entry,
2249
2262
  requestedPath: markdownRequest.requestedPath,
2263
+ origin: markdownOrigin,
2250
2264
  pages: recoveryPages,
2251
2265
  sitemap: sitemapConfig
2252
2266
  }), {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farming-labs/theme",
3
- "version": "0.1.131",
3
+ "version": "0.1.133",
4
4
  "description": "Theme package for @farming-labs/docs — layout, provider, MDX components, and styles",
5
5
  "keywords": [
6
6
  "docs",
@@ -139,7 +139,7 @@
139
139
  "tsdown": "^0.20.3",
140
140
  "typescript": "^5.9.3",
141
141
  "vitest": "^3.2.4",
142
- "@farming-labs/docs": "0.1.131"
142
+ "@farming-labs/docs": "0.1.133"
143
143
  },
144
144
  "peerDependencies": {
145
145
  "@farming-labs/docs": ">=0.0.1",