@farming-labs/theme 0.2.13 → 0.2.15

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.
@@ -661,6 +661,7 @@ function createDocsLayout(config, options) {
661
661
  const readingTimeOptions = resolveReadingTimeOptions(config.readingTime);
662
662
  const readingTimeEnabledByDefault = readingTimeOptions.enabled;
663
663
  const readingTimeWordsPerMinute = readingTimeOptions.wordsPerMinute ?? 220;
664
+ const readingTimeFormat = readingTimeOptions.format;
664
665
  const llmsTxtEnabled = resolveEnabledByDefault(config.llmsTxt);
665
666
  const feedbackConfig = resolveFeedbackConfig(config.feedback);
666
667
  const openDocsConfig = pageActions?.openDocs && typeof pageActions.openDocs === "object" ? pageActions.openDocs : void 0;
@@ -803,6 +804,7 @@ function createDocsLayout(config, options) {
803
804
  lastUpdatedEnabled,
804
805
  lastUpdatedPosition,
805
806
  readingTimeEnabled,
807
+ readingTimeFormat,
806
808
  readingTimeMap,
807
809
  structuredDataMap,
808
810
  llmsTxtEnabled,
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from "react";
2
- import { DocsFeedbackData } from "@farming-labs/docs";
2
+ import { DocsFeedbackData, ReadingTimeFormat } from "@farming-labs/docs";
3
3
  import * as react_jsx_runtime0 from "react/jsx-runtime";
4
4
 
5
5
  //#region src/docs-page-client.d.ts
@@ -49,6 +49,8 @@ interface DocsPageClientProps {
49
49
  readingTimeMap?: Record<string, number>;
50
50
  /** Direct reading-time override for the current page. */
51
51
  readingTime?: number | null;
52
+ /** Reading-time label style. */
53
+ readingTimeFormat?: ReadingTimeFormat;
52
54
  /** Map of pathname → serialized Schema.org JSON-LD. */
53
55
  structuredDataMap?: Record<string, string>;
54
56
  /** Direct serialized Schema.org JSON-LD override for the current page. */
@@ -103,6 +105,7 @@ declare function DocsPageClient({
103
105
  lastModified: lastModifiedProp,
104
106
  readingTimeMap,
105
107
  readingTime: readingTimeProp,
108
+ readingTimeFormat,
106
109
  structuredDataMap,
107
110
  structuredData: structuredDataProp,
108
111
  readingTimeEnabled,
@@ -198,8 +198,9 @@ function decodeHashTarget(hash) {
198
198
  return value;
199
199
  }
200
200
  }
201
- function formatReadingTimeLabel(minutes) {
202
- return `${Math.max(1, Math.ceil(minutes))} min read`;
201
+ function formatReadingTimeLabel(minutes, format = "long") {
202
+ const normalized = Math.max(1, Math.ceil(minutes));
203
+ return format === "short" ? `${normalized} min` : `${normalized} min read`;
203
204
  }
204
205
  function escapeIdSelector(value) {
205
206
  if (typeof CSS !== "undefined" && typeof CSS.escape === "function") return CSS.escape(value);
@@ -254,7 +255,7 @@ function findThreadlineTocActionsContainer() {
254
255
  }
255
256
  return toc.parentElement ?? toc;
256
257
  }
257
- function DocsPageClient({ tocEnabled, tocStyle = "default", breadcrumbEnabled = true, changelogBasePath, entry = "docs", publicPath, locale, copyMarkdown = false, openDocs = false, openDocsProviders, openDocsTarget, openDocsPrompt, pageActionsPosition = "below-title", pageActionsAlignment = "left", githubUrl, contentDir, githubBranch = "main", githubDirectory, editOnGithubUrl, lastModifiedMap, lastModified: lastModifiedProp, readingTimeMap, readingTime: readingTimeProp, structuredDataMap, structuredData: structuredDataProp, readingTimeEnabled = false, lastUpdatedEnabled = true, lastUpdatedPosition = "footer", llmsTxtEnabled = false, descriptionMap, description, feedbackEnabled = false, feedbackQuestion, feedbackPlaceholder, feedbackPositiveLabel, feedbackNegativeLabel, feedbackSubmitLabel, feedbackOnFeedback, analytics = false, children }) {
258
+ function DocsPageClient({ tocEnabled, tocStyle = "default", breadcrumbEnabled = true, changelogBasePath, entry = "docs", publicPath, locale, copyMarkdown = false, openDocs = false, openDocsProviders, openDocsTarget, openDocsPrompt, pageActionsPosition = "below-title", pageActionsAlignment = "left", githubUrl, contentDir, githubBranch = "main", githubDirectory, editOnGithubUrl, lastModifiedMap, lastModified: lastModifiedProp, readingTimeMap, readingTime: readingTimeProp, readingTimeFormat = "long", structuredDataMap, structuredData: structuredDataProp, readingTimeEnabled = false, lastUpdatedEnabled = true, lastUpdatedPosition = "footer", llmsTxtEnabled = false, descriptionMap, description, feedbackEnabled = false, feedbackQuestion, feedbackPlaceholder, feedbackPositiveLabel, feedbackNegativeLabel, feedbackSubmitLabel, feedbackOnFeedback, analytics = false, children }) {
258
259
  const fdTocStyle = tocStyle === "directional" ? "clerk" : void 0;
259
260
  const [toc, setToc] = useState([]);
260
261
  const [titlePortalHost, setTitlePortalHost] = useState(null);
@@ -442,7 +443,7 @@ function DocsPageClient({ tocEnabled, tocStyle = "default", breadcrumbEnabled =
442
443
  children: "·"
443
444
  }), /* @__PURE__ */ jsx("span", {
444
445
  className: "fd-page-meta-item",
445
- children: formatReadingTimeLabel(resolvedReadingTime)
446
+ children: formatReadingTimeLabel(resolvedReadingTime, readingTimeFormat)
446
447
  })]
447
448
  }, "reading-time") : void 0;
448
449
  const titleDescription = pageDescription ? /* @__PURE__ */ jsx("p", {
@@ -16,12 +16,22 @@ function estimateReadingTimeMinutes(content, wordsPerMinute) {
16
16
  return Math.max(1, Math.ceil(wordCount / normalizeWordsPerMinute(wordsPerMinute)));
17
17
  }
18
18
  function resolveReadingTimeOptions(readingTime) {
19
- if (readingTime === true) return { enabled: true };
20
- if (readingTime === false || readingTime === void 0 || readingTime === null) return { enabled: false };
21
- if (typeof readingTime !== "object") return { enabled: false };
19
+ if (readingTime === true) return {
20
+ enabled: true,
21
+ format: "long"
22
+ };
23
+ if (readingTime === false || readingTime === void 0 || readingTime === null) return {
24
+ enabled: false,
25
+ format: "long"
26
+ };
27
+ if (typeof readingTime !== "object") return {
28
+ enabled: false,
29
+ format: "long"
30
+ };
22
31
  return {
23
32
  enabled: readingTime.enabled !== false,
24
- wordsPerMinute: typeof readingTime.wordsPerMinute === "number" && Number.isFinite(readingTime.wordsPerMinute) ? readingTime.wordsPerMinute : void 0
33
+ wordsPerMinute: typeof readingTime.wordsPerMinute === "number" && Number.isFinite(readingTime.wordsPerMinute) ? readingTime.wordsPerMinute : void 0,
34
+ format: readingTime.format === "short" ? "short" : "long"
25
35
  };
26
36
  }
27
37
  function resolveReadingTimeFromContent(frontmatter, content, wordsPerMinute) {
@@ -244,7 +244,8 @@ function TanstackDocsLayout({ config, tree, locale, description, readingTime, la
244
244
  const lastUpdatedRaw = config.lastUpdated;
245
245
  const lastUpdatedEnabled = lastUpdatedRaw !== false && (typeof lastUpdatedRaw !== "object" || lastUpdatedRaw.enabled !== false);
246
246
  const lastUpdatedPosition = typeof lastUpdatedRaw === "object" ? lastUpdatedRaw.position ?? "footer" : "footer";
247
- const readingTimeEnabled = resolveReadingTimeOptions(config.readingTime).enabled;
247
+ const readingTimeOptions = resolveReadingTimeOptions(config.readingTime);
248
+ const readingTimeEnabled = readingTimeOptions.enabled;
248
249
  const llmsTxtEnabled = resolveEnabledByDefault(config.llmsTxt);
249
250
  const feedbackConfig = resolveFeedbackConfig(config.feedback);
250
251
  const staticExport = !!config.staticExport;
@@ -364,6 +365,7 @@ function TanstackDocsLayout({ config, tree, locale, description, readingTime, la
364
365
  lastUpdatedPosition,
365
366
  lastModified,
366
367
  readingTimeEnabled,
368
+ readingTimeFormat: readingTimeOptions.format,
367
369
  readingTime: typeof readingTime === "number" ? readingTime : void 0,
368
370
  llmsTxtEnabled,
369
371
  description,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farming-labs/theme",
3
- "version": "0.2.13",
3
+ "version": "0.2.15",
4
4
  "description": "Theme package for @farming-labs/docs — layout, provider, MDX components, and styles",
5
5
  "keywords": [
6
6
  "docs",
@@ -145,7 +145,7 @@
145
145
  "tsdown": "^0.20.3",
146
146
  "typescript": "^5.9.3",
147
147
  "vitest": "^4.1.8",
148
- "@farming-labs/docs": "0.2.13"
148
+ "@farming-labs/docs": "0.2.15"
149
149
  },
150
150
  "peerDependencies": {
151
151
  "@farming-labs/docs": ">=0.0.1",