@frontfactory/vitepress-theme 1.6.0 → 1.8.0
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/CHANGELOG.md +214 -0
- package/README.md +160 -8
- package/config.d.ts +26 -1
- package/config.js +165 -21
- package/dist/style.css +1 -1
- package/node/llms.js +31 -0
- package/node/og.js +159 -0
- package/node/pages.js +154 -0
- package/node/rss.js +81 -0
- package/package.json +49 -26
- package/src/blog/posts.data.ts +46 -0
- package/src/components/FfBackToTop.vue +33 -10
- package/src/components/FfBanner.vue +42 -8
- package/src/components/FfCopyStatus.vue +64 -0
- package/src/components/FfDocMeta.vue +50 -46
- package/src/components/FfFeature.vue +18 -7
- package/src/components/FfFeedback.vue +96 -0
- package/src/components/FfFooter.vue +11 -5
- package/src/components/FfHero.vue +20 -10
- package/src/components/FfHeroCommand.vue +24 -27
- package/src/components/FfHomeSponsors.vue +2 -2
- package/src/components/FfNavBarTitle.vue +63 -0
- package/src/components/FfPost.vue +49 -0
- package/src/components/FfProgress.vue +69 -0
- package/src/components/FfVersionSwitcher.vue +20 -0
- package/src/composables/blog.ts +38 -0
- package/src/composables/options.ts +19 -14
- package/src/composables/relativeTime.ts +59 -0
- package/src/composables/tabs.ts +155 -0
- package/src/content/Api.vue +6 -2
- package/src/content/Badge.vue +26 -0
- package/src/content/Callout.vue +27 -0
- package/src/content/FileTree.vue +118 -0
- package/src/content/Tab.vue +11 -0
- package/src/content/Tabs.vue +74 -0
- package/src/content/Timeline.vue +19 -0
- package/src/content/TimelineItem.vue +37 -0
- package/src/content/timeline.ts +4 -0
- package/src/index.ts +37 -1
- package/src/internal.ts +7 -2
- package/src/layout/FfBlog.vue +62 -0
- package/src/layout/FfLayout.vue +17 -1
- package/src/styles/_base.scss +20 -5
- package/src/styles/_blocks.scss +25 -1
- package/src/styles/_blog.scss +131 -0
- package/src/styles/_breakpoints.scss +26 -0
- package/src/styles/_code.scss +5 -5
- package/src/styles/_content.scss +280 -12
- package/src/styles/_doc.scss +18 -5
- package/src/styles/_home.scss +37 -17
- package/src/styles/_motion.scss +22 -2
- package/src/styles/_nav.scss +81 -8
- package/src/styles/_print.scss +77 -0
- package/src/styles/_sidebar.scss +2 -2
- package/src/styles/_tokens.scss +75 -9
- package/src/styles/index.scss +2 -0
- package/src/types.ts +140 -2
- package/types/blog/posts.data.d.ts +14 -0
- package/types/components/FfBackToTop.vue.d.ts +3 -0
- package/types/components/FfBanner.vue.d.ts +3 -0
- package/types/components/FfCopyStatus.vue.d.ts +3 -0
- package/types/components/FfDocMeta.vue.d.ts +3 -0
- package/types/components/FfFeature.vue.d.ts +13 -0
- package/types/components/FfFeedback.vue.d.ts +3 -0
- package/types/components/FfFooter.vue.d.ts +3 -0
- package/types/components/FfHero.vue.d.ts +42 -0
- package/types/components/FfHeroCommand.vue.d.ts +9 -0
- package/types/components/FfHomeSponsors.vue.d.ts +19 -0
- package/types/components/FfNavBarTitle.vue.d.ts +17 -0
- package/types/components/FfPost.vue.d.ts +3 -0
- package/types/components/FfProgress.vue.d.ts +3 -0
- package/types/components/FfVersionSwitcher.vue.d.ts +3 -0
- package/types/composables/blog.d.ts +10 -0
- package/types/composables/link.d.ts +12 -0
- package/types/composables/options.d.ts +15 -0
- package/types/composables/relativeTime.d.ts +2 -0
- package/types/composables/tabs.d.ts +15 -0
- package/types/content/Api.vue.d.ts +27 -0
- package/types/content/Badge.vue.d.ts +21 -0
- package/types/content/Callout.vue.d.ts +24 -0
- package/types/content/Card.vue.d.ts +23 -0
- package/types/content/CardGrid.vue.d.ts +20 -0
- package/types/content/FileTree.vue.d.ts +6 -0
- package/types/content/Kbd.vue.d.ts +15 -0
- package/types/content/Steps.vue.d.ts +15 -0
- package/types/content/Tab.vue.d.ts +19 -0
- package/types/content/Tabs.vue.d.ts +7 -0
- package/types/content/Timeline.vue.d.ts +21 -0
- package/types/content/TimelineItem.vue.d.ts +21 -0
- package/types/content/timeline.d.ts +3 -0
- package/types/index.d.ts +25 -0
- package/types/internal.d.ts +9 -0
- package/types/layout/FfBlog.vue.d.ts +3 -0
- package/types/layout/FfLayout.vue.d.ts +23 -0
- package/types/types.d.ts +256 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import {
|
|
3
|
-
computed, onMounted, onUnmounted, ref
|
|
3
|
+
computed, onMounted, onUnmounted, ref, watch
|
|
4
4
|
} from 'vue';
|
|
5
5
|
import { useLabels, useThemeOptions } from '../composables/options';
|
|
6
|
+
import { normalizeLink } from '../internal';
|
|
6
7
|
|
|
7
8
|
const options = useThemeOptions();
|
|
8
9
|
const labels = useLabels();
|
|
@@ -32,20 +33,42 @@ function dismiss() {
|
|
|
32
33
|
return;
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
try {
|
|
37
|
+
localStorage.setItem(`ff-banner-${banner.value.id}`, 'dismissed');
|
|
38
|
+
} catch {
|
|
39
|
+
// Private mode or full quota: the banner is dismissed for this page view only.
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Read before hiding: a mouse click leaves no visible focus, so only a keyboard user is moved.
|
|
43
|
+
const keyboard = document.activeElement?.matches(':focus-visible') ?? false;
|
|
44
|
+
|
|
36
45
|
document.documentElement.classList.add(DISMISSED);
|
|
37
46
|
height();
|
|
47
|
+
|
|
48
|
+
// The banner goes `display: none` under the focused close button. Hand focus to the next stop,
|
|
49
|
+
// VitePress' skip link, instead of letting it drop to <body>.
|
|
50
|
+
if (keyboard) {
|
|
51
|
+
document.querySelector<HTMLElement>('.VPSkipLink')?.focus();
|
|
52
|
+
}
|
|
38
53
|
}
|
|
39
54
|
|
|
40
|
-
|
|
55
|
+
// The banner can appear or go away after mount (locale switch, `v-if`), so the observer follows the
|
|
56
|
+
// element rather than being wired once.
|
|
57
|
+
watch(el, (node) => {
|
|
58
|
+
observer?.disconnect();
|
|
59
|
+
observer = undefined;
|
|
41
60
|
height();
|
|
42
61
|
|
|
43
|
-
if (
|
|
62
|
+
if (node) {
|
|
44
63
|
observer = new ResizeObserver(height);
|
|
45
|
-
observer.observe(
|
|
64
|
+
observer.observe(node);
|
|
46
65
|
}
|
|
66
|
+
}, {
|
|
67
|
+
flush: 'post'
|
|
47
68
|
});
|
|
48
69
|
|
|
70
|
+
onMounted(height);
|
|
71
|
+
|
|
49
72
|
onUnmounted(() => {
|
|
50
73
|
observer?.disconnect();
|
|
51
74
|
document.documentElement.style.removeProperty('--vp-layout-top-height');
|
|
@@ -63,7 +86,7 @@ onUnmounted(() => {
|
|
|
63
86
|
<component
|
|
64
87
|
:is="banner.link ? 'a' : 'div'"
|
|
65
88
|
class="ff-banner-body"
|
|
66
|
-
:href="banner.link"
|
|
89
|
+
:href="banner.link ? normalizeLink(banner.link) : undefined"
|
|
67
90
|
>
|
|
68
91
|
<span
|
|
69
92
|
v-if="banner.icon"
|
|
@@ -78,7 +101,7 @@ onUnmounted(() => {
|
|
|
78
101
|
v-if="banner.link"
|
|
79
102
|
class="ff-banner-cta"
|
|
80
103
|
>
|
|
81
|
-
{{ banner.linkText ??
|
|
104
|
+
{{ banner.linkText ?? labels.bannerCta }}
|
|
82
105
|
<span aria-hidden="true">→</span>
|
|
83
106
|
</span>
|
|
84
107
|
</component>
|
|
@@ -89,7 +112,18 @@ onUnmounted(() => {
|
|
|
89
112
|
:aria-label="labels.bannerDismiss"
|
|
90
113
|
@click="dismiss"
|
|
91
114
|
>
|
|
92
|
-
|
|
115
|
+
<svg
|
|
116
|
+
width="12"
|
|
117
|
+
height="12"
|
|
118
|
+
viewBox="0 0 12 12"
|
|
119
|
+
fill="none"
|
|
120
|
+
stroke="currentColor"
|
|
121
|
+
stroke-width="1.5"
|
|
122
|
+
stroke-linecap="round"
|
|
123
|
+
aria-hidden="true"
|
|
124
|
+
>
|
|
125
|
+
<path d="M1.5 1.5l9 9M10.5 1.5l-9 9" />
|
|
126
|
+
</svg>
|
|
93
127
|
</button>
|
|
94
128
|
</div>
|
|
95
129
|
</template>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import {
|
|
3
|
+
onMounted, onUnmounted, ref
|
|
4
|
+
} from 'vue';
|
|
5
|
+
import { useLabels } from '../composables/options';
|
|
6
|
+
|
|
7
|
+
const labels = useLabels();
|
|
8
|
+
const message = ref('');
|
|
9
|
+
|
|
10
|
+
// VitePress confirms a code block copy with a CSS `::before` only, which screen readers never
|
|
11
|
+
// hear. Its click handler adds `.copied` once the clipboard write succeeds, so the class is what
|
|
12
|
+
// gets watched rather than the click itself.
|
|
13
|
+
const BUTTON = 'div[class*="language-"] > button.copy';
|
|
14
|
+
|
|
15
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
16
|
+
|
|
17
|
+
function announce() {
|
|
18
|
+
message.value = labels.value.heroCopied;
|
|
19
|
+
|
|
20
|
+
clearTimeout(timer);
|
|
21
|
+
timer = setTimeout(() => (message.value = ''), 2000);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function onClick(event: MouseEvent) {
|
|
25
|
+
const button = (event.target as Element | null)?.closest?.(BUTTON);
|
|
26
|
+
|
|
27
|
+
if (!button) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Cleared first, so a second copy within two seconds is announced again.
|
|
32
|
+
message.value = '';
|
|
33
|
+
|
|
34
|
+
const observer = new MutationObserver(() => {
|
|
35
|
+
if (button.classList.contains('copied')) {
|
|
36
|
+
observer.disconnect();
|
|
37
|
+
announce();
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
observer.observe(button, {
|
|
42
|
+
attributeFilter: [
|
|
43
|
+
'class'
|
|
44
|
+
]
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// A failed write never adds the class: stop watching once the confirmation window is over.
|
|
48
|
+
setTimeout(() => observer.disconnect(), 2000);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
onMounted(() => window.addEventListener('click', onClick));
|
|
52
|
+
|
|
53
|
+
onUnmounted(() => {
|
|
54
|
+
window.removeEventListener('click', onClick);
|
|
55
|
+
clearTimeout(timer);
|
|
56
|
+
});
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
<template>
|
|
60
|
+
<span
|
|
61
|
+
class="visually-hidden"
|
|
62
|
+
aria-live="polite"
|
|
63
|
+
>{{ message }}</span>
|
|
64
|
+
</template>
|
|
@@ -4,6 +4,8 @@ import {
|
|
|
4
4
|
} from 'vue';
|
|
5
5
|
import { useData } from 'vitepress';
|
|
6
6
|
import { useLayout } from '../internal';
|
|
7
|
+
import { useCopy } from '../composables/tabs';
|
|
8
|
+
import { formatRelative } from '../composables/relativeTime';
|
|
7
9
|
import {
|
|
8
10
|
format, useLabels, useThemeOptions
|
|
9
11
|
} from '../composables/options';
|
|
@@ -63,14 +65,26 @@ const section = computed(() => {
|
|
|
63
65
|
|
|
64
66
|
const words = ref(0);
|
|
65
67
|
|
|
68
|
+
// Splitting the whole page is only worth it when the estimate can be shown.
|
|
69
|
+
const measured = computed(() => !!meta.value && meta.value.readingTime !== false);
|
|
70
|
+
|
|
66
71
|
function measure() {
|
|
72
|
+
if (!measured.value) {
|
|
73
|
+
words.value = 0;
|
|
74
|
+
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
67
78
|
words.value =
|
|
68
79
|
document.querySelector('.vp-doc')?.textContent?.trim().split(/\s+/).filter(Boolean)
|
|
69
80
|
.length ?? 0;
|
|
70
81
|
}
|
|
71
82
|
|
|
72
83
|
onMounted(() => nextTick(measure));
|
|
73
|
-
watch(
|
|
84
|
+
watch([
|
|
85
|
+
() => page.value.relativePath,
|
|
86
|
+
measured
|
|
87
|
+
], () => nextTick(measure));
|
|
74
88
|
|
|
75
89
|
const minutes = computed(() => {
|
|
76
90
|
if (!meta.value || meta.value.readingTime === false || !words.value) {
|
|
@@ -84,56 +98,35 @@ const minutes = computed(() => {
|
|
|
84
98
|
// Last updated
|
|
85
99
|
// --------------------------------------------------------------------------------------------- //
|
|
86
100
|
|
|
87
|
-
const units: [Intl.RelativeTimeFormatUnit, number][] = [
|
|
88
|
-
[
|
|
89
|
-
'year',
|
|
90
|
-
31536000000
|
|
91
|
-
],
|
|
92
|
-
[
|
|
93
|
-
'month',
|
|
94
|
-
2592000000
|
|
95
|
-
],
|
|
96
|
-
[
|
|
97
|
-
'week',
|
|
98
|
-
604800000
|
|
99
|
-
],
|
|
100
|
-
[
|
|
101
|
-
'day',
|
|
102
|
-
86400000
|
|
103
|
-
],
|
|
104
|
-
[
|
|
105
|
-
'hour',
|
|
106
|
-
3600000
|
|
107
|
-
],
|
|
108
|
-
[
|
|
109
|
-
'minute',
|
|
110
|
-
60000
|
|
111
|
-
]
|
|
112
|
-
];
|
|
113
|
-
|
|
114
101
|
const updated = computed(() => {
|
|
115
102
|
if (!meta.value || meta.value.lastUpdated === false || !page.value.lastUpdated) {
|
|
116
103
|
return null;
|
|
117
104
|
}
|
|
118
105
|
|
|
119
|
-
|
|
120
|
-
const relative = new Intl.RelativeTimeFormat(lang.value, {
|
|
121
|
-
numeric: 'auto'
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
for (const [
|
|
125
|
-
unit,
|
|
126
|
-
ms
|
|
127
|
-
] of units) {
|
|
128
|
-
if (Math.abs(elapsed) >= ms) {
|
|
129
|
-
return relative.format(Math.round(elapsed / ms), unit);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
return relative.format(0, 'minute');
|
|
106
|
+
return formatRelative(page.value.lastUpdated, lang.value);
|
|
134
107
|
});
|
|
135
108
|
|
|
136
|
-
const
|
|
109
|
+
const updatedAt = computed(() =>
|
|
110
|
+
page.value.lastUpdated ? new Date(page.value.lastUpdated).toISOString() : undefined
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
// --------------------------------------------------------------------------------------------- //
|
|
114
|
+
// Copy as Markdown
|
|
115
|
+
//
|
|
116
|
+
// The source is put on the page data at build time by `ffTransformPageData`; without it the
|
|
117
|
+
// button has nothing to copy and stays out.
|
|
118
|
+
// --------------------------------------------------------------------------------------------- //
|
|
119
|
+
|
|
120
|
+
const markdown = computed(() => (page.value as { ffMarkdown?: string }).ffMarkdown ?? '');
|
|
121
|
+
|
|
122
|
+
const copyable = computed(() => options.value.copyMarkdown === true && !!markdown.value);
|
|
123
|
+
|
|
124
|
+
const { copied, copy } = useCopy(markdown);
|
|
125
|
+
|
|
126
|
+
// The block stays for the button even when the kicker itself is switched off.
|
|
127
|
+
const hidden = computed(
|
|
128
|
+
() => (!meta.value && !copyable.value) || frontmatter.value.layout === 'home'
|
|
129
|
+
);
|
|
137
130
|
</script>
|
|
138
131
|
|
|
139
132
|
<template>
|
|
@@ -153,12 +146,23 @@ const hidden = computed(() => !meta.value || frontmatter.value.layout === 'home'
|
|
|
153
146
|
>
|
|
154
147
|
{{ format(labels.readingTime, minutes) }}
|
|
155
148
|
</span>
|
|
156
|
-
<
|
|
149
|
+
<time
|
|
157
150
|
v-if="updated"
|
|
158
151
|
class="ff-doc-meta-item"
|
|
152
|
+
:datetime="updatedAt"
|
|
159
153
|
>
|
|
160
154
|
{{ format(labels.lastUpdated, updated) }}
|
|
161
|
-
</
|
|
155
|
+
</time>
|
|
162
156
|
</ClientOnly>
|
|
157
|
+
|
|
158
|
+
<button
|
|
159
|
+
v-if="copyable"
|
|
160
|
+
type="button"
|
|
161
|
+
class="ff-doc-meta-copy"
|
|
162
|
+
:class="{ copied }"
|
|
163
|
+
@click="copy"
|
|
164
|
+
>
|
|
165
|
+
<span aria-live="polite">{{ copied ? labels.heroCopied : labels.copyMarkdown }}</span>
|
|
166
|
+
</button>
|
|
163
167
|
</div>
|
|
164
168
|
</template>
|
|
@@ -15,9 +15,11 @@ const props = defineProps<{
|
|
|
15
15
|
</script>
|
|
16
16
|
|
|
17
17
|
<template>
|
|
18
|
-
|
|
18
|
+
<!-- Only the title is the link, stretched over the card in CSS: wrapping the whole card made the
|
|
19
|
+
heading, details and call to action all part of the link's accessible name. -->
|
|
20
|
+
<article
|
|
19
21
|
class="VPFeature ff-feature"
|
|
20
|
-
|
|
22
|
+
:class="{ 'ff-feature-linked': link }"
|
|
21
23
|
>
|
|
22
24
|
<span
|
|
23
25
|
class="ff-feature-index"
|
|
@@ -42,10 +44,19 @@ const props = defineProps<{
|
|
|
42
44
|
v-html="icon"
|
|
43
45
|
/>
|
|
44
46
|
|
|
45
|
-
<h2
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
<h2 class="ff-feature-title">
|
|
48
|
+
<VPLink
|
|
49
|
+
v-if="link"
|
|
50
|
+
class="ff-feature-anchor"
|
|
51
|
+
v-bind="cardLinkProps(props.link, props.rel, props.target)"
|
|
52
|
+
>
|
|
53
|
+
<span v-html="title" />
|
|
54
|
+
</VPLink>
|
|
55
|
+
<span
|
|
56
|
+
v-else
|
|
57
|
+
v-html="title"
|
|
58
|
+
/>
|
|
59
|
+
</h2>
|
|
49
60
|
|
|
50
61
|
<ul
|
|
51
62
|
v-if="Array.isArray(details)"
|
|
@@ -70,5 +81,5 @@ const props = defineProps<{
|
|
|
70
81
|
{{ linkText }}
|
|
71
82
|
<span aria-hidden="true">→</span>
|
|
72
83
|
</span>
|
|
73
|
-
</
|
|
84
|
+
</article>
|
|
74
85
|
</template>
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import {
|
|
3
|
+
computed, nextTick, ref, watch
|
|
4
|
+
} from 'vue';
|
|
5
|
+
import { useData } from 'vitepress';
|
|
6
|
+
import { useLabels, useThemeOptions } from '../composables/options';
|
|
7
|
+
|
|
8
|
+
const { page, frontmatter, lang } = useData();
|
|
9
|
+
const options = useThemeOptions();
|
|
10
|
+
const labels = useLabels();
|
|
11
|
+
|
|
12
|
+
const config = computed(() => {
|
|
13
|
+
const { feedback } = options.value;
|
|
14
|
+
|
|
15
|
+
if (!feedback || frontmatter.value.feedback === false) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return feedback === true ? {} : feedback;
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const question = computed(() => config.value?.question || labels.value.feedbackQuestion);
|
|
23
|
+
|
|
24
|
+
const voted = ref(false);
|
|
25
|
+
const thanks = ref<HTMLElement | null>(null);
|
|
26
|
+
|
|
27
|
+
// The widget is reused across client-side navigation, so each page starts unanswered.
|
|
28
|
+
watch(() => page.value.relativePath, () => (voted.value = false));
|
|
29
|
+
|
|
30
|
+
function vote(value: 'yes' | 'no') {
|
|
31
|
+
const payload = {
|
|
32
|
+
page: page.value.relativePath,
|
|
33
|
+
value,
|
|
34
|
+
lang: lang.value
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
voted.value = true;
|
|
38
|
+
|
|
39
|
+
// The buttons leave the DOM with the vote: hand focus to the thank-you line instead of <body>.
|
|
40
|
+
nextTick(() => thanks.value?.focus());
|
|
41
|
+
|
|
42
|
+
// A string keeps the request CORS-safelisted (text/plain); a JSON Blob would trigger a
|
|
43
|
+
// preflight that cross-origin endpoints rarely answer.
|
|
44
|
+
if (config.value?.url) {
|
|
45
|
+
navigator.sendBeacon(config.value.url, JSON.stringify(payload));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Always emitted, so a site can forward the vote itself (a function cannot live in `themeConfig`).
|
|
49
|
+
window.dispatchEvent(new CustomEvent('ff:feedback', {
|
|
50
|
+
detail: payload
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<template>
|
|
56
|
+
<div
|
|
57
|
+
v-if="config"
|
|
58
|
+
class="ff-feedback"
|
|
59
|
+
>
|
|
60
|
+
<p
|
|
61
|
+
v-if="!voted"
|
|
62
|
+
class="ff-feedback-question ff-label"
|
|
63
|
+
>
|
|
64
|
+
{{ question }}
|
|
65
|
+
</p>
|
|
66
|
+
|
|
67
|
+
<div
|
|
68
|
+
v-if="!voted"
|
|
69
|
+
class="ff-feedback-actions"
|
|
70
|
+
>
|
|
71
|
+
<button
|
|
72
|
+
type="button"
|
|
73
|
+
class="ff-feedback-button ff-label"
|
|
74
|
+
@click="vote('yes')"
|
|
75
|
+
>
|
|
76
|
+
{{ labels.feedbackYes }}
|
|
77
|
+
</button>
|
|
78
|
+
<button
|
|
79
|
+
type="button"
|
|
80
|
+
class="ff-feedback-button ff-label"
|
|
81
|
+
@click="vote('no')"
|
|
82
|
+
>
|
|
83
|
+
{{ labels.feedbackNo }}
|
|
84
|
+
</button>
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
<p
|
|
88
|
+
ref="thanks"
|
|
89
|
+
class="ff-feedback-thanks ff-label"
|
|
90
|
+
tabindex="-1"
|
|
91
|
+
aria-live="polite"
|
|
92
|
+
>
|
|
93
|
+
{{ voted ? labels.feedbackThanks : '' }}
|
|
94
|
+
</p>
|
|
95
|
+
</div>
|
|
96
|
+
</template>
|
|
@@ -55,10 +55,11 @@ const visible = computed(
|
|
|
55
55
|
v-if="columns.length"
|
|
56
56
|
class="ff-footer-columns"
|
|
57
57
|
>
|
|
58
|
-
<
|
|
58
|
+
<nav
|
|
59
59
|
v-for="column in columns"
|
|
60
60
|
:key="column.title"
|
|
61
61
|
class="ff-footer-column"
|
|
62
|
+
:aria-label="column.title"
|
|
62
63
|
>
|
|
63
64
|
<p class="ff-label">
|
|
64
65
|
{{ column.title }}
|
|
@@ -78,12 +79,13 @@ const visible = computed(
|
|
|
78
79
|
</VPLink>
|
|
79
80
|
</li>
|
|
80
81
|
</ul>
|
|
81
|
-
</
|
|
82
|
+
</nav>
|
|
82
83
|
</div>
|
|
83
84
|
|
|
84
|
-
<
|
|
85
|
+
<nav
|
|
85
86
|
v-if="social.length"
|
|
86
87
|
class="ff-footer-column ff-footer-social"
|
|
88
|
+
:aria-label="labels.footerSocial"
|
|
87
89
|
>
|
|
88
90
|
<p class="ff-label">
|
|
89
91
|
{{ labels.footerSocial }}
|
|
@@ -97,14 +99,18 @@ const visible = computed(
|
|
|
97
99
|
<a
|
|
98
100
|
:href="item.link"
|
|
99
101
|
:target="item.target ?? '_blank'"
|
|
100
|
-
rel="me noopener"
|
|
102
|
+
rel="me noopener noreferrer"
|
|
101
103
|
>
|
|
102
104
|
<VPIcon :icon="item.icon" />
|
|
103
105
|
<span>{{ item.text }}</span>
|
|
106
|
+
<span
|
|
107
|
+
v-if="(item.target ?? '_blank') === '_blank'"
|
|
108
|
+
class="visually-hidden"
|
|
109
|
+
>({{ labels.newTab }})</span>
|
|
104
110
|
</a>
|
|
105
111
|
</li>
|
|
106
112
|
</ul>
|
|
107
|
-
</
|
|
113
|
+
</nav>
|
|
108
114
|
</div>
|
|
109
115
|
|
|
110
116
|
<div
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import {
|
|
3
|
-
Comment, computed, Fragment, Text, useSlots, type VNode
|
|
3
|
+
Comment, computed, Fragment, onBeforeUpdate, Text, useSlots, type VNode
|
|
4
4
|
} from 'vue';
|
|
5
5
|
import { useData } from 'vitepress';
|
|
6
|
-
import { VPImage } from '../internal';
|
|
6
|
+
import { normalizeLink, VPImage } from '../internal';
|
|
7
7
|
import FfHeroCommand from './FfHeroCommand.vue';
|
|
8
8
|
import type { HeroExtras, HeroMetaItem } from '../types';
|
|
9
9
|
import type { DefaultTheme } from 'vitepress/theme';
|
|
@@ -64,9 +64,19 @@ function filled(nodes?: VNode[]): boolean {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
// Called from the template rather than cached in a computed: the slot has to be rendered where its
|
|
67
|
-
// dependencies are tracked, and it changes with the page.
|
|
67
|
+
// dependencies are tracked, and it changes with the page. It is still only rendered once per
|
|
68
|
+
// render — the template and the helpers below ask several times — so the answer is kept until the
|
|
69
|
+
// next update starts.
|
|
70
|
+
let imageCache: boolean | undefined;
|
|
71
|
+
|
|
72
|
+
onBeforeUpdate(() => {
|
|
73
|
+
imageCache = undefined;
|
|
74
|
+
});
|
|
75
|
+
|
|
68
76
|
function hasImage() {
|
|
69
|
-
|
|
77
|
+
imageCache ??= !!props.image || filled(slots['home-hero-image']?.());
|
|
78
|
+
|
|
79
|
+
return imageCache;
|
|
70
80
|
}
|
|
71
81
|
|
|
72
82
|
// The second column carries the image when there is one, and the starting point otherwise. The
|
|
@@ -139,9 +149,9 @@ function hasInlineCommand() {
|
|
|
139
149
|
:key="action.link"
|
|
140
150
|
class="ff-btn"
|
|
141
151
|
:class="`ff-btn-${action.theme ?? 'brand'}`"
|
|
142
|
-
:href="action.link"
|
|
152
|
+
:href="normalizeLink(action.link)"
|
|
143
153
|
:target="action.target"
|
|
144
|
-
:rel="action.rel"
|
|
154
|
+
:rel="action.rel ?? (action.target === '_blank' ? 'noopener' : undefined)"
|
|
145
155
|
>
|
|
146
156
|
{{ action.text }}
|
|
147
157
|
</a>
|
|
@@ -176,7 +186,7 @@ function hasInlineCommand() {
|
|
|
176
186
|
</slot>
|
|
177
187
|
</div>
|
|
178
188
|
|
|
179
|
-
<
|
|
189
|
+
<div
|
|
180
190
|
v-else-if="hasPanel()"
|
|
181
191
|
class="ff-hero-panel"
|
|
182
192
|
:class="{ 'ff-hero-panel-bare': !hasActions }"
|
|
@@ -197,14 +207,14 @@ function hasInlineCommand() {
|
|
|
197
207
|
:key="action.link"
|
|
198
208
|
class="ff-btn"
|
|
199
209
|
:class="`ff-btn-${action.theme ?? 'brand'}`"
|
|
200
|
-
:href="action.link"
|
|
210
|
+
:href="normalizeLink(action.link)"
|
|
201
211
|
:target="action.target"
|
|
202
|
-
:rel="action.rel"
|
|
212
|
+
:rel="action.rel ?? (action.target === '_blank' ? 'noopener' : undefined)"
|
|
203
213
|
>
|
|
204
214
|
{{ action.text }}
|
|
205
215
|
</a>
|
|
206
216
|
</div>
|
|
207
|
-
</
|
|
217
|
+
</div>
|
|
208
218
|
</div>
|
|
209
219
|
|
|
210
220
|
<dl
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
computed, onUnmounted, ref, watch
|
|
4
|
-
} from 'vue';
|
|
2
|
+
import { computed, useId } from 'vue';
|
|
5
3
|
import { format, useLabels } from '../composables/options';
|
|
4
|
+
import { useCopy, useTabs } from '../composables/tabs';
|
|
6
5
|
import type { HeroCommandTab } from '../types';
|
|
7
6
|
|
|
8
7
|
// Used from both hero panel positions (inline and beside the headline, see FfHero), which are
|
|
@@ -19,33 +18,15 @@ const tabs = computed<HeroCommandTab[] | undefined>(() =>
|
|
|
19
18
|
Array.isArray(props.command) ? props.command : undefined
|
|
20
19
|
);
|
|
21
20
|
|
|
22
|
-
const activeTab =
|
|
21
|
+
const { active: activeTab, select, onKeydown } = useTabs(() => tabs.value?.map((tab) => tab.label) ?? []);
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
// component (two home pages in the same site), so the index is reset rather than left pointing
|
|
26
|
-
// past the end.
|
|
27
|
-
watch(tabs, () => (activeTab.value = 0));
|
|
23
|
+
const id = useId();
|
|
28
24
|
|
|
29
25
|
const activeCommand = computed<string>(() =>
|
|
30
26
|
tabs.value ? (tabs.value[activeTab.value]?.value ?? '') : (props.command as string)
|
|
31
27
|
);
|
|
32
28
|
|
|
33
|
-
const copied =
|
|
34
|
-
let copiedTimer: ReturnType<typeof setTimeout> | undefined;
|
|
35
|
-
|
|
36
|
-
async function copy() {
|
|
37
|
-
if (!activeCommand.value) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
await navigator.clipboard.writeText(activeCommand.value);
|
|
42
|
-
copied.value = true;
|
|
43
|
-
|
|
44
|
-
clearTimeout(copiedTimer);
|
|
45
|
-
copiedTimer = setTimeout(() => (copied.value = false), 2000);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
onUnmounted(() => clearTimeout(copiedTimer));
|
|
29
|
+
const { copied, copy } = useCopy(activeCommand);
|
|
49
30
|
</script>
|
|
50
31
|
|
|
51
32
|
<template>
|
|
@@ -61,22 +42,33 @@ onUnmounted(() => clearTimeout(copiedTimer));
|
|
|
61
42
|
v-if="tabs"
|
|
62
43
|
class="ff-hero-command-tabs"
|
|
63
44
|
role="tablist"
|
|
45
|
+
:aria-label="labels.heroInstall"
|
|
46
|
+
@keydown="onKeydown"
|
|
64
47
|
>
|
|
65
48
|
<button
|
|
66
49
|
v-for="(tab, index) in tabs"
|
|
50
|
+
:id="`${id}-tab-${index}`"
|
|
67
51
|
:key="tab.label"
|
|
68
52
|
type="button"
|
|
69
53
|
role="tab"
|
|
70
54
|
class="ff-hero-command-tab"
|
|
71
55
|
:class="{ active: index === activeTab }"
|
|
72
56
|
:aria-selected="index === activeTab"
|
|
73
|
-
|
|
57
|
+
:aria-controls="`${id}-panel`"
|
|
58
|
+
:tabindex="index === activeTab ? 0 : -1"
|
|
59
|
+
@click="select(index)"
|
|
74
60
|
>
|
|
75
61
|
{{ tab.label }}
|
|
76
62
|
</button>
|
|
77
63
|
</div>
|
|
78
64
|
|
|
79
|
-
|
|
65
|
+
<!-- One panel whose command follows the active tab, rather than one panel per tab. -->
|
|
66
|
+
<div
|
|
67
|
+
:id="tabs ? `${id}-panel` : undefined"
|
|
68
|
+
class="ff-hero-command"
|
|
69
|
+
:role="tabs ? 'tabpanel' : undefined"
|
|
70
|
+
:aria-labelledby="tabs ? `${id}-tab-${activeTab}` : undefined"
|
|
71
|
+
>
|
|
80
72
|
<code>
|
|
81
73
|
<span
|
|
82
74
|
class="ff-hero-prompt"
|
|
@@ -89,13 +81,18 @@ onUnmounted(() => clearTimeout(copiedTimer));
|
|
|
89
81
|
<span
|
|
90
82
|
v-if="copied"
|
|
91
83
|
class="ff-hero-copied ff-label"
|
|
84
|
+
aria-hidden="true"
|
|
92
85
|
>{{ labels.heroCopied }}</span>
|
|
93
86
|
|
|
87
|
+
<span
|
|
88
|
+
class="visually-hidden"
|
|
89
|
+
aria-live="polite"
|
|
90
|
+
>{{ copied ? labels.heroCopied : '' }}</span>
|
|
91
|
+
|
|
94
92
|
<button
|
|
95
93
|
type="button"
|
|
96
94
|
class="ff-hero-copy"
|
|
97
95
|
:class="{ copied }"
|
|
98
|
-
:title="format(labels.heroCopyLabel, activeCommand)"
|
|
99
96
|
:aria-label="format(labels.heroCopyLabel, activeCommand)"
|
|
100
97
|
@click="copy"
|
|
101
98
|
/>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { VPSponsors } from '../internal';
|
|
2
|
+
import { normalizeLink, VPSponsors } from '../internal';
|
|
3
3
|
import { useLabels } from '../composables/options';
|
|
4
4
|
|
|
5
5
|
export interface SponsorItem {
|
|
@@ -48,7 +48,7 @@ const labels = useLabels();
|
|
|
48
48
|
>
|
|
49
49
|
<a
|
|
50
50
|
class="ff-btn ff-btn-alt no-icon"
|
|
51
|
-
:href="actionLink"
|
|
51
|
+
:href="normalizeLink(actionLink)"
|
|
52
52
|
>{{ actionText ?? labels.sponsorsAction }}</a>
|
|
53
53
|
</div>
|
|
54
54
|
</div>
|