@frontfactory/vitepress-theme 1.8.0 → 1.10.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 +39 -0
- package/README.md +11 -391
- package/config.d.ts +4 -3
- package/config.js +58 -40
- package/dist/style.css +1 -1
- package/node/banner.d.ts +3 -0
- package/node/banner.js +14 -0
- package/node/blog.d.ts +11 -0
- package/node/blog.js +63 -0
- package/node/llms.js +4 -3
- package/node/og.js +5 -6
- package/node/options.d.ts +1 -0
- package/node/options.js +17 -0
- package/node/page-actions.d.ts +12 -0
- package/node/page-actions.js +34 -0
- package/node/pages.js +34 -14
- package/node/rss.js +13 -21
- package/package.json +1 -1
- package/src/blog/posts.data.ts +7 -4
- package/src/components/FfBackToTop.vue +6 -36
- package/src/components/FfBanner.vue +3 -2
- package/src/components/FfCopyStatus.vue +6 -14
- package/src/components/FfDocMeta.vue +299 -24
- package/src/components/FfFeedback.vue +4 -9
- package/src/components/FfHero.vue +14 -33
- package/src/components/FfHeroActions.vue +44 -0
- package/src/components/FfHeroCommand.vue +3 -2
- package/src/components/FfPost.vue +6 -4
- package/src/components/FfProgress.vue +6 -40
- package/src/composables/blog.ts +8 -11
- package/src/composables/copy.ts +29 -0
- package/src/composables/frame.ts +50 -0
- package/src/composables/options.ts +9 -1
- package/src/composables/tabs.ts +2 -35
- package/src/composables/transient.ts +27 -0
- package/src/content/Tabs.vue +27 -6
- package/src/internal.ts +1 -0
- package/src/layout/FfLayout.vue +3 -3
- package/src/styles/_base.scss +5 -9
- package/src/styles/_blocks.scss +4 -7
- package/src/styles/_blog.scss +4 -5
- package/src/styles/_code.scss +12 -20
- package/src/styles/_content.scss +153 -63
- package/src/styles/_doc.scss +26 -25
- package/src/styles/_home.scss +31 -61
- package/src/styles/_mixins.scss +87 -0
- package/src/styles/_motion.scss +12 -10
- package/src/styles/_nav.scss +12 -19
- package/src/styles/_sidebar.scss +5 -8
- package/src/styles/_tokens.scss +19 -4
- package/src/types.ts +31 -4
- package/types/components/FfHeroActions.vue.d.ts +19 -0
- package/types/composables/blog.d.ts +3 -4
- package/types/composables/copy.d.ts +6 -0
- package/types/composables/frame.d.ts +6 -0
- package/types/composables/tabs.d.ts +0 -5
- package/types/composables/transient.d.ts +6 -0
- package/types/internal.d.ts +1 -0
- package/types/types.d.ts +29 -4
|
@@ -3,7 +3,8 @@ import {
|
|
|
3
3
|
Comment, computed, Fragment, onBeforeUpdate, Text, useSlots, type VNode
|
|
4
4
|
} from 'vue';
|
|
5
5
|
import { useData } from 'vitepress';
|
|
6
|
-
import {
|
|
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';
|
|
@@ -138,24 +139,14 @@ function hasInlineCommand() {
|
|
|
138
139
|
|
|
139
140
|
<slot name="home-hero-info-after" />
|
|
140
141
|
|
|
141
|
-
<
|
|
142
|
+
<FfHeroActions
|
|
142
143
|
v-if="hasActions && !hasPanel()"
|
|
143
|
-
|
|
144
|
+
:actions="actions!"
|
|
144
145
|
>
|
|
145
|
-
<
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
:key="action.link"
|
|
150
|
-
class="ff-btn"
|
|
151
|
-
:class="`ff-btn-${action.theme ?? 'brand'}`"
|
|
152
|
-
:href="normalizeLink(action.link)"
|
|
153
|
-
:target="action.target"
|
|
154
|
-
:rel="action.rel ?? (action.target === '_blank' ? 'noopener' : undefined)"
|
|
155
|
-
>
|
|
156
|
-
{{ action.text }}
|
|
157
|
-
</a>
|
|
158
|
-
</div>
|
|
146
|
+
<template #before>
|
|
147
|
+
<slot name="home-hero-actions-before-actions" />
|
|
148
|
+
</template>
|
|
149
|
+
</FfHeroActions>
|
|
159
150
|
|
|
160
151
|
<slot name="home-hero-actions-after" />
|
|
161
152
|
|
|
@@ -196,24 +187,14 @@ function hasInlineCommand() {
|
|
|
196
187
|
:bare="!hasActions"
|
|
197
188
|
/>
|
|
198
189
|
|
|
199
|
-
<
|
|
190
|
+
<FfHeroActions
|
|
200
191
|
v-if="hasActions"
|
|
201
|
-
|
|
192
|
+
:actions="actions!"
|
|
202
193
|
>
|
|
203
|
-
<
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
:key="action.link"
|
|
208
|
-
class="ff-btn"
|
|
209
|
-
:class="`ff-btn-${action.theme ?? 'brand'}`"
|
|
210
|
-
:href="normalizeLink(action.link)"
|
|
211
|
-
:target="action.target"
|
|
212
|
-
:rel="action.rel ?? (action.target === '_blank' ? 'noopener' : undefined)"
|
|
213
|
-
>
|
|
214
|
-
{{ action.text }}
|
|
215
|
-
</a>
|
|
216
|
-
</div>
|
|
194
|
+
<template #before>
|
|
195
|
+
<slot name="home-hero-actions-before-actions" />
|
|
196
|
+
</template>
|
|
197
|
+
</FfHeroActions>
|
|
217
198
|
</div>
|
|
218
199
|
</div>
|
|
219
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>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, useId } from 'vue';
|
|
3
3
|
import { format, useLabels } from '../composables/options';
|
|
4
|
-
import { useCopy
|
|
4
|
+
import { useCopy } from '../composables/copy';
|
|
5
|
+
import { useTabs } from '../composables/tabs';
|
|
5
6
|
import type { HeroCommandTab } from '../types';
|
|
6
7
|
|
|
7
8
|
// Used from both hero panel positions (inline and beside the headline, see FfHero), which are
|
|
@@ -48,7 +49,7 @@ const { copied, copy } = useCopy(activeCommand);
|
|
|
48
49
|
<button
|
|
49
50
|
v-for="(tab, index) in tabs"
|
|
50
51
|
:id="`${id}-tab-${index}`"
|
|
51
|
-
:key="
|
|
52
|
+
:key="index"
|
|
52
53
|
type="button"
|
|
53
54
|
role="tab"
|
|
54
55
|
class="ff-hero-command-tab"
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed } from 'vue';
|
|
3
|
-
import { useData } from 'vitepress';
|
|
3
|
+
import { useData, withBase } from 'vitepress';
|
|
4
4
|
import {
|
|
5
5
|
formatDate, resolveAuthor, useBlog
|
|
6
6
|
} from '../composables/blog';
|
|
7
7
|
import { format, useLabels } from '../composables/options';
|
|
8
|
+
import { toTags } from '../../node/blog.js';
|
|
9
|
+
import { normalizeLink } from '../internal';
|
|
8
10
|
|
|
9
11
|
const { frontmatter, lang } = useData();
|
|
10
12
|
const { isPost, authors } = useBlog();
|
|
@@ -12,7 +14,7 @@ const labels = useLabels();
|
|
|
12
14
|
|
|
13
15
|
const date = computed(() => (isPost.value ? new Date(frontmatter.value.date).toISOString() : ''));
|
|
14
16
|
const author = computed(() => resolveAuthor(authors.value, frontmatter.value.author));
|
|
15
|
-
const tags = computed<string[]>(() => (
|
|
17
|
+
const tags = computed<string[]>(() => (toTags(frontmatter.value.tags) as string[]));
|
|
16
18
|
</script>
|
|
17
19
|
|
|
18
20
|
<template>
|
|
@@ -30,13 +32,13 @@ const tags = computed<string[]>(() => (Array.isArray(frontmatter.value.tags) ? f
|
|
|
30
32
|
>
|
|
31
33
|
<img
|
|
32
34
|
v-if="author.avatar"
|
|
33
|
-
:src="author.avatar"
|
|
35
|
+
:src="withBase(author.avatar)"
|
|
34
36
|
alt=""
|
|
35
37
|
class="ff-post-avatar"
|
|
36
38
|
>
|
|
37
39
|
<a
|
|
38
40
|
v-if="author.link"
|
|
39
|
-
:href="author.link"
|
|
41
|
+
:href="normalizeLink(author.link)"
|
|
40
42
|
>{{ format(labels.blogBy, author.name) }}</a>
|
|
41
43
|
<template v-else>{{ format(labels.blogBy, author.name) }}</template>
|
|
42
44
|
</span>
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
computed, onMounted, ref, watchEffect
|
|
4
|
-
} from 'vue';
|
|
2
|
+
import { computed, ref } from 'vue';
|
|
5
3
|
import { useData } from 'vitepress';
|
|
6
4
|
import { useThemeOptions } from '../composables/options';
|
|
5
|
+
import { useFrameListener } from '../composables/frame';
|
|
7
6
|
|
|
8
7
|
const { frontmatter } = useData();
|
|
9
8
|
const options = useThemeOptions();
|
|
@@ -18,43 +17,10 @@ function update() {
|
|
|
18
17
|
progress.value = range > 0 ? Math.min(Math.max(window.scrollY / range, 0), 1) : 0;
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (!frame) {
|
|
26
|
-
frame = requestAnimationFrame(() => {
|
|
27
|
-
frame = 0;
|
|
28
|
-
update();
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Listens only while the bar is enabled, and follows the option if it changes (locale switch,
|
|
34
|
-
// per-page frontmatter). The effect is stopped with the component, which runs its cleanup.
|
|
35
|
-
onMounted(() => {
|
|
36
|
-
watchEffect((onCleanup) => {
|
|
37
|
-
if (!enabled.value) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
update();
|
|
42
|
-
window.addEventListener('scroll', onChange, {
|
|
43
|
-
passive: true
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
window.addEventListener('resize', onChange, {
|
|
47
|
-
passive: true
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
onCleanup(() => {
|
|
51
|
-
cancelAnimationFrame(frame);
|
|
52
|
-
frame = 0;
|
|
53
|
-
window.removeEventListener('scroll', onChange);
|
|
54
|
-
window.removeEventListener('resize', onChange);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
});
|
|
20
|
+
useFrameListener(enabled, update, [
|
|
21
|
+
'scroll',
|
|
22
|
+
'resize'
|
|
23
|
+
]);
|
|
58
24
|
</script>
|
|
59
25
|
|
|
60
26
|
<template>
|
package/src/composables/blog.ts
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import { computed } from 'vue';
|
|
2
2
|
import { useData } from 'vitepress';
|
|
3
3
|
import { useThemeOptions } from './options';
|
|
4
|
-
import
|
|
4
|
+
import {
|
|
5
|
+
blogDir, isPostPath, resolveAuthor
|
|
6
|
+
} from '../../node/blog.js';
|
|
7
|
+
|
|
8
|
+
export { resolveAuthor };
|
|
5
9
|
|
|
6
10
|
/** Blog options, with the directory normalised (no slash at either end). */
|
|
7
11
|
export function useBlog() {
|
|
8
12
|
const options = useThemeOptions();
|
|
9
13
|
const { page, frontmatter } = useData();
|
|
10
14
|
|
|
11
|
-
const dir = computed(() => (options.value
|
|
15
|
+
const dir = computed(() => blogDir(options.value));
|
|
12
16
|
|
|
13
17
|
// A post is a dated page under the blog directory, the index excluded.
|
|
14
|
-
const isPost = computed(
|
|
15
|
-
(
|
|
18
|
+
const isPost = computed(() =>
|
|
19
|
+
isPostPath(dir.value, page.value.relativePath, frontmatter.value.date)
|
|
16
20
|
);
|
|
17
21
|
|
|
18
22
|
return {
|
|
@@ -22,13 +26,6 @@ export function useBlog() {
|
|
|
22
26
|
};
|
|
23
27
|
}
|
|
24
28
|
|
|
25
|
-
/** `author` is a key of `ff.blog.authors`, or a plain name used as is. */
|
|
26
|
-
export function resolveAuthor(authors: Record<string, BlogAuthor>, value?: string): BlogAuthor | null {
|
|
27
|
-
return value ? authors[value] ?? {
|
|
28
|
-
name: value
|
|
29
|
-
} : null;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
29
|
// UTC, so the server and the browser print the same day whatever their time zone.
|
|
33
30
|
export function formatDate(date: string, lang: string) {
|
|
34
31
|
return new Intl.DateTimeFormat(lang, {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { toValue, type MaybeRefOrGetter } from 'vue';
|
|
2
|
+
import { useTransientFlag } from './transient';
|
|
3
|
+
|
|
4
|
+
/** Copies a string to the clipboard and flags it as copied for two seconds. */
|
|
5
|
+
export function useCopy(text: MaybeRefOrGetter<string>) {
|
|
6
|
+
const { active: copied, start } = useTransientFlag();
|
|
7
|
+
|
|
8
|
+
async function copy() {
|
|
9
|
+
const value = toValue(text);
|
|
10
|
+
|
|
11
|
+
if (!value) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
try {
|
|
16
|
+
await navigator.clipboard.writeText(value);
|
|
17
|
+
} catch {
|
|
18
|
+
// Insecure context or denied permission: there is nothing to confirm.
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
start();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
copied,
|
|
27
|
+
copy
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {
|
|
2
|
+
onMounted, toValue, watchEffect, type MaybeRefOrGetter
|
|
3
|
+
} from 'vue';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Runs `update` once, then at most once per frame however many of the window `events` fire. Listens
|
|
7
|
+
* only while `enabled` is true and follows it if it changes; everything is undone on unmount.
|
|
8
|
+
*/
|
|
9
|
+
export function useFrameListener(
|
|
10
|
+
enabled: MaybeRefOrGetter<boolean>,
|
|
11
|
+
update: () => void,
|
|
12
|
+
events: string[]
|
|
13
|
+
) {
|
|
14
|
+
let frame = 0;
|
|
15
|
+
|
|
16
|
+
function onEvent() {
|
|
17
|
+
if (!frame) {
|
|
18
|
+
frame = requestAnimationFrame(() => {
|
|
19
|
+
frame = 0;
|
|
20
|
+
update();
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// The effect is stopped with the component, which runs its cleanup.
|
|
26
|
+
onMounted(() => {
|
|
27
|
+
watchEffect((onCleanup) => {
|
|
28
|
+
if (!toValue(enabled)) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
update();
|
|
33
|
+
|
|
34
|
+
for (const name of events) {
|
|
35
|
+
window.addEventListener(name, onEvent, {
|
|
36
|
+
passive: true
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
onCleanup(() => {
|
|
41
|
+
cancelAnimationFrame(frame);
|
|
42
|
+
frame = 0;
|
|
43
|
+
|
|
44
|
+
for (const name of events) {
|
|
45
|
+
window.removeEventListener(name, onEvent);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
}
|
|
@@ -33,9 +33,17 @@ export const defaultLabels: Required<ThemeLabels> = {
|
|
|
33
33
|
feedbackNo: 'No',
|
|
34
34
|
feedbackThanks: 'Thanks for your feedback',
|
|
35
35
|
copyMarkdown: 'Copy as Markdown',
|
|
36
|
+
copyMarkdownHint: 'Page source',
|
|
37
|
+
pageActions: 'More page actions',
|
|
38
|
+
copyLink: 'Copy link',
|
|
39
|
+
linkCopied: 'Link copied',
|
|
40
|
+
share: 'Share',
|
|
41
|
+
shareOn: 'Share on {0}',
|
|
36
42
|
versionSwitcher: 'Version',
|
|
37
43
|
blogBy: 'By {0}',
|
|
38
|
-
blogEmpty: 'No posts yet'
|
|
44
|
+
blogEmpty: 'No posts yet',
|
|
45
|
+
returnToTop: 'Return to top',
|
|
46
|
+
codeCopied: 'Copied'
|
|
39
47
|
};
|
|
40
48
|
|
|
41
49
|
/**
|
package/src/composables/tabs.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
computed, onMounted,
|
|
2
|
+
computed, onMounted, reactive, ref, toValue, watch, type MaybeRefOrGetter
|
|
3
3
|
} from 'vue';
|
|
4
4
|
|
|
5
5
|
const STORAGE_PREFIX = 'ff-tabs:';
|
|
@@ -33,7 +33,7 @@ export function useTabs(labels: MaybeRefOrGetter<string[]>, syncKey?: MaybeRefOr
|
|
|
33
33
|
|
|
34
34
|
// Client-side navigation can swap the labels without remounting the component (two pages
|
|
35
35
|
// using the same layout), so the index is reset rather than left pointing past the end.
|
|
36
|
-
watch(() => toValue(labels), () => (local.value = 0));
|
|
36
|
+
watch(() => JSON.stringify(toValue(labels)), () => (local.value = 0));
|
|
37
37
|
|
|
38
38
|
const active = computed(() => {
|
|
39
39
|
const list = toValue(labels);
|
|
@@ -120,36 +120,3 @@ export function useTabs(labels: MaybeRefOrGetter<string[]>, syncKey?: MaybeRefOr
|
|
|
120
120
|
onKeydown
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
|
-
|
|
124
|
-
/** Copies a string to the clipboard and flags it as copied for two seconds. */
|
|
125
|
-
export function useCopy(text: MaybeRefOrGetter<string>) {
|
|
126
|
-
const copied = ref(false);
|
|
127
|
-
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
128
|
-
|
|
129
|
-
async function copy() {
|
|
130
|
-
const value = toValue(text);
|
|
131
|
-
|
|
132
|
-
if (!value) {
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
try {
|
|
137
|
-
await navigator.clipboard.writeText(value);
|
|
138
|
-
} catch {
|
|
139
|
-
// Insecure context or denied permission: there is nothing to confirm.
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
copied.value = true;
|
|
144
|
-
|
|
145
|
-
clearTimeout(timer);
|
|
146
|
-
timer = setTimeout(() => (copied.value = false), 2000);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
onUnmounted(() => clearTimeout(timer));
|
|
150
|
-
|
|
151
|
-
return {
|
|
152
|
-
copied,
|
|
153
|
-
copy
|
|
154
|
-
};
|
|
155
|
-
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { onUnmounted, ref } from 'vue';
|
|
2
|
+
|
|
3
|
+
/** A flag that turns itself off `ms` milliseconds after `start()`; the timer dies with the component. */
|
|
4
|
+
export function useTransientFlag(ms = 2000) {
|
|
5
|
+
const active = ref(false);
|
|
6
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
7
|
+
|
|
8
|
+
function stop() {
|
|
9
|
+
clearTimeout(timer);
|
|
10
|
+
active.value = false;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function start() {
|
|
14
|
+
active.value = true;
|
|
15
|
+
|
|
16
|
+
clearTimeout(timer);
|
|
17
|
+
timer = setTimeout(() => (active.value = false), ms);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
onUnmounted(() => clearTimeout(timer));
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
active,
|
|
24
|
+
start,
|
|
25
|
+
stop
|
|
26
|
+
};
|
|
27
|
+
}
|
package/src/content/Tabs.vue
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import {
|
|
3
|
-
Fragment, useId, useSlots, type VNode
|
|
3
|
+
Fragment, onBeforeUpdate, useId, useSlots, type VNode
|
|
4
4
|
} from 'vue';
|
|
5
5
|
import Tab from './Tab.vue';
|
|
6
6
|
import { useTabs } from '../composables/tabs';
|
|
@@ -15,10 +15,10 @@ const id = useId();
|
|
|
15
15
|
|
|
16
16
|
// The tabs are read off the slot rather than registered by each <Tab> on setup: during SSR the
|
|
17
17
|
// list is printed before any child runs, so a registration would come too late.
|
|
18
|
-
function
|
|
18
|
+
function collect(nodes: VNode[]): VNode[] {
|
|
19
19
|
return nodes.flatMap((node) => {
|
|
20
20
|
if (node.type === Fragment && Array.isArray(node.children)) {
|
|
21
|
-
return
|
|
21
|
+
return collect(node.children as VNode[]);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
return node.type === Tab ? [
|
|
@@ -27,11 +27,32 @@ function panels(nodes: VNode[] = slots.default?.() ?? []): VNode[] {
|
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
// Render-only cache: the template reads the tabs twice (labels, then panels), and both come from
|
|
31
|
+
// one slot call. It is dropped before each re-render so a changed slot is picked up. `useTabs` does
|
|
32
|
+
// not use it: its computed and watch call the slot themselves, which is what tracks the slot's
|
|
33
|
+
// reactive reads and re-evaluates them when the content changes.
|
|
34
|
+
let cached: VNode[] | null = null;
|
|
35
|
+
|
|
36
|
+
onBeforeUpdate(() => {
|
|
37
|
+
cached = null;
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
function labelsOf(nodes: VNode[]) {
|
|
41
|
+
return nodes.map((node) => String(node.props?.label ?? ''));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function panels(): VNode[] {
|
|
45
|
+
return cached ??= collect(slots.default?.() ?? []);
|
|
46
|
+
}
|
|
47
|
+
|
|
30
48
|
function labels() {
|
|
31
|
-
return panels()
|
|
49
|
+
return labelsOf(panels());
|
|
32
50
|
}
|
|
33
51
|
|
|
34
|
-
const { active, select, onKeydown } = useTabs(
|
|
52
|
+
const { active, select, onKeydown } = useTabs(
|
|
53
|
+
() => labelsOf(collect(slots.default?.() ?? [])),
|
|
54
|
+
() => props.syncKey
|
|
55
|
+
);
|
|
35
56
|
</script>
|
|
36
57
|
|
|
37
58
|
<template>
|
|
@@ -44,7 +65,7 @@ const { active, select, onKeydown } = useTabs(labels, () => props.syncKey);
|
|
|
44
65
|
<button
|
|
45
66
|
v-for="(label, index) in labels()"
|
|
46
67
|
:id="`${id}-tab-${index}`"
|
|
47
|
-
:key="
|
|
68
|
+
:key="index"
|
|
48
69
|
type="button"
|
|
49
70
|
role="tab"
|
|
50
71
|
class="ff-tabs-tab"
|
package/src/internal.ts
CHANGED
|
@@ -15,3 +15,4 @@ export { default as VPSponsors } from 'vitepress/dist/client/theme-default/compo
|
|
|
15
15
|
export { useLangs } from 'vitepress/dist/client/theme-default/composables/langs.js';
|
|
16
16
|
export { useLayout } from 'vitepress/dist/client/theme-default/composables/layout.js';
|
|
17
17
|
export { normalizeLink } from 'vitepress/dist/client/theme-default/support/utils.js';
|
|
18
|
+
export { isExternal } from 'vitepress/dist/client/shared.js';
|
package/src/layout/FfLayout.vue
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import { useSlots } from 'vue';
|
|
3
3
|
import { useData } from 'vitepress';
|
|
4
4
|
import DefaultTheme from 'vitepress/theme';
|
|
5
5
|
import FfBackToTop from '../components/FfBackToTop.vue';
|
|
@@ -25,7 +25,7 @@ const owned = [
|
|
|
25
25
|
];
|
|
26
26
|
|
|
27
27
|
const slots = useSlots();
|
|
28
|
-
const forwarded =
|
|
28
|
+
const forwarded = () => Object.keys(slots).filter((name) => !owned.includes(name));
|
|
29
29
|
</script>
|
|
30
30
|
|
|
31
31
|
<template>
|
|
@@ -60,7 +60,7 @@ const forwarded = computed(() => Object.keys(slots).filter((name) => !owned.incl
|
|
|
60
60
|
</template>
|
|
61
61
|
|
|
62
62
|
<template
|
|
63
|
-
v-for="name in forwarded"
|
|
63
|
+
v-for="name in forwarded()"
|
|
64
64
|
:key="name"
|
|
65
65
|
#[name]="data"
|
|
66
66
|
>
|
package/src/styles/_base.scss
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// BASE //
|
|
3
3
|
// ============================================================================================= //
|
|
4
4
|
|
|
5
|
+
@use "mixins";
|
|
5
6
|
@use "theme" as mg;
|
|
6
7
|
|
|
7
8
|
// Everything the theme restyles is scoped under .ff-theme, the class the layout puts on its root
|
|
@@ -24,13 +25,9 @@
|
|
|
24
25
|
display: inline-flex;
|
|
25
26
|
align-items: center;
|
|
26
27
|
gap: 0.5em;
|
|
27
|
-
font-family: #{mg.ref("font-mono")};
|
|
28
|
-
font-size: #{mg.ref("size-label")};
|
|
29
|
-
font-weight: 500;
|
|
30
28
|
line-height: 1;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
color: #{mg.ref("color-ink-faint")};
|
|
29
|
+
|
|
30
|
+
@include mixins.label;
|
|
34
31
|
}
|
|
35
32
|
|
|
36
33
|
.ff-display {
|
|
@@ -53,7 +50,6 @@
|
|
|
53
50
|
.VPLocalSearchBox :focus-visible {
|
|
54
51
|
outline: 2px solid #{mg.ref("color-accent")};
|
|
55
52
|
outline-offset: 2px;
|
|
56
|
-
border-radius: #{mg.ref("radius-sm")};
|
|
57
53
|
}
|
|
58
54
|
|
|
59
55
|
.ff-theme * {
|
|
@@ -78,13 +74,13 @@
|
|
|
78
74
|
.VPButton.medium {
|
|
79
75
|
padding: 0 1.25rem;
|
|
80
76
|
line-height: 2.75rem;
|
|
81
|
-
font-size:
|
|
77
|
+
font-size: #{mg.ref("size-ui")};
|
|
82
78
|
}
|
|
83
79
|
|
|
84
80
|
.VPButton.big {
|
|
85
81
|
padding: 0 1.75rem;
|
|
86
82
|
line-height: 3.25rem;
|
|
87
|
-
font-size:
|
|
83
|
+
font-size: #{mg.ref("size-ui-lg")};
|
|
88
84
|
}
|
|
89
85
|
|
|
90
86
|
.VPBadge {
|
package/src/styles/_blocks.scss
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// CUSTOM BLOCKS //
|
|
3
3
|
// ============================================================================================= //
|
|
4
4
|
|
|
5
|
+
@use "mixins";
|
|
5
6
|
@use "theme" as mg;
|
|
6
7
|
|
|
7
8
|
.ff-theme {
|
|
@@ -16,7 +17,7 @@
|
|
|
16
17
|
border-left: #{mg.ref("rule-accent-width")} solid #{mg.ref("color-rule-strong")};
|
|
17
18
|
border-radius: 0;
|
|
18
19
|
background: transparent;
|
|
19
|
-
font-size:
|
|
20
|
+
font-size: #{mg.ref("size-ui-lg")};
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
.vp-doc .custom-block p,
|
|
@@ -35,13 +36,9 @@
|
|
|
35
36
|
|
|
36
37
|
.vp-doc .custom-block .custom-block-title {
|
|
37
38
|
margin-bottom: 0.5rem;
|
|
38
|
-
font-family: #{mg.ref("font-mono")};
|
|
39
|
-
font-size: #{mg.ref("size-label")};
|
|
40
|
-
font-weight: 500;
|
|
41
39
|
line-height: 1;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
color: #{mg.ref("color-ink-faint")};
|
|
40
|
+
|
|
41
|
+
@include mixins.label;
|
|
45
42
|
}
|
|
46
43
|
|
|
47
44
|
.vp-doc .custom-block.tip,
|
package/src/styles/_blog.scss
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// ============================================================================================= //
|
|
4
4
|
|
|
5
5
|
@use "breakpoints" as bp;
|
|
6
|
+
@use "mixins";
|
|
6
7
|
@use "theme" as mg;
|
|
7
8
|
|
|
8
9
|
.ff-theme {
|
|
@@ -24,10 +25,8 @@
|
|
|
24
25
|
.ff-blog-title {
|
|
25
26
|
margin: 0;
|
|
26
27
|
font-family: #{mg.ref("font-display")};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
line-height: #{mg.ref("leading-tight")};
|
|
30
|
-
letter-spacing: -0.03em;
|
|
28
|
+
|
|
29
|
+
@include mixins.page-title;
|
|
31
30
|
}
|
|
32
31
|
|
|
33
32
|
.ff-blog-lede {
|
|
@@ -67,7 +66,7 @@
|
|
|
67
66
|
font-size: #{mg.ref("size-h2")};
|
|
68
67
|
font-weight: 600;
|
|
69
68
|
line-height: 1.3;
|
|
70
|
-
letter-spacing: -
|
|
69
|
+
letter-spacing: #{mg.ref("tracking-heading")};
|
|
71
70
|
}
|
|
72
71
|
|
|
73
72
|
.ff-blog-post-title a {
|