@frontfactory/vitepress-theme 1.8.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 +28 -0
- package/README.md +20 -7
- package/config.d.ts +4 -3
- package/config.js +58 -37
- package/dist/style.css +1 -1
- package/node/blog.d.ts +3 -0
- package/node/blog.js +19 -0
- package/node/llms.js +4 -3
- package/node/og.js +5 -6
- package/node/pages.js +14 -6
- package/node/rss.js +6 -9
- package/package.json +1 -1
- package/src/blog/posts.data.ts +3 -2
- package/src/components/FfBackToTop.vue +1 -1
- package/src/components/FfCopyStatus.vue +1 -1
- package/src/components/FfDocMeta.vue +300 -17
- 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 +4 -3
- package/src/composables/blog.ts +7 -4
- package/src/composables/copy.ts +36 -0
- package/src/composables/options.ts +9 -1
- package/src/composables/tabs.ts +2 -35
- 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 +6 -12
- package/src/styles/_content.scss +153 -63
- package/src/styles/_doc.scss +14 -24
- package/src/styles/_home.scss +11 -49
- package/src/styles/_mixins.scss +63 -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 +30 -4
- package/types/components/FfHeroActions.vue.d.ts +19 -0
- package/types/composables/copy.d.ts +6 -0
- package/types/composables/tabs.d.ts +0 -5
- package/types/internal.d.ts +1 -0
- package/types/types.d.ts +28 -4
|
@@ -1,10 +1,11 @@
|
|
|
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 { normalizeLink } from '../internal';
|
|
8
9
|
|
|
9
10
|
const { frontmatter, lang } = useData();
|
|
10
11
|
const { isPost, authors } = useBlog();
|
|
@@ -30,13 +31,13 @@ const tags = computed<string[]>(() => (Array.isArray(frontmatter.value.tags) ? f
|
|
|
30
31
|
>
|
|
31
32
|
<img
|
|
32
33
|
v-if="author.avatar"
|
|
33
|
-
:src="author.avatar"
|
|
34
|
+
:src="withBase(author.avatar)"
|
|
34
35
|
alt=""
|
|
35
36
|
class="ff-post-avatar"
|
|
36
37
|
>
|
|
37
38
|
<a
|
|
38
39
|
v-if="author.link"
|
|
39
|
-
:href="author.link"
|
|
40
|
+
:href="normalizeLink(author.link)"
|
|
40
41
|
>{{ format(labels.blogBy, author.name) }}</a>
|
|
41
42
|
<template v-else>{{ format(labels.blogBy, author.name) }}</template>
|
|
42
43
|
</span>
|
package/src/composables/blog.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { computed } from 'vue';
|
|
2
2
|
import { useData } from 'vitepress';
|
|
3
3
|
import { useThemeOptions } from './options';
|
|
4
|
+
import { blogDir, hasValidDate } from '../../node/blog.js';
|
|
4
5
|
import type { BlogAuthor } from '../types';
|
|
5
6
|
|
|
6
7
|
/** Blog options, with the directory normalised (no slash at either end). */
|
|
@@ -8,12 +9,14 @@ export function useBlog() {
|
|
|
8
9
|
const options = useThemeOptions();
|
|
9
10
|
const { page, frontmatter } = useData();
|
|
10
11
|
|
|
11
|
-
const dir = computed(() => (options.value
|
|
12
|
+
const dir = computed(() => blogDir(options.value));
|
|
12
13
|
|
|
13
14
|
// A post is a dated page under the blog directory, the index excluded.
|
|
14
|
-
const isPost = computed(
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
const isPost = computed(() => {
|
|
16
|
+
const path = page.value.relativePath;
|
|
17
|
+
|
|
18
|
+
return path.startsWith(`${dir.value}/`) && path !== `${dir.value}/index.md` && hasValidDate(frontmatter.value.date);
|
|
19
|
+
});
|
|
17
20
|
|
|
18
21
|
return {
|
|
19
22
|
dir,
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {
|
|
2
|
+
onUnmounted, ref, toValue, type MaybeRefOrGetter
|
|
3
|
+
} from 'vue';
|
|
4
|
+
|
|
5
|
+
/** Copies a string to the clipboard and flags it as copied for two seconds. */
|
|
6
|
+
export function useCopy(text: MaybeRefOrGetter<string>) {
|
|
7
|
+
const copied = ref(false);
|
|
8
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
9
|
+
|
|
10
|
+
async function copy() {
|
|
11
|
+
const value = toValue(text);
|
|
12
|
+
|
|
13
|
+
if (!value) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
await navigator.clipboard.writeText(value);
|
|
19
|
+
} catch {
|
|
20
|
+
// Insecure context or denied permission: there is nothing to confirm.
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
copied.value = true;
|
|
25
|
+
|
|
26
|
+
clearTimeout(timer);
|
|
27
|
+
timer = setTimeout(() => (copied.value = false), 2000);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
onUnmounted(() => clearTimeout(timer));
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
copied,
|
|
34
|
+
copy
|
|
35
|
+
};
|
|
36
|
+
}
|
|
@@ -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
|
-
}
|
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 {
|
package/src/styles/_code.scss
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// CODE //
|
|
3
3
|
// ============================================================================================= //
|
|
4
4
|
|
|
5
|
+
@use "mixins";
|
|
5
6
|
@use "theme" as mg;
|
|
6
7
|
|
|
7
8
|
.ff-theme {
|
|
@@ -31,12 +32,9 @@
|
|
|
31
32
|
left: 0;
|
|
32
33
|
height: 2.5rem;
|
|
33
34
|
padding: 0 1rem;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
text-transform: uppercase;
|
|
38
|
-
letter-spacing: #{mg.ref("tracking-label")};
|
|
39
|
-
color: #{mg.ref("color-ink-faint")};
|
|
35
|
+
|
|
36
|
+
@include mixins.label;
|
|
37
|
+
|
|
40
38
|
opacity: 1;
|
|
41
39
|
}
|
|
42
40
|
|
|
@@ -139,12 +137,8 @@
|
|
|
139
137
|
.vp-doc .vp-code-group .tabs label {
|
|
140
138
|
padding: 0 0.75rem;
|
|
141
139
|
line-height: 2.5rem;
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
font-weight: 500;
|
|
145
|
-
text-transform: uppercase;
|
|
146
|
-
letter-spacing: #{mg.ref("tracking-label")};
|
|
147
|
-
color: #{mg.ref("color-ink-faint")};
|
|
140
|
+
|
|
141
|
+
@include mixins.label;
|
|
148
142
|
}
|
|
149
143
|
|
|
150
144
|
.vp-doc .vp-code-group input:checked + label {
|