@farming-labs/nuxt-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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farming-labs/nuxt-theme",
3
- "version": "0.1.45",
3
+ "version": "0.1.47",
4
4
  "description": "Nuxt/Vue UI components for @farming-labs/docs — layout, sidebar, TOC, search, and theme toggle",
5
5
  "keywords": [
6
6
  "docs",
@@ -81,7 +81,7 @@
81
81
  },
82
82
  "dependencies": {
83
83
  "sugar-high": "^0.9.5",
84
- "@farming-labs/docs": "0.1.45"
84
+ "@farming-labs/docs": "0.1.47"
85
85
  },
86
86
  "peerDependencies": {
87
87
  "nuxt": ">=3.0.0",
@@ -1,4 +1,5 @@
1
1
  <script setup lang="ts">
2
+ import { resolveReadingTimeOptions } from "@farming-labs/docs";
2
3
  import { computed, ref, onMounted, onUnmounted, watch } from "vue";
3
4
  import { useRoute } from "vue-router";
4
5
  import { useHead } from "#app";
@@ -15,6 +16,7 @@ const props = defineProps<{
15
16
  description?: string;
16
17
  html: string;
17
18
  rawMarkdown?: string;
19
+ readingTime?: number | null;
18
20
  previousPage?: { name: string; url: string } | null;
19
21
  nextPage?: { name: string; url: string } | null;
20
22
  editOnGithub?: string;
@@ -168,6 +170,29 @@ const showPageActions = computed(
168
170
  );
169
171
  const showActionsAbove = computed(() => pageActionsPosition.value === "above-title" && showPageActions.value);
170
172
  const showActionsBelow = computed(() => pageActionsPosition.value === "below-title" && showPageActions.value);
173
+ const readingTimeConfig = computed(() =>
174
+ resolveReadingTimeOptions(props.config?.readingTime as never),
175
+ );
176
+ const readingTimeValue = computed(() =>
177
+ readingTimeConfig.value.enabled && typeof props.data.readingTime === "number"
178
+ ? Math.max(1, Math.ceil(props.data.readingTime))
179
+ : null,
180
+ );
181
+ const readingTimeLabel = computed(() =>
182
+ readingTimeValue.value ? `${readingTimeValue.value} min read` : null,
183
+ );
184
+ const showReadingTimeAbove = computed(() => !!readingTimeLabel.value && showActionsAbove.value);
185
+ const showReadingTimeBelow = computed(
186
+ () =>
187
+ !!readingTimeLabel.value &&
188
+ !showReadingTimeAbove.value &&
189
+ (showActionsBelow.value ||
190
+ showLastUpdatedBelowTitle.value ||
191
+ (!showPageActions.value && pageActionsPosition.value === "below-title")),
192
+ );
193
+ const showReadingTimeStandalone = computed(
194
+ () => !!readingTimeLabel.value && !showReadingTimeAbove.value && !showReadingTimeBelow.value,
195
+ );
171
196
  const feedbackConfig = computed(() => {
172
197
  const defaults = {
173
198
  enabled: false,
@@ -415,12 +440,24 @@ onUnmounted(() => {
415
440
  </div>
416
441
  </div>
417
442
  </div>
443
+ <div v-if="showReadingTimeAbove" class="fd-page-meta">
444
+ <span class="fd-page-meta-dot" aria-hidden="true">·</span>
445
+ <span class="fd-page-meta-item">{{ readingTimeLabel }}</span>
446
+ </div>
447
+ <div v-if="showReadingTimeStandalone" class="fd-page-meta">
448
+ <span class="fd-page-meta-dot" aria-hidden="true">·</span>
449
+ <span class="fd-page-meta-item">{{ readingTimeLabel }}</span>
450
+ </div>
418
451
 
419
452
  <h1 class="fd-page-title">{{ data.title }}</h1>
420
453
  <p v-if="data.description" class="fd-page-description">{{ data.description }}</p>
421
454
  <p v-if="showLastUpdatedBelowTitle && data.lastModified" class="fd-last-modified fd-last-modified-below-title">
422
455
  Last updated: {{ data.lastModified }}
423
456
  </p>
457
+ <div v-if="showReadingTimeBelow && !showActionsBelow" class="fd-page-meta">
458
+ <span class="fd-page-meta-dot" aria-hidden="true">·</span>
459
+ <span class="fd-page-meta-item">{{ readingTimeLabel }}</span>
460
+ </div>
424
461
 
425
462
  <!-- Below-title actions -->
426
463
  <template v-if="showActionsBelow">
@@ -480,6 +517,10 @@ onUnmounted(() => {
480
517
  </div>
481
518
  </div>
482
519
  </div>
520
+ <div v-if="showReadingTimeBelow" class="fd-page-meta">
521
+ <span class="fd-page-meta-dot" aria-hidden="true">·</span>
522
+ <span class="fd-page-meta-item">{{ readingTimeLabel }}</span>
523
+ </div>
483
524
  </template>
484
525
 
485
526
  <div v-html="htmlWithoutFirstH1" />
package/styles/docs.css CHANGED
@@ -750,6 +750,33 @@ samp {
750
750
  margin-bottom: 1rem;
751
751
  }
752
752
 
753
+ .fd-page-meta {
754
+ display: flex;
755
+ flex-wrap: wrap;
756
+ align-items: center;
757
+ gap: 0.375rem;
758
+ margin-bottom: 0.75rem;
759
+ }
760
+
761
+ .fd-page-meta-dot {
762
+ display: inline-flex;
763
+ align-items: center;
764
+ justify-content: center;
765
+ font-family: var(--fd-font-mono, ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace);
766
+ font-size: 0.8rem;
767
+ line-height: 1;
768
+ color: color-mix(in srgb, var(--color-fd-muted-foreground) 78%, transparent);
769
+ }
770
+
771
+ .fd-page-meta-item {
772
+ font-family: var(--fd-font-mono, ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace);
773
+ font-size: 0.6875rem;
774
+ font-weight: 500;
775
+ letter-spacing: 0;
776
+ text-transform: uppercase;
777
+ color: var(--color-fd-muted-foreground);
778
+ }
779
+
753
780
  .fd-feedback {
754
781
  margin-top: 2rem;
755
782
  margin-bottom: 1.25rem;