@farming-labs/theme 0.2.14 → 0.2.16
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/docs-feedback.d.mts +2 -0
- package/dist/docs-feedback.mjs +6 -3
- package/dist/docs-layout.mjs +9 -1
- package/dist/docs-page-client.d.mts +10 -1
- package/dist/docs-page-client.mjs +12 -4
- package/dist/page-actions.d.mts +4 -0
- package/dist/page-actions.mjs +3 -3
- package/dist/reading-time.mjs +14 -4
- package/dist/tanstack-layout.mjs +10 -2
- package/package.json +2 -2
package/dist/docs-feedback.d.mts
CHANGED
|
@@ -8,6 +8,7 @@ interface DocsFeedbackProps {
|
|
|
8
8
|
locale?: string;
|
|
9
9
|
question?: string;
|
|
10
10
|
placeholder?: string;
|
|
11
|
+
requireComment?: boolean;
|
|
11
12
|
positiveLabel?: string;
|
|
12
13
|
negativeLabel?: string;
|
|
13
14
|
submitLabel?: string;
|
|
@@ -20,6 +21,7 @@ declare function DocsFeedback({
|
|
|
20
21
|
locale,
|
|
21
22
|
question,
|
|
22
23
|
placeholder,
|
|
24
|
+
requireComment,
|
|
23
25
|
positiveLabel,
|
|
24
26
|
negativeLabel,
|
|
25
27
|
submitLabel,
|
package/dist/docs-feedback.mjs
CHANGED
|
@@ -116,12 +116,13 @@ function CheckIcon() {
|
|
|
116
116
|
})
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
|
-
function DocsFeedback({ pathname, entry, locale, question = "How is this guide?", placeholder = "Leave your feedback...", positiveLabel = "Good", negativeLabel = "Bad", submitLabel = "Submit", onFeedback, analytics = false }) {
|
|
119
|
+
function DocsFeedback({ pathname, entry, locale, question = "How is this guide?", placeholder = "Leave your feedback...", requireComment = false, positiveLabel = "Good", negativeLabel = "Bad", submitLabel = "Submit", onFeedback, analytics = false }) {
|
|
120
120
|
const [selected, setSelected] = useState(null);
|
|
121
121
|
const [comment, setComment] = useState("");
|
|
122
122
|
const [status, setStatus] = useState("idle");
|
|
123
123
|
const normalizedPathname = useMemo(() => normalizePathname(pathname), [pathname]);
|
|
124
124
|
const showForm = selected !== null;
|
|
125
|
+
const commentRequired = requireComment && comment.trim().length === 0;
|
|
125
126
|
const submitButtonLabel = status === "submitted" ? "Submitted" : submitLabel;
|
|
126
127
|
useEffect(() => {
|
|
127
128
|
setSelected(null);
|
|
@@ -151,7 +152,7 @@ function DocsFeedback({ pathname, entry, locale, question = "How is this guide?"
|
|
|
151
152
|
}
|
|
152
153
|
}
|
|
153
154
|
async function handleSubmit() {
|
|
154
|
-
if (!selected || status === "submitting") return;
|
|
155
|
+
if (!selected || status === "submitting" || commentRequired) return;
|
|
155
156
|
setStatus("submitting");
|
|
156
157
|
const payload = buildFeedbackPayload(selected, normalizedPathname, entry, comment, locale);
|
|
157
158
|
try {
|
|
@@ -221,6 +222,8 @@ function DocsFeedback({ pathname, entry, locale, question = "How is this guide?"
|
|
|
221
222
|
className: "fd-feedback-input",
|
|
222
223
|
"aria-label": "Additional feedback",
|
|
223
224
|
placeholder,
|
|
225
|
+
required: requireComment,
|
|
226
|
+
"aria-required": requireComment,
|
|
224
227
|
value: comment,
|
|
225
228
|
disabled: status === "submitting",
|
|
226
229
|
onChange: (event) => {
|
|
@@ -233,7 +236,7 @@ function DocsFeedback({ pathname, entry, locale, question = "How is this guide?"
|
|
|
233
236
|
children: [/* @__PURE__ */ jsxs("button", {
|
|
234
237
|
type: "button",
|
|
235
238
|
className: "fd-page-action-btn fd-feedback-submit",
|
|
236
|
-
disabled: status === "submitting" || status === "submitted",
|
|
239
|
+
disabled: status === "submitting" || status === "submitted" || commentRequired,
|
|
237
240
|
onClick: () => void handleSubmit(),
|
|
238
241
|
children: [
|
|
239
242
|
status === "submitting" && /* @__PURE__ */ jsx("span", {
|
package/dist/docs-layout.mjs
CHANGED
|
@@ -652,6 +652,7 @@ function createDocsLayout(config, options) {
|
|
|
652
652
|
const layoutDimensions = config.theme?.ui?.layout;
|
|
653
653
|
const pageActions = config.pageActions;
|
|
654
654
|
const copyMarkdownEnabled = resolveBool(pageActions?.copyMarkdown);
|
|
655
|
+
const copyMarkdownConfig = pageActions?.copyMarkdown && typeof pageActions.copyMarkdown === "object" ? pageActions.copyMarkdown : void 0;
|
|
655
656
|
const openDocsEnabled = resolveBool(pageActions?.openDocs);
|
|
656
657
|
const pageActionsPosition = pageActions?.position ?? "below-title";
|
|
657
658
|
const pageActionsAlignment = pageActions?.alignment ?? "left";
|
|
@@ -661,6 +662,7 @@ function createDocsLayout(config, options) {
|
|
|
661
662
|
const readingTimeOptions = resolveReadingTimeOptions(config.readingTime);
|
|
662
663
|
const readingTimeEnabledByDefault = readingTimeOptions.enabled;
|
|
663
664
|
const readingTimeWordsPerMinute = readingTimeOptions.wordsPerMinute ?? 220;
|
|
665
|
+
const readingTimeFormat = readingTimeOptions.format;
|
|
664
666
|
const llmsTxtEnabled = resolveEnabledByDefault(config.llmsTxt);
|
|
665
667
|
const feedbackConfig = resolveFeedbackConfig(config.feedback);
|
|
666
668
|
const openDocsConfig = pageActions?.openDocs && typeof pageActions.openDocs === "object" ? pageActions.openDocs : void 0;
|
|
@@ -789,6 +791,8 @@ function createDocsLayout(config, options) {
|
|
|
789
791
|
publicPath: localeContext.publicPath,
|
|
790
792
|
locale: activeLocale,
|
|
791
793
|
copyMarkdown: copyMarkdownEnabled,
|
|
794
|
+
copyMarkdownLabel: copyMarkdownConfig?.label,
|
|
795
|
+
copyMarkdownCopiedLabel: copyMarkdownConfig?.copiedLabel,
|
|
792
796
|
openDocs: openDocsEnabled,
|
|
793
797
|
openDocsProviders,
|
|
794
798
|
openDocsTarget: openDocsConfig?.target,
|
|
@@ -803,6 +807,7 @@ function createDocsLayout(config, options) {
|
|
|
803
807
|
lastUpdatedEnabled,
|
|
804
808
|
lastUpdatedPosition,
|
|
805
809
|
readingTimeEnabled,
|
|
810
|
+
readingTimeFormat,
|
|
806
811
|
readingTimeMap,
|
|
807
812
|
structuredDataMap,
|
|
808
813
|
llmsTxtEnabled,
|
|
@@ -810,6 +815,7 @@ function createDocsLayout(config, options) {
|
|
|
810
815
|
feedbackEnabled: feedbackConfig.enabled,
|
|
811
816
|
feedbackQuestion: feedbackConfig.question,
|
|
812
817
|
feedbackPlaceholder: feedbackConfig.placeholder,
|
|
818
|
+
feedbackRequireComment: feedbackConfig.requireComment,
|
|
813
819
|
feedbackPositiveLabel: feedbackConfig.positiveLabel,
|
|
814
820
|
feedbackNegativeLabel: feedbackConfig.negativeLabel,
|
|
815
821
|
feedbackSubmitLabel: feedbackConfig.submitLabel,
|
|
@@ -837,6 +843,7 @@ function resolveFeedbackConfig(feedback) {
|
|
|
837
843
|
enabled: false,
|
|
838
844
|
question: "How is this guide?",
|
|
839
845
|
placeholder: "Leave your feedback...",
|
|
846
|
+
requireComment: false,
|
|
840
847
|
positiveLabel: "Good",
|
|
841
848
|
negativeLabel: "Bad",
|
|
842
849
|
submitLabel: "Submit"
|
|
@@ -846,11 +853,12 @@ function resolveFeedbackConfig(feedback) {
|
|
|
846
853
|
...defaults,
|
|
847
854
|
enabled: true
|
|
848
855
|
};
|
|
849
|
-
const hasHumanFeedbackConfig = feedback.enabled !== void 0 || feedback.question !== void 0 || feedback.placeholder !== void 0 || feedback.positiveLabel !== void 0 || feedback.negativeLabel !== void 0 || feedback.submitLabel !== void 0 || feedback.onFeedback !== void 0;
|
|
856
|
+
const hasHumanFeedbackConfig = feedback.enabled !== void 0 || feedback.question !== void 0 || feedback.placeholder !== void 0 || feedback.requireComment !== void 0 || feedback.positiveLabel !== void 0 || feedback.negativeLabel !== void 0 || feedback.submitLabel !== void 0 || feedback.onFeedback !== void 0;
|
|
850
857
|
return {
|
|
851
858
|
enabled: feedback.enabled === true || feedback.enabled !== false && hasHumanFeedbackConfig,
|
|
852
859
|
question: feedback.question ?? defaults.question,
|
|
853
860
|
placeholder: feedback.placeholder ?? defaults.placeholder,
|
|
861
|
+
requireComment: feedback.requireComment ?? defaults.requireComment,
|
|
854
862
|
positiveLabel: feedback.positiveLabel ?? defaults.positiveLabel,
|
|
855
863
|
negativeLabel: feedback.negativeLabel ?? defaults.negativeLabel,
|
|
856
864
|
submitLabel: feedback.submitLabel ?? defaults.submitLabel
|
|
@@ -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
|
|
@@ -23,6 +23,8 @@ interface DocsPageClientProps {
|
|
|
23
23
|
/** Active locale (used for llms.txt links) */
|
|
24
24
|
locale?: string;
|
|
25
25
|
copyMarkdown?: boolean;
|
|
26
|
+
copyMarkdownLabel?: string;
|
|
27
|
+
copyMarkdownCopiedLabel?: string;
|
|
26
28
|
openDocs?: boolean;
|
|
27
29
|
openDocsProviders?: SerializedProvider[];
|
|
28
30
|
openDocsTarget?: "markdown" | "page" | "source" | "github";
|
|
@@ -49,6 +51,8 @@ interface DocsPageClientProps {
|
|
|
49
51
|
readingTimeMap?: Record<string, number>;
|
|
50
52
|
/** Direct reading-time override for the current page. */
|
|
51
53
|
readingTime?: number | null;
|
|
54
|
+
/** Reading-time label style. */
|
|
55
|
+
readingTimeFormat?: ReadingTimeFormat;
|
|
52
56
|
/** Map of pathname → serialized Schema.org JSON-LD. */
|
|
53
57
|
structuredDataMap?: Record<string, string>;
|
|
54
58
|
/** Direct serialized Schema.org JSON-LD override for the current page. */
|
|
@@ -72,6 +76,7 @@ interface DocsPageClientProps {
|
|
|
72
76
|
feedbackEnabled?: boolean;
|
|
73
77
|
feedbackQuestion?: string;
|
|
74
78
|
feedbackPlaceholder?: string;
|
|
79
|
+
feedbackRequireComment?: boolean;
|
|
75
80
|
feedbackPositiveLabel?: string;
|
|
76
81
|
feedbackNegativeLabel?: string;
|
|
77
82
|
feedbackSubmitLabel?: string;
|
|
@@ -88,6 +93,8 @@ declare function DocsPageClient({
|
|
|
88
93
|
publicPath,
|
|
89
94
|
locale,
|
|
90
95
|
copyMarkdown,
|
|
96
|
+
copyMarkdownLabel,
|
|
97
|
+
copyMarkdownCopiedLabel,
|
|
91
98
|
openDocs,
|
|
92
99
|
openDocsProviders,
|
|
93
100
|
openDocsTarget,
|
|
@@ -103,6 +110,7 @@ declare function DocsPageClient({
|
|
|
103
110
|
lastModified: lastModifiedProp,
|
|
104
111
|
readingTimeMap,
|
|
105
112
|
readingTime: readingTimeProp,
|
|
113
|
+
readingTimeFormat,
|
|
106
114
|
structuredDataMap,
|
|
107
115
|
structuredData: structuredDataProp,
|
|
108
116
|
readingTimeEnabled,
|
|
@@ -114,6 +122,7 @@ declare function DocsPageClient({
|
|
|
114
122
|
feedbackEnabled,
|
|
115
123
|
feedbackQuestion,
|
|
116
124
|
feedbackPlaceholder,
|
|
125
|
+
feedbackRequireComment,
|
|
117
126
|
feedbackPositiveLabel,
|
|
118
127
|
feedbackNegativeLabel,
|
|
119
128
|
feedbackSubmitLabel,
|
|
@@ -198,8 +198,9 @@ function decodeHashTarget(hash) {
|
|
|
198
198
|
return value;
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
|
-
function formatReadingTimeLabel(minutes) {
|
|
202
|
-
|
|
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, copyMarkdownLabel, copyMarkdownCopiedLabel, 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, feedbackRequireComment, 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", {
|
|
@@ -464,6 +465,8 @@ function DocsPageClient({ tocEnabled, tocStyle = "default", breadcrumbEnabled =
|
|
|
464
465
|
"data-actions-alignment": pageActionsAlignment,
|
|
465
466
|
children: /* @__PURE__ */ jsx(PageActions, {
|
|
466
467
|
copyMarkdown,
|
|
468
|
+
copyMarkdownLabel,
|
|
469
|
+
copyMarkdownCopiedLabel,
|
|
467
470
|
openDocs,
|
|
468
471
|
providers: openDocsProviders,
|
|
469
472
|
openDocsTarget,
|
|
@@ -507,6 +510,8 @@ function DocsPageClient({ tocEnabled, tocStyle = "default", breadcrumbEnabled =
|
|
|
507
510
|
className: "fd-actions-toc-portal not-prose",
|
|
508
511
|
children: /* @__PURE__ */ jsx(PageActions, {
|
|
509
512
|
copyMarkdown,
|
|
513
|
+
copyMarkdownLabel,
|
|
514
|
+
copyMarkdownCopiedLabel,
|
|
510
515
|
openDocs,
|
|
511
516
|
providers: openDocsProviders,
|
|
512
517
|
openDocsTarget,
|
|
@@ -559,6 +564,8 @@ function DocsPageClient({ tocEnabled, tocStyle = "default", breadcrumbEnabled =
|
|
|
559
564
|
"data-actions-alignment": pageActionsAlignment,
|
|
560
565
|
children: /* @__PURE__ */ jsx(PageActions, {
|
|
561
566
|
copyMarkdown,
|
|
567
|
+
copyMarkdownLabel,
|
|
568
|
+
copyMarkdownCopiedLabel,
|
|
562
569
|
openDocs,
|
|
563
570
|
providers: openDocsProviders,
|
|
564
571
|
openDocsTarget,
|
|
@@ -588,6 +595,7 @@ function DocsPageClient({ tocEnabled, tocStyle = "default", breadcrumbEnabled =
|
|
|
588
595
|
locale: activeLocale,
|
|
589
596
|
question: feedbackQuestion,
|
|
590
597
|
placeholder: feedbackPlaceholder,
|
|
598
|
+
requireComment: feedbackRequireComment,
|
|
591
599
|
positiveLabel: feedbackPositiveLabel,
|
|
592
600
|
negativeLabel: feedbackNegativeLabel,
|
|
593
601
|
submitLabel: feedbackSubmitLabel,
|
package/dist/page-actions.d.mts
CHANGED
|
@@ -11,6 +11,8 @@ interface SerializedProvider {
|
|
|
11
11
|
}
|
|
12
12
|
interface PageActionsProps {
|
|
13
13
|
copyMarkdown?: boolean;
|
|
14
|
+
copyMarkdownLabel?: string;
|
|
15
|
+
copyMarkdownCopiedLabel?: string;
|
|
14
16
|
openDocs?: boolean;
|
|
15
17
|
providers?: SerializedProvider[];
|
|
16
18
|
openDocsTarget?: "markdown" | "page" | "source" | "github";
|
|
@@ -23,6 +25,8 @@ interface PageActionsProps {
|
|
|
23
25
|
}
|
|
24
26
|
declare function PageActions({
|
|
25
27
|
copyMarkdown,
|
|
28
|
+
copyMarkdownLabel,
|
|
29
|
+
copyMarkdownCopiedLabel,
|
|
26
30
|
openDocs,
|
|
27
31
|
providers,
|
|
28
32
|
openDocsTarget,
|
package/dist/page-actions.mjs
CHANGED
|
@@ -132,7 +132,7 @@ function pageUrlToMarkdownUrl(pageUrl) {
|
|
|
132
132
|
function fillPromptTemplate(template, values) {
|
|
133
133
|
return template.replace(/\{pageUrl\}/g, values.pageUrl).replace(/\{markdownUrl\}/g, values.markdownUrl).replace(/\{sourceUrl\}/g, values.sourceUrl).replace(/\{mdxUrl\}/g, values.sourceUrl).replace(/\{githubUrl\}/g, values.githubUrl).replace(/\{url\}/g, values.url);
|
|
134
134
|
}
|
|
135
|
-
function PageActions({ copyMarkdown, openDocs, providers, openDocsTarget = DEFAULT_OPEN_DOCS_TARGET, openDocsPrompt = DEFAULT_OPEN_DOCS_PROMPT, alignment = "left", variant = "default", githubFileUrl, analytics = false }) {
|
|
135
|
+
function PageActions({ copyMarkdown, copyMarkdownLabel = "Copy page", copyMarkdownCopiedLabel = "Copied!", openDocs, providers, openDocsTarget = DEFAULT_OPEN_DOCS_TARGET, openDocsPrompt = DEFAULT_OPEN_DOCS_PROMPT, alignment = "left", variant = "default", githubFileUrl, analytics = false }) {
|
|
136
136
|
const [copied, setCopied] = useState(false);
|
|
137
137
|
const [dropdownOpen, setDropdownOpen] = useState(false);
|
|
138
138
|
const dropdownRef = useRef(null);
|
|
@@ -238,7 +238,7 @@ function PageActions({ copyMarkdown, openDocs, providers, openDocsTarget = DEFAU
|
|
|
238
238
|
onClick: handleCopyMarkdown,
|
|
239
239
|
className: "fd-page-action-btn",
|
|
240
240
|
"data-copied": copied,
|
|
241
|
-
children: [copied ? /* @__PURE__ */ jsx(CheckIcon, {}) : /* @__PURE__ */ jsx(CopyIcon, {}), /* @__PURE__ */ jsx("span", { children: copied ?
|
|
241
|
+
children: [copied ? /* @__PURE__ */ jsx(CheckIcon, {}) : /* @__PURE__ */ jsx(CopyIcon, {}), /* @__PURE__ */ jsx("span", { children: copied ? copyMarkdownCopiedLabel : copyMarkdownLabel })]
|
|
242
242
|
}),
|
|
243
243
|
openDocs && /* @__PURE__ */ jsxs("a", {
|
|
244
244
|
className: "fd-page-action-btn",
|
|
@@ -271,7 +271,7 @@ function PageActions({ copyMarkdown, openDocs, providers, openDocsTarget = DEFAU
|
|
|
271
271
|
onClick: handleCopyMarkdown,
|
|
272
272
|
className: "fd-page-action-btn",
|
|
273
273
|
"data-copied": copied,
|
|
274
|
-
children: [copied ? /* @__PURE__ */ jsx(CheckIcon, {}) : /* @__PURE__ */ jsx(CopyIcon, {}), /* @__PURE__ */ jsx("span", { children: copied ?
|
|
274
|
+
children: [copied ? /* @__PURE__ */ jsx(CheckIcon, {}) : /* @__PURE__ */ jsx(CopyIcon, {}), /* @__PURE__ */ jsx("span", { children: copied ? copyMarkdownCopiedLabel : copyMarkdownLabel })]
|
|
275
275
|
}), openDocs && resolvedProviders.length > 0 && /* @__PURE__ */ jsxs("div", {
|
|
276
276
|
ref: dropdownRef,
|
|
277
277
|
className: "fd-page-action-dropdown",
|
package/dist/reading-time.mjs
CHANGED
|
@@ -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 {
|
|
20
|
-
|
|
21
|
-
|
|
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) {
|
package/dist/tanstack-layout.mjs
CHANGED
|
@@ -193,6 +193,7 @@ function resolveFeedbackConfig(feedback) {
|
|
|
193
193
|
enabled: false,
|
|
194
194
|
question: "How is this guide?",
|
|
195
195
|
placeholder: "Leave your feedback...",
|
|
196
|
+
requireComment: false,
|
|
196
197
|
positiveLabel: "Good",
|
|
197
198
|
negativeLabel: "Bad",
|
|
198
199
|
submitLabel: "Submit"
|
|
@@ -202,11 +203,12 @@ function resolveFeedbackConfig(feedback) {
|
|
|
202
203
|
...defaults,
|
|
203
204
|
enabled: true
|
|
204
205
|
};
|
|
205
|
-
const hasHumanFeedbackConfig = feedback.enabled !== void 0 || feedback.question !== void 0 || feedback.placeholder !== void 0 || feedback.positiveLabel !== void 0 || feedback.negativeLabel !== void 0 || feedback.submitLabel !== void 0 || feedback.onFeedback !== void 0;
|
|
206
|
+
const hasHumanFeedbackConfig = feedback.enabled !== void 0 || feedback.question !== void 0 || feedback.placeholder !== void 0 || feedback.requireComment !== void 0 || feedback.positiveLabel !== void 0 || feedback.negativeLabel !== void 0 || feedback.submitLabel !== void 0 || feedback.onFeedback !== void 0;
|
|
206
207
|
return {
|
|
207
208
|
enabled: feedback.enabled === true || feedback.enabled !== false && hasHumanFeedbackConfig,
|
|
208
209
|
question: feedback.question ?? defaults.question,
|
|
209
210
|
placeholder: feedback.placeholder ?? defaults.placeholder,
|
|
211
|
+
requireComment: feedback.requireComment ?? defaults.requireComment,
|
|
210
212
|
positiveLabel: feedback.positiveLabel ?? defaults.positiveLabel,
|
|
211
213
|
negativeLabel: feedback.negativeLabel ?? defaults.negativeLabel,
|
|
212
214
|
submitLabel: feedback.submitLabel ?? defaults.submitLabel
|
|
@@ -238,13 +240,15 @@ function TanstackDocsLayout({ config, tree, locale, description, readingTime, la
|
|
|
238
240
|
const layoutDimensions = config.theme?.ui?.layout;
|
|
239
241
|
const pageActions = config.pageActions;
|
|
240
242
|
const copyMarkdownEnabled = resolveBool(pageActions?.copyMarkdown);
|
|
243
|
+
const copyMarkdownConfig = pageActions?.copyMarkdown && typeof pageActions.copyMarkdown === "object" ? pageActions.copyMarkdown : void 0;
|
|
241
244
|
const openDocsEnabled = resolveBool(pageActions?.openDocs);
|
|
242
245
|
const pageActionsPosition = pageActions?.position ?? "below-title";
|
|
243
246
|
const pageActionsAlignment = pageActions?.alignment ?? "left";
|
|
244
247
|
const lastUpdatedRaw = config.lastUpdated;
|
|
245
248
|
const lastUpdatedEnabled = lastUpdatedRaw !== false && (typeof lastUpdatedRaw !== "object" || lastUpdatedRaw.enabled !== false);
|
|
246
249
|
const lastUpdatedPosition = typeof lastUpdatedRaw === "object" ? lastUpdatedRaw.position ?? "footer" : "footer";
|
|
247
|
-
const
|
|
250
|
+
const readingTimeOptions = resolveReadingTimeOptions(config.readingTime);
|
|
251
|
+
const readingTimeEnabled = readingTimeOptions.enabled;
|
|
248
252
|
const llmsTxtEnabled = resolveEnabledByDefault(config.llmsTxt);
|
|
249
253
|
const feedbackConfig = resolveFeedbackConfig(config.feedback);
|
|
250
254
|
const staticExport = !!config.staticExport;
|
|
@@ -353,6 +357,8 @@ function TanstackDocsLayout({ config, tree, locale, description, readingTime, la
|
|
|
353
357
|
entry: config.entry ?? "docs",
|
|
354
358
|
locale,
|
|
355
359
|
copyMarkdown: copyMarkdownEnabled,
|
|
360
|
+
copyMarkdownLabel: copyMarkdownConfig?.label,
|
|
361
|
+
copyMarkdownCopiedLabel: copyMarkdownConfig?.copiedLabel,
|
|
356
362
|
openDocs: openDocsEnabled,
|
|
357
363
|
openDocsProviders,
|
|
358
364
|
openDocsTarget: openDocsConfig?.target,
|
|
@@ -364,12 +370,14 @@ function TanstackDocsLayout({ config, tree, locale, description, readingTime, la
|
|
|
364
370
|
lastUpdatedPosition,
|
|
365
371
|
lastModified,
|
|
366
372
|
readingTimeEnabled,
|
|
373
|
+
readingTimeFormat: readingTimeOptions.format,
|
|
367
374
|
readingTime: typeof readingTime === "number" ? readingTime : void 0,
|
|
368
375
|
llmsTxtEnabled,
|
|
369
376
|
description,
|
|
370
377
|
feedbackEnabled: feedbackConfig.enabled,
|
|
371
378
|
feedbackQuestion: feedbackConfig.question,
|
|
372
379
|
feedbackPlaceholder: feedbackConfig.placeholder,
|
|
380
|
+
feedbackRequireComment: feedbackConfig.requireComment,
|
|
373
381
|
feedbackPositiveLabel: feedbackConfig.positiveLabel,
|
|
374
382
|
feedbackNegativeLabel: feedbackConfig.negativeLabel,
|
|
375
383
|
feedbackSubmitLabel: feedbackConfig.submitLabel,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farming-labs/theme",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.16",
|
|
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.
|
|
148
|
+
"@farming-labs/docs": "0.2.16"
|
|
149
149
|
},
|
|
150
150
|
"peerDependencies": {
|
|
151
151
|
"@farming-labs/docs": ">=0.0.1",
|