@farming-labs/astro-theme 0.1.45 → 0.1.47
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/package.json +3 -3
- package/src/components/DocsContent.astro +40 -0
- package/styles/docs.css +27 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farming-labs/astro-theme",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.47",
|
|
4
4
|
"description": "Astro UI components for @farming-labs/docs — layout, sidebar, TOC, search, and theme toggle",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"astro",
|
|
@@ -109,8 +109,8 @@
|
|
|
109
109
|
},
|
|
110
110
|
"dependencies": {
|
|
111
111
|
"sugar-high": "^0.9.5",
|
|
112
|
-
"@farming-labs/
|
|
113
|
-
"@farming-labs/
|
|
112
|
+
"@farming-labs/docs": "0.1.47",
|
|
113
|
+
"@farming-labs/astro": "0.1.47"
|
|
114
114
|
},
|
|
115
115
|
"peerDependencies": {
|
|
116
116
|
"astro": ">=4.0.0"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
+
import { resolveReadingTimeOptions } from "@farming-labs/docs";
|
|
2
3
|
import DocsPage from "./DocsPage.astro";
|
|
3
4
|
|
|
4
5
|
const { data, config = null } = Astro.props;
|
|
@@ -84,6 +85,9 @@ const pageActionsAlignment = (() => {
|
|
|
84
85
|
if (typeof pa === "object" && pa !== null && pa.alignment) return pa.alignment;
|
|
85
86
|
return "left";
|
|
86
87
|
})();
|
|
88
|
+
const showPageActions = copyMarkdownEnabled || openDocsEnabled;
|
|
89
|
+
const showActionsAbove = pageActionsPosition === "above-title" && showPageActions;
|
|
90
|
+
const showActionsBelow = pageActionsPosition === "below-title" && showPageActions;
|
|
87
91
|
|
|
88
92
|
const lastUpdatedConfig = (() => {
|
|
89
93
|
const lu = config?.lastUpdated;
|
|
@@ -97,6 +101,18 @@ const lastUpdatedConfig = (() => {
|
|
|
97
101
|
|
|
98
102
|
const showLastUpdatedInFooter = !!data.lastModified && lastUpdatedConfig.enabled && lastUpdatedConfig.position === "footer";
|
|
99
103
|
const showLastUpdatedBelowTitle = !!data.lastModified && lastUpdatedConfig.enabled && lastUpdatedConfig.position === "below-title";
|
|
104
|
+
const readingTimeConfig = resolveReadingTimeOptions(config?.readingTime as never);
|
|
105
|
+
const readingTimeValue =
|
|
106
|
+
readingTimeConfig.enabled && typeof data.readingTime === "number"
|
|
107
|
+
? Math.max(1, Math.ceil(data.readingTime))
|
|
108
|
+
: null;
|
|
109
|
+
const readingTimeLabel = readingTimeValue ? `${readingTimeValue} min read` : null;
|
|
110
|
+
const showReadingTimeAbove = !!readingTimeLabel && showActionsAbove;
|
|
111
|
+
const showReadingTimeBelow =
|
|
112
|
+
!!readingTimeLabel &&
|
|
113
|
+
!showReadingTimeAbove &&
|
|
114
|
+
(showActionsBelow || showLastUpdatedBelowTitle || (!showPageActions && pageActionsPosition === "below-title"));
|
|
115
|
+
const showReadingTimeStandalone = !!readingTimeLabel && !showReadingTimeAbove && !showReadingTimeBelow;
|
|
100
116
|
const feedbackConfig = (() => {
|
|
101
117
|
const defaults = {
|
|
102
118
|
enabled: false,
|
|
@@ -188,11 +204,29 @@ const htmlWithoutFirstH1 = (data.html || "").replace(/<h1[^>]*>[\s\S]*?<\/h1>\s*
|
|
|
188
204
|
)}
|
|
189
205
|
</div>
|
|
190
206
|
)}
|
|
207
|
+
{showReadingTimeAbove && (
|
|
208
|
+
<div class="fd-page-meta">
|
|
209
|
+
<span class="fd-page-meta-dot" aria-hidden="true">·</span>
|
|
210
|
+
<span class="fd-page-meta-item">{readingTimeLabel}</span>
|
|
211
|
+
</div>
|
|
212
|
+
)}
|
|
213
|
+
{showReadingTimeStandalone && (
|
|
214
|
+
<div class="fd-page-meta">
|
|
215
|
+
<span class="fd-page-meta-dot" aria-hidden="true">·</span>
|
|
216
|
+
<span class="fd-page-meta-item">{readingTimeLabel}</span>
|
|
217
|
+
</div>
|
|
218
|
+
)}
|
|
191
219
|
<h1 class="fd-page-title">{data.title}</h1>
|
|
192
220
|
{data.description && <p class="fd-page-description">{data.description}</p>}
|
|
193
221
|
{showLastUpdatedBelowTitle && data.lastModified && (
|
|
194
222
|
<p class="fd-last-modified fd-last-modified-below-title">Last updated: {data.lastModified}</p>
|
|
195
223
|
)}
|
|
224
|
+
{showReadingTimeBelow && !showActionsBelow && (
|
|
225
|
+
<div class="fd-page-meta">
|
|
226
|
+
<span class="fd-page-meta-dot" aria-hidden="true">·</span>
|
|
227
|
+
<span class="fd-page-meta-item">{readingTimeLabel}</span>
|
|
228
|
+
</div>
|
|
229
|
+
)}
|
|
196
230
|
{pageActionsPosition === "below-title" && (copyMarkdownEnabled || openDocsEnabled) && (
|
|
197
231
|
<>
|
|
198
232
|
<hr class="fd-page-actions-divider" aria-hidden="true" />
|
|
@@ -241,6 +275,12 @@ const htmlWithoutFirstH1 = (data.html || "").replace(/<h1[^>]*>[\s\S]*?<\/h1>\s*
|
|
|
241
275
|
</div>
|
|
242
276
|
)}
|
|
243
277
|
</div>
|
|
278
|
+
{showReadingTimeBelow && (
|
|
279
|
+
<div class="fd-page-meta">
|
|
280
|
+
<span class="fd-page-meta-dot" aria-hidden="true">·</span>
|
|
281
|
+
<span class="fd-page-meta-item">{readingTimeLabel}</span>
|
|
282
|
+
</div>
|
|
283
|
+
)}
|
|
244
284
|
</>
|
|
245
285
|
)}
|
|
246
286
|
<Fragment set:html={htmlWithoutFirstH1} />
|
package/styles/docs.css
CHANGED
|
@@ -1641,6 +1641,33 @@ html.dark pre.shiki {
|
|
|
1641
1641
|
margin-bottom: 1rem;
|
|
1642
1642
|
}
|
|
1643
1643
|
|
|
1644
|
+
.fd-page-meta {
|
|
1645
|
+
display: flex;
|
|
1646
|
+
flex-wrap: wrap;
|
|
1647
|
+
align-items: center;
|
|
1648
|
+
gap: 0.375rem;
|
|
1649
|
+
margin-bottom: 0.75rem;
|
|
1650
|
+
}
|
|
1651
|
+
|
|
1652
|
+
.fd-page-meta-dot {
|
|
1653
|
+
display: inline-flex;
|
|
1654
|
+
align-items: center;
|
|
1655
|
+
justify-content: center;
|
|
1656
|
+
font-family: var(--fd-font-mono, ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace);
|
|
1657
|
+
font-size: 0.8rem;
|
|
1658
|
+
line-height: 1;
|
|
1659
|
+
color: color-mix(in srgb, var(--color-fd-muted-foreground) 78%, transparent);
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1662
|
+
.fd-page-meta-item {
|
|
1663
|
+
font-family: var(--fd-font-mono, ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace);
|
|
1664
|
+
font-size: 0.6875rem;
|
|
1665
|
+
font-weight: 500;
|
|
1666
|
+
letter-spacing: 0;
|
|
1667
|
+
text-transform: uppercase;
|
|
1668
|
+
color: var(--color-fd-muted-foreground);
|
|
1669
|
+
}
|
|
1670
|
+
|
|
1644
1671
|
.fd-feedback {
|
|
1645
1672
|
margin-top: 2rem;
|
|
1646
1673
|
margin-bottom: 1.25rem;
|