@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
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {
|
|
3
|
+
Comment, Fragment, Text, createTextVNode, defineComponent, h, isVNode, type VNode
|
|
4
|
+
} from 'vue';
|
|
5
|
+
|
|
6
|
+
interface Entry {
|
|
7
|
+
label: Array<string | VNode>
|
|
8
|
+
children: Entry[]
|
|
9
|
+
folder: boolean
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// Markdown renders a list as plain <ul>/<li> vnodes, and whitespace between them as text; the
|
|
13
|
+
// fragments and blanks are skipped so only real elements remain.
|
|
14
|
+
function elements(nodes: unknown): VNode[] {
|
|
15
|
+
const list = Array.isArray(nodes) ? nodes : [
|
|
16
|
+
nodes
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
return list.flatMap((node) => {
|
|
20
|
+
if (!isVNode(node) || node.type === Comment) {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return node.type === Fragment ? elements(node.children) : [
|
|
25
|
+
node
|
|
26
|
+
];
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function textOf(part: string | VNode): string {
|
|
31
|
+
if (typeof part === 'string') {
|
|
32
|
+
return part;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (typeof part.children === 'string') {
|
|
36
|
+
return part.children;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return Array.isArray(part.children) ? part.children.map((child) => textOf(child as string | VNode)).join('') : '';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// The slash only marks a folder in the source; it is dropped from what is displayed.
|
|
43
|
+
function stripSlash(part: string | VNode): string | VNode {
|
|
44
|
+
if (typeof part === 'string') {
|
|
45
|
+
return part.replace(/\/\s*$/, '');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (part.type === Text && typeof part.children === 'string') {
|
|
49
|
+
return createTextVNode(part.children.replace(/\/\s*$/, ''));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (typeof part.children === 'string') {
|
|
53
|
+
return h(part.type as string, part.props, part.children.replace(/\/\s*$/, ''));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (Array.isArray(part.children)) {
|
|
57
|
+
const children = part.children as Array<string | VNode>;
|
|
58
|
+
|
|
59
|
+
return h(part.type as string, part.props, [
|
|
60
|
+
...children.slice(0, -1),
|
|
61
|
+
stripSlash(children[children.length - 1])
|
|
62
|
+
]);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return part;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function entries(list: VNode): Entry[] {
|
|
69
|
+
return elements(list.children).filter((node) => node.type === 'li').map((item) => {
|
|
70
|
+
const parts = typeof item.children === 'string' ? [
|
|
71
|
+
item.children
|
|
72
|
+
] : (item.children as unknown[] ?? []).flatMap((child) => (Array.isArray(child) ? child : [
|
|
73
|
+
child
|
|
74
|
+
]));
|
|
75
|
+
const nested = parts.find((part): part is VNode => isVNode(part) && part.type === 'ul');
|
|
76
|
+
const label = parts.filter((part): part is string | VNode => part !== nested && (typeof part === 'string' || isVNode(part)) && textOf(part).trim() !== '');
|
|
77
|
+
const children = nested ? entries(nested) : [];
|
|
78
|
+
const folder = Boolean(nested) || /\/\s*$/.test(textOf(label[label.length - 1] ?? ''));
|
|
79
|
+
|
|
80
|
+
return {
|
|
81
|
+
label: folder && label.length ? [
|
|
82
|
+
...label.slice(0, -1),
|
|
83
|
+
stripSlash(label[label.length - 1])
|
|
84
|
+
] : label,
|
|
85
|
+
children,
|
|
86
|
+
folder
|
|
87
|
+
};
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function render(items: Entry[]): VNode {
|
|
92
|
+
return h('ul', items.map((entry) => h('li', {
|
|
93
|
+
class: entry.folder ? 'is-folder' : 'is-file'
|
|
94
|
+
}, [
|
|
95
|
+
h('span', {
|
|
96
|
+
class: 'ff-filetree-name'
|
|
97
|
+
}, entry.label),
|
|
98
|
+
entry.children.length ? render(entry.children) : null
|
|
99
|
+
])));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export default defineComponent({
|
|
103
|
+
name: 'FileTree',
|
|
104
|
+
setup(_, { slots }) {
|
|
105
|
+
// The tree is read off the slot on each render rather than parsed into state, so it follows
|
|
106
|
+
// hot updates of the Markdown it sits in.
|
|
107
|
+
return () => {
|
|
108
|
+
const list = elements(slots.default?.()).find((node) => node.type === 'ul');
|
|
109
|
+
|
|
110
|
+
return h('div', {
|
|
111
|
+
class: 'ff-filetree'
|
|
112
|
+
}, list ? [
|
|
113
|
+
render(entries(list))
|
|
114
|
+
] : []);
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
</script>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
// A marker: <Tabs> reads `label` off this vnode to build the tab list, and renders it as a panel.
|
|
3
|
+
defineProps<{
|
|
4
|
+
/** Text of the tab; also the value shared between groups with the same `syncKey`. */
|
|
5
|
+
label: string
|
|
6
|
+
}>();
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<template>
|
|
10
|
+
<slot />
|
|
11
|
+
</template>
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import {
|
|
3
|
+
Fragment, onBeforeUpdate, useId, useSlots, type VNode
|
|
4
|
+
} from 'vue';
|
|
5
|
+
import Tab from './Tab.vue';
|
|
6
|
+
import { useTabs } from '../composables/tabs';
|
|
7
|
+
|
|
8
|
+
const props = defineProps<{
|
|
9
|
+
/** Groups sharing a key switch together, and the choice is remembered across visits. */
|
|
10
|
+
syncKey?: string
|
|
11
|
+
}>();
|
|
12
|
+
|
|
13
|
+
const slots = useSlots();
|
|
14
|
+
const id = useId();
|
|
15
|
+
|
|
16
|
+
// The tabs are read off the slot rather than registered by each <Tab> on setup: during SSR the
|
|
17
|
+
// list is printed before any child runs, so a registration would come too late.
|
|
18
|
+
function collect(nodes: VNode[]): VNode[] {
|
|
19
|
+
return nodes.flatMap((node) => {
|
|
20
|
+
if (node.type === Fragment && Array.isArray(node.children)) {
|
|
21
|
+
return collect(node.children as VNode[]);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return node.type === Tab ? [
|
|
25
|
+
node
|
|
26
|
+
] : [];
|
|
27
|
+
});
|
|
28
|
+
}
|
|
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
|
+
|
|
48
|
+
function labels() {
|
|
49
|
+
return labelsOf(panels());
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const { active, select, onKeydown } = useTabs(
|
|
53
|
+
() => labelsOf(collect(slots.default?.() ?? [])),
|
|
54
|
+
() => props.syncKey
|
|
55
|
+
);
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
<template>
|
|
59
|
+
<div class="ff-tabs">
|
|
60
|
+
<div
|
|
61
|
+
class="ff-tabs-list"
|
|
62
|
+
role="tablist"
|
|
63
|
+
@keydown="onKeydown"
|
|
64
|
+
>
|
|
65
|
+
<button
|
|
66
|
+
v-for="(label, index) in labels()"
|
|
67
|
+
:id="`${id}-tab-${index}`"
|
|
68
|
+
:key="index"
|
|
69
|
+
type="button"
|
|
70
|
+
role="tab"
|
|
71
|
+
class="ff-tabs-tab"
|
|
72
|
+
:class="{ active: index === active }"
|
|
73
|
+
:aria-selected="index === active"
|
|
74
|
+
:aria-controls="`${id}-panel-${index}`"
|
|
75
|
+
:tabindex="index === active ? 0 : -1"
|
|
76
|
+
@click="select(index)"
|
|
77
|
+
>
|
|
78
|
+
{{ label }}
|
|
79
|
+
</button>
|
|
80
|
+
</div>
|
|
81
|
+
|
|
82
|
+
<div
|
|
83
|
+
v-for="(panel, index) in panels()"
|
|
84
|
+
v-show="index === active"
|
|
85
|
+
:id="`${id}-panel-${index}`"
|
|
86
|
+
:key="index"
|
|
87
|
+
class="ff-tabs-panel"
|
|
88
|
+
role="tabpanel"
|
|
89
|
+
:aria-labelledby="`${id}-tab-${index}`"
|
|
90
|
+
tabindex="0"
|
|
91
|
+
>
|
|
92
|
+
<component :is="panel" />
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
95
|
+
</template>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { provide, toRef } from 'vue';
|
|
3
|
+
import { TIMELINE_LEVEL } from './timeline';
|
|
4
|
+
|
|
5
|
+
const props = withDefaults(defineProps<{
|
|
6
|
+
/** Heading level of the entry titles, to fit the outline the timeline sits in. */
|
|
7
|
+
level?: 2 | 3 | 4 | 5 | 6
|
|
8
|
+
}>(), {
|
|
9
|
+
level: 3
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
provide(TIMELINE_LEVEL, toRef(props, 'level'));
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<template>
|
|
16
|
+
<div class="ff-timeline">
|
|
17
|
+
<slot />
|
|
18
|
+
</div>
|
|
19
|
+
</template>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { inject, ref } from 'vue';
|
|
3
|
+
import { TIMELINE_LEVEL } from './timeline';
|
|
4
|
+
|
|
5
|
+
// h3 outside a <Timeline>, matching the timeline's own default.
|
|
6
|
+
const level = inject(TIMELINE_LEVEL, ref(3));
|
|
7
|
+
|
|
8
|
+
defineProps<{
|
|
9
|
+
/** Date or period, printed as a small monospaced label above the title. */
|
|
10
|
+
date?: string
|
|
11
|
+
/** Heading of the entry. */
|
|
12
|
+
title?: string
|
|
13
|
+
}>();
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<template>
|
|
17
|
+
<section class="ff-timeline-item">
|
|
18
|
+
<p
|
|
19
|
+
v-if="date"
|
|
20
|
+
class="ff-timeline-date ff-label"
|
|
21
|
+
>
|
|
22
|
+
{{ date }}
|
|
23
|
+
</p>
|
|
24
|
+
|
|
25
|
+
<component
|
|
26
|
+
:is="`h${level}`"
|
|
27
|
+
v-if="title"
|
|
28
|
+
class="ff-timeline-title"
|
|
29
|
+
>
|
|
30
|
+
{{ title }}
|
|
31
|
+
</component>
|
|
32
|
+
|
|
33
|
+
<div class="ff-timeline-body">
|
|
34
|
+
<slot />
|
|
35
|
+
</div>
|
|
36
|
+
</section>
|
|
37
|
+
</template>
|
package/src/index.ts
CHANGED
|
@@ -2,11 +2,19 @@ import type { Theme } from 'vitepress';
|
|
|
2
2
|
import DefaultTheme from 'vitepress/theme';
|
|
3
3
|
|
|
4
4
|
import FfLayout from './layout/FfLayout.vue';
|
|
5
|
+
import FfBlog from './layout/FfBlog.vue';
|
|
5
6
|
import Api from './content/Api.vue';
|
|
7
|
+
import Badge from './content/Badge.vue';
|
|
8
|
+
import Callout from './content/Callout.vue';
|
|
6
9
|
import Card from './content/Card.vue';
|
|
7
10
|
import CardGrid from './content/CardGrid.vue';
|
|
11
|
+
import FileTree from './content/FileTree.vue';
|
|
8
12
|
import Kbd from './content/Kbd.vue';
|
|
9
13
|
import Steps from './content/Steps.vue';
|
|
14
|
+
import Tab from './content/Tab.vue';
|
|
15
|
+
import Tabs from './content/Tabs.vue';
|
|
16
|
+
import Timeline from './content/Timeline.vue';
|
|
17
|
+
import TimelineItem from './content/TimelineItem.vue';
|
|
10
18
|
|
|
11
19
|
import '../dist/style.css';
|
|
12
20
|
|
|
@@ -21,21 +29,42 @@ const theme: Theme = {
|
|
|
21
29
|
extends: DefaultTheme,
|
|
22
30
|
Layout: FfLayout,
|
|
23
31
|
enhanceApp({ app }) {
|
|
32
|
+
// DefaultTheme registers its own `Badge` before this runs; registering over it makes Vue warn
|
|
33
|
+
// in dev, so the original is dropped first.
|
|
34
|
+
delete app._context.components.Badge;
|
|
35
|
+
|
|
24
36
|
app.component('Api', Api);
|
|
37
|
+
app.component('Badge', Badge);
|
|
38
|
+
// `layout: blog` in the frontmatter resolves to this component by name.
|
|
39
|
+
// eslint-disable-next-line vue/component-definition-name-casing
|
|
40
|
+
app.component('blog', FfBlog);
|
|
41
|
+
app.component('Callout', Callout);
|
|
25
42
|
app.component('Card', Card);
|
|
26
43
|
app.component('CardGrid', CardGrid);
|
|
44
|
+
app.component('FileTree', FileTree);
|
|
27
45
|
app.component('Kbd', Kbd);
|
|
28
46
|
app.component('Steps', Steps);
|
|
47
|
+
app.component('Tab', Tab);
|
|
48
|
+
app.component('Tabs', Tabs);
|
|
49
|
+
app.component('Timeline', Timeline);
|
|
50
|
+
app.component('TimelineItem', TimelineItem);
|
|
29
51
|
}
|
|
30
52
|
};
|
|
31
53
|
|
|
32
54
|
export default theme;
|
|
33
55
|
|
|
34
56
|
export { default as Api } from './content/Api.vue';
|
|
57
|
+
export { default as Badge } from './content/Badge.vue';
|
|
58
|
+
export { default as Callout } from './content/Callout.vue';
|
|
35
59
|
export { default as Card } from './content/Card.vue';
|
|
36
60
|
export { default as CardGrid } from './content/CardGrid.vue';
|
|
61
|
+
export { default as FileTree } from './content/FileTree.vue';
|
|
37
62
|
export { default as Kbd } from './content/Kbd.vue';
|
|
38
63
|
export { default as Steps } from './content/Steps.vue';
|
|
64
|
+
export { default as Tab } from './content/Tab.vue';
|
|
65
|
+
export { default as Tabs } from './content/Tabs.vue';
|
|
66
|
+
export { default as Timeline } from './content/Timeline.vue';
|
|
67
|
+
export { default as TimelineItem } from './content/TimelineItem.vue';
|
|
39
68
|
|
|
40
69
|
export {
|
|
41
70
|
defaultLabels, useLabels, useThemeOptions
|
|
@@ -43,13 +72,20 @@ export {
|
|
|
43
72
|
|
|
44
73
|
export type {
|
|
45
74
|
BannerConfig,
|
|
75
|
+
BlogAuthor,
|
|
76
|
+
BlogConfig,
|
|
77
|
+
BlogRssConfig,
|
|
78
|
+
FeedbackConfig,
|
|
46
79
|
FooterColumn,
|
|
47
80
|
FooterLink,
|
|
48
81
|
HeroCommandTab,
|
|
49
82
|
HeroExtras,
|
|
50
83
|
HeroMetaItem,
|
|
51
84
|
MetaConfig,
|
|
85
|
+
OgConfig,
|
|
86
|
+
OgFont,
|
|
52
87
|
ThemeConfig,
|
|
53
88
|
ThemeLabels,
|
|
54
|
-
ThemeOptions
|
|
89
|
+
ThemeOptions,
|
|
90
|
+
VersionsConfig
|
|
55
91
|
} from './types';
|
package/src/internal.ts
CHANGED
|
@@ -2,11 +2,17 @@
|
|
|
2
2
|
//
|
|
3
3
|
// `VPImage`, `VPLink` and `useLayout` are part of its public surface (`vitepress/theme`), but they
|
|
4
4
|
// are imported from their own files instead: components that this theme swaps in through a Vite
|
|
5
|
-
// alias would otherwise import the theme index that imports them back.
|
|
6
|
-
//
|
|
5
|
+
// alias would otherwise import the theme index that imports them back. `normalizeLink` is the one
|
|
6
|
+
// exception: it is not public, but it is what VPLink and VPButton run every href through (site
|
|
7
|
+
// `base`, `.html` suffix without `cleanUrls`), and the theme's own links need the same treatment.
|
|
7
8
|
|
|
9
|
+
export { default as VPBadge } from 'vitepress/dist/client/theme-default/components/VPBadge.vue';
|
|
10
|
+
export { default as VPFlyout } from 'vitepress/dist/client/theme-default/components/VPFlyout.vue';
|
|
8
11
|
export { default as VPIcon } from 'vitepress/dist/client/theme-default/components/VPIcon.vue';
|
|
9
12
|
export { default as VPImage } from 'vitepress/dist/client/theme-default/components/VPImage.vue';
|
|
10
13
|
export { default as VPLink } from 'vitepress/dist/client/theme-default/components/VPLink.vue';
|
|
11
14
|
export { default as VPSponsors } from 'vitepress/dist/client/theme-default/components/VPSponsors.vue';
|
|
15
|
+
export { useLangs } from 'vitepress/dist/client/theme-default/composables/langs.js';
|
|
12
16
|
export { useLayout } from 'vitepress/dist/client/theme-default/composables/layout.js';
|
|
17
|
+
export { normalizeLink } from 'vitepress/dist/client/theme-default/support/utils.js';
|
|
18
|
+
export { isExternal } from 'vitepress/dist/client/shared.js';
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useData, withBase } from 'vitepress';
|
|
3
|
+
import { data as posts } from '../blog/posts.data';
|
|
4
|
+
import {
|
|
5
|
+
formatDate, resolveAuthor, useBlog
|
|
6
|
+
} from '../composables/blog';
|
|
7
|
+
import { format, useLabels } from '../composables/options';
|
|
8
|
+
|
|
9
|
+
const { frontmatter, lang } = useData();
|
|
10
|
+
const { authors } = useBlog();
|
|
11
|
+
const labels = useLabels();
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<template>
|
|
15
|
+
<div class="ff-blog">
|
|
16
|
+
<h1 class="ff-blog-title">
|
|
17
|
+
{{ frontmatter.title }}
|
|
18
|
+
</h1>
|
|
19
|
+
|
|
20
|
+
<p
|
|
21
|
+
v-if="frontmatter.description"
|
|
22
|
+
class="ff-blog-lede"
|
|
23
|
+
>
|
|
24
|
+
{{ frontmatter.description }}
|
|
25
|
+
</p>
|
|
26
|
+
|
|
27
|
+
<ol class="ff-blog-list">
|
|
28
|
+
<li
|
|
29
|
+
v-for="post in posts"
|
|
30
|
+
:key="post.url"
|
|
31
|
+
class="ff-blog-post"
|
|
32
|
+
>
|
|
33
|
+
<div class="ff-blog-meta ff-label">
|
|
34
|
+
<time :datetime="post.date">{{ formatDate(post.date, lang) }}</time>
|
|
35
|
+
<span v-if="post.author">{{ format(labels.blogBy, resolveAuthor(authors, post.author)!.name) }}</span>
|
|
36
|
+
<span
|
|
37
|
+
v-for="tag in post.tags"
|
|
38
|
+
:key="tag"
|
|
39
|
+
>{{ tag }}</span>
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
<h2 class="ff-blog-post-title">
|
|
43
|
+
<a :href="withBase(post.url)">{{ post.title }}</a>
|
|
44
|
+
</h2>
|
|
45
|
+
|
|
46
|
+
<p
|
|
47
|
+
v-if="post.excerpt"
|
|
48
|
+
class="ff-blog-excerpt"
|
|
49
|
+
>
|
|
50
|
+
{{ post.excerpt }}
|
|
51
|
+
</p>
|
|
52
|
+
</li>
|
|
53
|
+
</ol>
|
|
54
|
+
|
|
55
|
+
<p
|
|
56
|
+
v-if="!posts.length"
|
|
57
|
+
class="ff-blog-empty ff-label"
|
|
58
|
+
>
|
|
59
|
+
{{ labels.blogEmpty }}
|
|
60
|
+
</p>
|
|
61
|
+
</div>
|
|
62
|
+
</template>
|
package/src/layout/FfLayout.vue
CHANGED
|
@@ -1,24 +1,31 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import { useSlots } from 'vue';
|
|
3
|
+
import { useData } from 'vitepress';
|
|
3
4
|
import DefaultTheme from 'vitepress/theme';
|
|
4
5
|
import FfBackToTop from '../components/FfBackToTop.vue';
|
|
5
6
|
import FfBanner from '../components/FfBanner.vue';
|
|
7
|
+
import FfCopyStatus from '../components/FfCopyStatus.vue';
|
|
6
8
|
import FfDocMeta from '../components/FfDocMeta.vue';
|
|
9
|
+
import FfFeedback from '../components/FfFeedback.vue';
|
|
10
|
+
import FfPost from '../components/FfPost.vue';
|
|
11
|
+
import FfProgress from '../components/FfProgress.vue';
|
|
7
12
|
import { useThemeOptions } from '../composables/options';
|
|
8
13
|
|
|
9
14
|
const { Layout } = DefaultTheme;
|
|
10
15
|
const options = useThemeOptions();
|
|
16
|
+
const { frontmatter } = useData();
|
|
11
17
|
|
|
12
|
-
//
|
|
18
|
+
// Four slots carry the additions of this theme; every other slot the site passes in is forwarded
|
|
13
19
|
// untouched, so the whole default slot surface keeps working.
|
|
14
20
|
const owned = [
|
|
15
21
|
'layout-top',
|
|
16
22
|
'doc-before',
|
|
23
|
+
'doc-footer-before',
|
|
17
24
|
'layout-bottom'
|
|
18
25
|
];
|
|
19
26
|
|
|
20
27
|
const slots = useSlots();
|
|
21
|
-
const forwarded =
|
|
28
|
+
const forwarded = () => Object.keys(slots).filter((name) => !owned.includes(name));
|
|
22
29
|
</script>
|
|
23
30
|
|
|
24
31
|
<template>
|
|
@@ -26,25 +33,34 @@ const forwarded = computed(() => Object.keys(slots).filter((name) => !owned.incl
|
|
|
26
33
|
class="ff-theme"
|
|
27
34
|
:data-nav-order="options.navOrder ?? 'search-first'"
|
|
28
35
|
:data-nav-sticky="options.navSticky === false ? 'false' : 'true'"
|
|
36
|
+
:data-layout="frontmatter.wide === true ? 'wide' : undefined"
|
|
29
37
|
>
|
|
30
38
|
<Layout>
|
|
31
39
|
<template #layout-top>
|
|
40
|
+
<FfProgress />
|
|
32
41
|
<FfBanner />
|
|
33
42
|
<slot name="layout-top" />
|
|
34
43
|
</template>
|
|
35
44
|
|
|
36
45
|
<template #doc-before>
|
|
37
46
|
<FfDocMeta />
|
|
47
|
+
<FfPost />
|
|
38
48
|
<slot name="doc-before" />
|
|
39
49
|
</template>
|
|
40
50
|
|
|
51
|
+
<template #doc-footer-before>
|
|
52
|
+
<FfFeedback />
|
|
53
|
+
<slot name="doc-footer-before" />
|
|
54
|
+
</template>
|
|
55
|
+
|
|
41
56
|
<template #layout-bottom>
|
|
42
57
|
<slot name="layout-bottom" />
|
|
43
58
|
<FfBackToTop />
|
|
59
|
+
<FfCopyStatus />
|
|
44
60
|
</template>
|
|
45
61
|
|
|
46
62
|
<template
|
|
47
|
-
v-for="name in forwarded"
|
|
63
|
+
v-for="name in forwarded()"
|
|
48
64
|
:key="name"
|
|
49
65
|
#[name]="data"
|
|
50
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 * {
|
|
@@ -73,22 +69,18 @@
|
|
|
73
69
|
border-width: #{mg.ref("rule-width")};
|
|
74
70
|
font-weight: 550;
|
|
75
71
|
letter-spacing: 0.01em;
|
|
76
|
-
transition:
|
|
77
|
-
background-color #{mg.ref("motion-duration")} #{mg.ref("motion-ease")},
|
|
78
|
-
border-color #{mg.ref("motion-duration")} #{mg.ref("motion-ease")},
|
|
79
|
-
color #{mg.ref("motion-duration")} #{mg.ref("motion-ease")};
|
|
80
72
|
}
|
|
81
73
|
|
|
82
74
|
.VPButton.medium {
|
|
83
75
|
padding: 0 1.25rem;
|
|
84
76
|
line-height: 2.75rem;
|
|
85
|
-
font-size:
|
|
77
|
+
font-size: #{mg.ref("size-ui")};
|
|
86
78
|
}
|
|
87
79
|
|
|
88
80
|
.VPButton.big {
|
|
89
81
|
padding: 0 1.75rem;
|
|
90
82
|
line-height: 3.25rem;
|
|
91
|
-
font-size:
|
|
83
|
+
font-size: #{mg.ref("size-ui-lg")};
|
|
92
84
|
}
|
|
93
85
|
|
|
94
86
|
.VPBadge {
|
|
@@ -99,7 +91,7 @@
|
|
|
99
91
|
font-size: #{mg.ref("size-label")};
|
|
100
92
|
font-weight: 500;
|
|
101
93
|
text-transform: uppercase;
|
|
102
|
-
letter-spacing:
|
|
94
|
+
letter-spacing: #{mg.ref("tracking-label-tight")};
|
|
103
95
|
color: #{mg.ref("color-ink-muted")};
|
|
104
96
|
}
|
|
105
97
|
|
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,
|
|
@@ -93,7 +90,7 @@
|
|
|
93
90
|
font-size: #{mg.ref("size-meta")};
|
|
94
91
|
font-weight: 500;
|
|
95
92
|
text-transform: uppercase;
|
|
96
|
-
letter-spacing:
|
|
93
|
+
letter-spacing: #{mg.ref("tracking-label-tight")};
|
|
97
94
|
color: #{mg.ref("color-ink")};
|
|
98
95
|
cursor: pointer;
|
|
99
96
|
}
|
|
@@ -101,4 +98,28 @@
|
|
|
101
98
|
.vp-doc .custom-block.details[open] summary {
|
|
102
99
|
margin-bottom: 0.75rem;
|
|
103
100
|
}
|
|
101
|
+
|
|
102
|
+
// Status badges for `<Badge type="…">`: they extend the tip / warning / danger colours of
|
|
103
|
+
// the base badge, so only the ones that differ from it are declared.
|
|
104
|
+
|
|
105
|
+
.VPBadge.new {
|
|
106
|
+
border-color: #{mg.ref("color-accent")};
|
|
107
|
+
color: #{mg.ref("color-accent")};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.VPBadge.beta {
|
|
111
|
+
border-color: #{mg.ref("color-warning")};
|
|
112
|
+
color: #{mg.ref("color-warning")};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.VPBadge.deprecated {
|
|
116
|
+
border-color: #{mg.ref("color-danger")};
|
|
117
|
+
color: #{mg.ref("color-danger")};
|
|
118
|
+
text-decoration: line-through;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.VPBadge.since {
|
|
122
|
+
border-color: #{mg.ref("color-rule-strong")};
|
|
123
|
+
color: #{mg.ref("color-ink-muted")};
|
|
124
|
+
}
|
|
104
125
|
}
|