@frontfactory/vitepress-theme 1.7.0 → 1.9.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 +83 -0
- package/README.md +163 -7
- package/config.d.ts +27 -1
- package/config.js +186 -21
- package/dist/style.css +1 -1
- package/node/blog.d.ts +3 -0
- package/node/blog.js +19 -0
- package/node/llms.js +32 -0
- package/node/og.js +158 -0
- package/node/pages.js +162 -0
- package/node/rss.js +78 -0
- package/package.json +42 -28
- package/src/blog/posts.data.ts +47 -0
- package/src/components/FfBackToTop.vue +19 -10
- package/src/components/FfBanner.vue +24 -6
- package/src/components/FfCopyStatus.vue +64 -0
- package/src/components/FfDocMeta.vue +325 -3
- package/src/components/FfFeature.vue +18 -7
- package/src/components/FfFeedback.vue +96 -0
- package/src/components/FfHero.vue +26 -35
- package/src/components/FfHeroActions.vue +44 -0
- package/src/components/FfHeroCommand.vue +22 -35
- package/src/components/FfHomeSponsors.vue +2 -2
- package/src/components/FfNavBarTitle.vue +63 -0
- package/src/components/FfPost.vue +50 -0
- package/src/components/FfProgress.vue +69 -0
- package/src/components/FfVersionSwitcher.vue +20 -0
- package/src/composables/blog.ts +41 -0
- package/src/composables/copy.ts +36 -0
- package/src/composables/options.ts +20 -1
- package/src/composables/tabs.ts +122 -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 +95 -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 +8 -2
- package/src/layout/FfBlog.vue +62 -0
- package/src/layout/FfLayout.vue +20 -4
- package/src/styles/_base.scss +6 -14
- package/src/styles/_blocks.scss +29 -8
- package/src/styles/_blog.scss +130 -0
- package/src/styles/_breakpoints.scss +26 -0
- package/src/styles/_code.scss +11 -17
- package/src/styles/_content.scss +377 -18
- package/src/styles/_doc.scss +32 -29
- package/src/styles/_home.scss +47 -65
- package/src/styles/_mixins.scss +63 -0
- package/src/styles/_motion.scss +24 -13
- package/src/styles/_nav.scss +90 -24
- package/src/styles/_print.scss +77 -0
- package/src/styles/_sidebar.scss +7 -10
- package/src/styles/_tokens.scss +92 -11
- package/src/styles/index.scss +2 -0
- package/src/types.ts +148 -0
- 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/FfHeroActions.vue.d.ts +19 -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/copy.d.ts +6 -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 +10 -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 +10 -0
- package/types/layout/FfBlog.vue.d.ts +3 -0
- package/types/layout/FfLayout.vue.d.ts +23 -0
- package/types/types.d.ts +280 -0
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import {
|
|
3
|
-
computed, nextTick, onMounted, ref, watch
|
|
3
|
+
computed, h, nextTick, onMounted, onUnmounted, ref, watch
|
|
4
4
|
} from 'vue';
|
|
5
5
|
import { useData } from 'vitepress';
|
|
6
6
|
import { useLayout } from '../internal';
|
|
7
|
+
import { useCopy } from '../composables/copy';
|
|
7
8
|
import { formatRelative } from '../composables/relativeTime';
|
|
8
9
|
import {
|
|
9
10
|
format, useLabels, useThemeOptions
|
|
@@ -64,14 +65,26 @@ const section = computed(() => {
|
|
|
64
65
|
|
|
65
66
|
const words = ref(0);
|
|
66
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
|
+
|
|
67
71
|
function measure() {
|
|
72
|
+
if (!measured.value) {
|
|
73
|
+
words.value = 0;
|
|
74
|
+
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
68
78
|
words.value =
|
|
69
79
|
document.querySelector('.vp-doc')?.textContent?.trim().split(/\s+/).filter(Boolean)
|
|
70
80
|
.length ?? 0;
|
|
71
81
|
}
|
|
72
82
|
|
|
73
83
|
onMounted(() => nextTick(measure));
|
|
74
|
-
watch(
|
|
84
|
+
watch([
|
|
85
|
+
() => page.value.relativePath,
|
|
86
|
+
measured
|
|
87
|
+
], () => nextTick(measure));
|
|
75
88
|
|
|
76
89
|
const minutes = computed(() => {
|
|
77
90
|
if (!meta.value || meta.value.readingTime === false || !words.value) {
|
|
@@ -97,7 +110,223 @@ const updatedAt = computed(() =>
|
|
|
97
110
|
page.value.lastUpdated ? new Date(page.value.lastUpdated).toISOString() : undefined
|
|
98
111
|
);
|
|
99
112
|
|
|
100
|
-
|
|
113
|
+
// --------------------------------------------------------------------------------------------- //
|
|
114
|
+
// Page actions menu
|
|
115
|
+
//
|
|
116
|
+
// Copying the Markdown source needs `ffMarkdown`, put on the page data at build time by
|
|
117
|
+
// `ffTransformPageData`; without it that action stays out. `copyMarkdown` is the older spelling of
|
|
118
|
+
// `pageActions: { copyMarkdown: true }`.
|
|
119
|
+
// --------------------------------------------------------------------------------------------- //
|
|
120
|
+
|
|
121
|
+
type Network = 'x' | 'linkedin' | 'bluesky' | 'mastodon';
|
|
122
|
+
|
|
123
|
+
// 24px viewBox paths: the interface icons are stroked, the brand ones (Simple Icons, CC0) filled.
|
|
124
|
+
const icons = {
|
|
125
|
+
copy: 'M10 8h10a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H10a2 2 0 0 1-2-2V10a2 2 0 0 1 2-2zM4 16a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2',
|
|
126
|
+
check: 'M20 6 9 17l-5-5',
|
|
127
|
+
link: 'M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71',
|
|
128
|
+
share: 'M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8M16 6l-4-4-4 4M12 2v13',
|
|
129
|
+
chevron: 'm6 9 6 6 6-6',
|
|
130
|
+
external: 'M7 7h10v10M7 17 17 7'
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const brands: Record<Network, string> = {
|
|
134
|
+
x: 'M18.901 1.153h3.68l-8.04 9.19L24 22.846h-7.406l-5.8-7.584-6.638 7.584H.474l8.6-9.83L0 1.154h7.594l5.243 6.932ZM17.61 20.644h2.039L6.486 3.24H4.298Z',
|
|
135
|
+
linkedin: 'M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z',
|
|
136
|
+
bluesky: 'M12 10.8c-1.087-2.114-4.046-6.053-6.798-7.995C2.566.944 1.561 1.266.902 1.565.139 1.908 0 3.08 0 3.768c0 .69.378 5.65.624 6.479.815 2.736 3.713 3.66 6.383 3.364.136-.02.275-.039.415-.056-.138.022-.276.04-.415.056-3.912.58-7.387 2.005-2.83 7.078 5.013 5.19 6.87-1.113 7.823-4.308.953 3.195 2.05 9.271 7.733 4.308 4.267-4.308 1.172-6.498-2.74-7.078a8.741 8.741 0 0 1-.415-.056c.14.017.279.036.415.056 2.67.297 5.568-.628 6.383-3.364.246-.828.624-5.79.624-6.478 0-.69-.139-1.861-.902-2.206-.659-.298-1.664-.62-4.3 1.24C16.046 4.748 13.087 8.687 12 10.8Z',
|
|
137
|
+
mastodon: 'M23.268 5.313c-.35-2.578-2.617-4.61-5.304-5.004C17.51.242 15.792 0 11.813 0h-.03c-3.98 0-4.835.242-5.288.309C3.882.692 1.496 2.518.917 5.127.64 6.412.61 7.837.661 9.143c.074 1.874.088 3.745.26 5.611.118 1.24.325 2.47.62 3.68.55 2.237 2.777 4.098 4.96 4.857 2.336.792 4.849.923 7.256.38.265-.061.527-.132.786-.213.585-.184 1.27-.39 1.774-.753a.057.057 0 0 0 .023-.043v-1.809a.052.052 0 0 0-.02-.041.053.053 0 0 0-.046-.01 20.282 20.282 0 0 1-4.709.545c-2.73 0-3.463-1.284-3.674-1.818a5.593 5.593 0 0 1-.319-1.433.053.053 0 0 1 .066-.054c1.517.363 3.072.546 4.632.546.376 0 .75 0 1.125-.01 1.57-.044 3.224-.124 4.768-.422.038-.008.077-.015.11-.024 2.435-.464 4.753-1.92 4.989-5.604.008-.145.03-1.52.03-1.67.002-.512.167-3.63-.024-5.545zm-3.748 9.195h-2.561V8.29c0-1.309-.55-1.976-1.67-1.976-1.23 0-1.846.79-1.846 2.35v3.403h-2.546V8.663c0-1.56-.617-2.35-1.848-2.35-1.112 0-1.668.668-1.67 1.977v6.218H4.822V8.102c0-1.31.337-2.35 1.011-3.12.696-.77 1.608-1.164 2.74-1.164 1.311 0 2.302.5 2.962 1.498l.638 1.06.638-1.06c.66-.999 1.65-1.498 2.96-1.498 1.13 0 2.043.395 2.74 1.164.675.77 1.012 1.81 1.012 3.12z'
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const networks: Record<
|
|
141
|
+
Network,
|
|
142
|
+
{
|
|
143
|
+
name: string
|
|
144
|
+
url: (url: string, text: string, instance: string) => string
|
|
145
|
+
}
|
|
146
|
+
> = {
|
|
147
|
+
x: {
|
|
148
|
+
name: 'X',
|
|
149
|
+
url: (url, text) =>
|
|
150
|
+
`https://twitter.com/intent/tweet?url=${encodeURIComponent(url)}&text=${encodeURIComponent(text)}`
|
|
151
|
+
},
|
|
152
|
+
linkedin: {
|
|
153
|
+
name: 'LinkedIn',
|
|
154
|
+
url: (url) =>
|
|
155
|
+
`https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(url)}`
|
|
156
|
+
},
|
|
157
|
+
bluesky: {
|
|
158
|
+
name: 'Bluesky',
|
|
159
|
+
url: (url, text) =>
|
|
160
|
+
`https://bsky.app/intent/compose?text=${encodeURIComponent(`${text} ${url}`)}`
|
|
161
|
+
},
|
|
162
|
+
mastodon: {
|
|
163
|
+
name: 'Mastodon',
|
|
164
|
+
url: (url, text, instance) =>
|
|
165
|
+
`https://${instance}/share?text=${encodeURIComponent(`${text} ${url}`)}`
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
// Renders one of the paths above.
|
|
170
|
+
const MetaIcon = (props: { d: string;
|
|
171
|
+
brand?: boolean }) =>
|
|
172
|
+
h(
|
|
173
|
+
'svg',
|
|
174
|
+
{
|
|
175
|
+
class: [
|
|
176
|
+
'ff-doc-meta-icon',
|
|
177
|
+
{
|
|
178
|
+
brand: props.brand
|
|
179
|
+
}
|
|
180
|
+
],
|
|
181
|
+
viewBox: '0 0 24 24',
|
|
182
|
+
'aria-hidden': 'true'
|
|
183
|
+
},
|
|
184
|
+
h('path', {
|
|
185
|
+
d: props.d
|
|
186
|
+
})
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
MetaIcon.props = [
|
|
190
|
+
'd',
|
|
191
|
+
'brand'
|
|
192
|
+
];
|
|
193
|
+
|
|
194
|
+
const markdown = computed(() => (page.value as { ffMarkdown?: string }).ffMarkdown ?? '');
|
|
195
|
+
|
|
196
|
+
const actions = computed(() => {
|
|
197
|
+
const { pageActions, copyMarkdown } = options.value;
|
|
198
|
+
const all = pageActions === true;
|
|
199
|
+
const config = typeof pageActions === 'object' ? pageActions : {};
|
|
200
|
+
|
|
201
|
+
return {
|
|
202
|
+
markdown: (all || config.copyMarkdown || copyMarkdown === true) && !!markdown.value,
|
|
203
|
+
link: all || !!config.copyLink,
|
|
204
|
+
share: all ? (Object.keys(networks) as Network[]) : (config.share ?? []),
|
|
205
|
+
instance: config.mastodonInstance ?? 'mastodon.social'
|
|
206
|
+
};
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
const available = computed(
|
|
210
|
+
() => actions.value.markdown || actions.value.link || actions.value.share.length > 0
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
// The main part of the split button copies the link, else the Markdown; with neither, the single
|
|
214
|
+
// "Share" trigger takes its place. The menu never repeats the main action.
|
|
215
|
+
const main = computed(() =>
|
|
216
|
+
actions.value.link ? 'link' : actions.value.markdown ? 'markdown' : null
|
|
217
|
+
);
|
|
218
|
+
const menuMarkdown = computed(() => main.value === 'link' && actions.value.markdown);
|
|
219
|
+
const hasMenu = computed(() => menuMarkdown.value || actions.value.share.length > 0);
|
|
220
|
+
|
|
221
|
+
// The page address without its query or hash, read on the client only.
|
|
222
|
+
function pageAddress() {
|
|
223
|
+
return window.location.origin + window.location.pathname;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const { copied: markdownCopied, copy: copyMarkdown } = useCopy(markdown);
|
|
227
|
+
const { copied: linkCopied, copy: copyLink } = useCopy(pageAddress);
|
|
228
|
+
|
|
229
|
+
const copied = computed(() => markdownCopied.value || linkCopied.value);
|
|
230
|
+
const message = computed(() =>
|
|
231
|
+
linkCopied.value ? labels.value.linkCopied : markdownCopied.value ? labels.value.heroCopied : ''
|
|
232
|
+
);
|
|
233
|
+
const mainLabel = computed(
|
|
234
|
+
() =>
|
|
235
|
+
message.value ||
|
|
236
|
+
(main.value === 'link' ? labels.value.copyLink : labels.value.copyMarkdown)
|
|
237
|
+
);
|
|
238
|
+
|
|
239
|
+
const root = ref<HTMLElement>();
|
|
240
|
+
const trigger = ref<HTMLButtonElement>();
|
|
241
|
+
const open = ref(false);
|
|
242
|
+
const pageUrl = ref('');
|
|
243
|
+
|
|
244
|
+
const shares = computed(() =>
|
|
245
|
+
actions.value.share
|
|
246
|
+
.filter((id) => networks[id])
|
|
247
|
+
.map((id) => ({
|
|
248
|
+
id,
|
|
249
|
+
name: networks[id].name,
|
|
250
|
+
href: networks[id].url(pageUrl.value, page.value.title, actions.value.instance)
|
|
251
|
+
}))
|
|
252
|
+
);
|
|
253
|
+
|
|
254
|
+
function toggle() {
|
|
255
|
+
open.value = !open.value;
|
|
256
|
+
|
|
257
|
+
if (open.value) {
|
|
258
|
+
// Read on the client only, so the page renders the same on the server.
|
|
259
|
+
pageUrl.value = pageAddress();
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function close(refocus = false) {
|
|
264
|
+
open.value = false;
|
|
265
|
+
|
|
266
|
+
if (refocus) {
|
|
267
|
+
trigger.value?.focus();
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// A link is only followed once its handlers return, so the menu leaves after it.
|
|
272
|
+
function closeSoon() {
|
|
273
|
+
setTimeout(() => close());
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
function onKeydown(event: KeyboardEvent) {
|
|
277
|
+
if (!open.value) {
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
if (event.key === 'Escape') {
|
|
282
|
+
close(true);
|
|
283
|
+
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
const step = {
|
|
288
|
+
ArrowDown: 1,
|
|
289
|
+
ArrowUp: -1
|
|
290
|
+
}[event.key];
|
|
291
|
+
|
|
292
|
+
if (!step) {
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
event.preventDefault();
|
|
297
|
+
|
|
298
|
+
const list = Array.from(root.value?.querySelectorAll<HTMLElement>('[role="menuitem"]') ?? []);
|
|
299
|
+
const index = list.indexOf(document.activeElement as HTMLElement);
|
|
300
|
+
|
|
301
|
+
list[index < 0 && step < 0 ? list.length - 1 : (index + step + list.length) % list.length]?.focus();
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// A null target is a click on a control that takes no focus (Safari buttons): not a way out.
|
|
305
|
+
function onFocusout(event: FocusEvent) {
|
|
306
|
+
const next = event.relatedTarget as Node | null;
|
|
307
|
+
|
|
308
|
+
if (open.value && next && !root.value?.contains(next)) {
|
|
309
|
+
close();
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function onOutside(event: Event) {
|
|
314
|
+
if (open.value && !root.value?.contains(event.target as Node)) {
|
|
315
|
+
close();
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
onMounted(() => document.addEventListener('pointerdown', onOutside));
|
|
320
|
+
onUnmounted(() => document.removeEventListener('pointerdown', onOutside));
|
|
321
|
+
watch(
|
|
322
|
+
() => page.value.relativePath,
|
|
323
|
+
() => close()
|
|
324
|
+
);
|
|
325
|
+
|
|
326
|
+
// The block stays for the menu even when the kicker itself is switched off.
|
|
327
|
+
const hidden = computed(
|
|
328
|
+
() => (!meta.value && !available.value) || frontmatter.value.layout === 'home'
|
|
329
|
+
);
|
|
101
330
|
</script>
|
|
102
331
|
|
|
103
332
|
<template>
|
|
@@ -125,5 +354,98 @@ const hidden = computed(() => !meta.value || frontmatter.value.layout === 'home'
|
|
|
125
354
|
{{ format(labels.lastUpdated, updated) }}
|
|
126
355
|
</time>
|
|
127
356
|
</ClientOnly>
|
|
357
|
+
|
|
358
|
+
<div
|
|
359
|
+
v-if="available"
|
|
360
|
+
ref="root"
|
|
361
|
+
class="ff-doc-meta-actions"
|
|
362
|
+
@keydown="onKeydown"
|
|
363
|
+
@focusout="onFocusout"
|
|
364
|
+
>
|
|
365
|
+
<div
|
|
366
|
+
class="ff-doc-meta-split"
|
|
367
|
+
:class="{ copied }"
|
|
368
|
+
>
|
|
369
|
+
<button
|
|
370
|
+
v-if="main"
|
|
371
|
+
type="button"
|
|
372
|
+
class="ff-doc-meta-main"
|
|
373
|
+
@click="main === 'link' ? copyLink() : copyMarkdown()"
|
|
374
|
+
>
|
|
375
|
+
<MetaIcon :d="copied ? icons.check : main === 'link' ? icons.link : icons.copy" />
|
|
376
|
+
{{ mainLabel }}
|
|
377
|
+
</button>
|
|
378
|
+
|
|
379
|
+
<button
|
|
380
|
+
v-if="!main || hasMenu"
|
|
381
|
+
ref="trigger"
|
|
382
|
+
type="button"
|
|
383
|
+
class="ff-doc-meta-toggle"
|
|
384
|
+
:class="{ open }"
|
|
385
|
+
aria-haspopup="menu"
|
|
386
|
+
:aria-expanded="open"
|
|
387
|
+
:aria-label="main ? labels.pageActions : undefined"
|
|
388
|
+
@click="toggle"
|
|
389
|
+
>
|
|
390
|
+
<template v-if="!main">
|
|
391
|
+
<MetaIcon :d="icons.share" />
|
|
392
|
+
{{ labels.share }}
|
|
393
|
+
</template>
|
|
394
|
+
<MetaIcon
|
|
395
|
+
class="ff-doc-meta-chevron"
|
|
396
|
+
:d="icons.chevron"
|
|
397
|
+
/>
|
|
398
|
+
</button>
|
|
399
|
+
</div>
|
|
400
|
+
|
|
401
|
+
<span
|
|
402
|
+
class="visually-hidden"
|
|
403
|
+
aria-live="polite"
|
|
404
|
+
>{{ message }}</span>
|
|
405
|
+
|
|
406
|
+
<div
|
|
407
|
+
v-if="open"
|
|
408
|
+
class="ff-doc-meta-menu"
|
|
409
|
+
role="menu"
|
|
410
|
+
>
|
|
411
|
+
<button
|
|
412
|
+
v-if="menuMarkdown"
|
|
413
|
+
type="button"
|
|
414
|
+
role="menuitem"
|
|
415
|
+
@click="copyMarkdown(); close(true)"
|
|
416
|
+
>
|
|
417
|
+
<MetaIcon :d="icons.copy" />
|
|
418
|
+
<span class="ff-doc-meta-menu-text">
|
|
419
|
+
{{ labels.copyMarkdown }}
|
|
420
|
+
<small>{{ labels.copyMarkdownHint }}</small>
|
|
421
|
+
</span>
|
|
422
|
+
</button>
|
|
423
|
+
|
|
424
|
+
<hr
|
|
425
|
+
v-if="menuMarkdown && shares.length"
|
|
426
|
+
role="separator"
|
|
427
|
+
>
|
|
428
|
+
|
|
429
|
+
<a
|
|
430
|
+
v-for="share in shares"
|
|
431
|
+
:key="share.id"
|
|
432
|
+
role="menuitem"
|
|
433
|
+
:href="share.href"
|
|
434
|
+
target="_blank"
|
|
435
|
+
rel="noopener noreferrer"
|
|
436
|
+
@click="closeSoon"
|
|
437
|
+
>
|
|
438
|
+
<MetaIcon
|
|
439
|
+
:d="brands[share.id]"
|
|
440
|
+
brand
|
|
441
|
+
/>
|
|
442
|
+
<span class="ff-doc-meta-menu-text">{{ format(labels.shareOn, share.name) }}</span>
|
|
443
|
+
<MetaIcon
|
|
444
|
+
class="ff-doc-meta-external"
|
|
445
|
+
:d="icons.external"
|
|
446
|
+
/>
|
|
447
|
+
</a>
|
|
448
|
+
</div>
|
|
449
|
+
</div>
|
|
128
450
|
</div>
|
|
129
451
|
</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>
|
|
@@ -1,9 +1,10 @@
|
|
|
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
6
|
import { VPImage } from '../internal';
|
|
7
|
+
import FfHeroActions from './FfHeroActions.vue';
|
|
7
8
|
import FfHeroCommand from './FfHeroCommand.vue';
|
|
8
9
|
import type { HeroExtras, HeroMetaItem } from '../types';
|
|
9
10
|
import type { DefaultTheme } from 'vitepress/theme';
|
|
@@ -64,9 +65,19 @@ function filled(nodes?: VNode[]): boolean {
|
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
// 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.
|
|
68
|
+
// dependencies are tracked, and it changes with the page. It is still only rendered once per
|
|
69
|
+
// render — the template and the helpers below ask several times — so the answer is kept until the
|
|
70
|
+
// next update starts.
|
|
71
|
+
let imageCache: boolean | undefined;
|
|
72
|
+
|
|
73
|
+
onBeforeUpdate(() => {
|
|
74
|
+
imageCache = undefined;
|
|
75
|
+
});
|
|
76
|
+
|
|
68
77
|
function hasImage() {
|
|
69
|
-
|
|
78
|
+
imageCache ??= !!props.image || filled(slots['home-hero-image']?.());
|
|
79
|
+
|
|
80
|
+
return imageCache;
|
|
70
81
|
}
|
|
71
82
|
|
|
72
83
|
// The second column carries the image when there is one, and the starting point otherwise. The
|
|
@@ -128,24 +139,14 @@ function hasInlineCommand() {
|
|
|
128
139
|
|
|
129
140
|
<slot name="home-hero-info-after" />
|
|
130
141
|
|
|
131
|
-
<
|
|
142
|
+
<FfHeroActions
|
|
132
143
|
v-if="hasActions && !hasPanel()"
|
|
133
|
-
|
|
144
|
+
:actions="actions!"
|
|
134
145
|
>
|
|
135
|
-
<
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
:key="action.link"
|
|
140
|
-
class="ff-btn"
|
|
141
|
-
:class="`ff-btn-${action.theme ?? 'brand'}`"
|
|
142
|
-
:href="action.link"
|
|
143
|
-
:target="action.target"
|
|
144
|
-
:rel="action.rel ?? (action.target === '_blank' ? 'noopener' : undefined)"
|
|
145
|
-
>
|
|
146
|
-
{{ action.text }}
|
|
147
|
-
</a>
|
|
148
|
-
</div>
|
|
146
|
+
<template #before>
|
|
147
|
+
<slot name="home-hero-actions-before-actions" />
|
|
148
|
+
</template>
|
|
149
|
+
</FfHeroActions>
|
|
149
150
|
|
|
150
151
|
<slot name="home-hero-actions-after" />
|
|
151
152
|
|
|
@@ -186,24 +187,14 @@ function hasInlineCommand() {
|
|
|
186
187
|
:bare="!hasActions"
|
|
187
188
|
/>
|
|
188
189
|
|
|
189
|
-
<
|
|
190
|
+
<FfHeroActions
|
|
190
191
|
v-if="hasActions"
|
|
191
|
-
|
|
192
|
+
:actions="actions!"
|
|
192
193
|
>
|
|
193
|
-
<
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
:key="action.link"
|
|
198
|
-
class="ff-btn"
|
|
199
|
-
:class="`ff-btn-${action.theme ?? 'brand'}`"
|
|
200
|
-
:href="action.link"
|
|
201
|
-
:target="action.target"
|
|
202
|
-
:rel="action.rel ?? (action.target === '_blank' ? 'noopener' : undefined)"
|
|
203
|
-
>
|
|
204
|
-
{{ action.text }}
|
|
205
|
-
</a>
|
|
206
|
-
</div>
|
|
194
|
+
<template #before>
|
|
195
|
+
<slot name="home-hero-actions-before-actions" />
|
|
196
|
+
</template>
|
|
197
|
+
</FfHeroActions>
|
|
207
198
|
</div>
|
|
208
199
|
</div>
|
|
209
200
|
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { isExternal, normalizeLink } from '../internal';
|
|
3
|
+
import type { HeroAction } from './FfHero.vue';
|
|
4
|
+
|
|
5
|
+
defineProps<{
|
|
6
|
+
actions: HeroAction[]
|
|
7
|
+
}>();
|
|
8
|
+
|
|
9
|
+
// Like VPButton: an external link opens in a new tab and drops the referrer unless the action
|
|
10
|
+
// says otherwise.
|
|
11
|
+
function target(action: HeroAction) {
|
|
12
|
+
return action.target ?? (isExternal(action.link) ? '_blank' : undefined);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function rel(action: HeroAction) {
|
|
16
|
+
if (action.rel) {
|
|
17
|
+
return action.rel;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (isExternal(action.link)) {
|
|
21
|
+
return 'noreferrer';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return target(action) === '_blank' ? 'noopener' : undefined;
|
|
25
|
+
}
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<template>
|
|
29
|
+
<div class="ff-hero-actions">
|
|
30
|
+
<slot name="before" />
|
|
31
|
+
|
|
32
|
+
<a
|
|
33
|
+
v-for="action in actions"
|
|
34
|
+
:key="action.link"
|
|
35
|
+
class="ff-btn"
|
|
36
|
+
:class="`ff-btn-${action.theme ?? 'brand'}`"
|
|
37
|
+
:href="normalizeLink(action.link)"
|
|
38
|
+
:target="target(action)"
|
|
39
|
+
:rel="rel(action)"
|
|
40
|
+
>
|
|
41
|
+
{{ action.text }}
|
|
42
|
+
</a>
|
|
43
|
+
</div>
|
|
44
|
+
</template>
|