@frontfactory/vitepress-theme 1.5.0 → 1.5.2

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.
@@ -1,23 +1,27 @@
1
1
  <script setup lang="ts">
2
- import { computed } from 'vue'
3
- import { useData } from 'vitepress'
4
- import { useLayout, VPIcon, VPLink } from '../internal'
5
- import { useLabels, useThemeOptions } from '../composables/options'
6
- import type { DefaultTheme } from '../types'
2
+ import { computed } from 'vue';
3
+ import { useData } from 'vitepress';
4
+ import {
5
+ useLayout, VPIcon, VPLink
6
+ } from '../internal';
7
+ import { useLabels, useThemeOptions } from '../composables/options';
8
+ import type { DefaultTheme } from '../types';
7
9
 
8
- const { theme, frontmatter } = useData()
9
- const { hasSidebar } = useLayout()
10
- const options = useThemeOptions()
11
- const labels = useLabels()
10
+ const { theme, frontmatter } = useData();
11
+ const { hasSidebar } = useLayout();
12
+ const options = useThemeOptions();
13
+ const labels = useLabels();
12
14
 
13
- const columns = computed(() => options.value.footerColumns ?? [])
15
+ const columns = computed(() => options.value.footerColumns ?? []);
14
16
 
15
17
  /**
16
18
  * `themeConfig.socialLinks`, printed as a normal footer column: one row per network, its logo
17
19
  * beside a readable name. The name is the entry's `ariaLabel`, or the icon slug it defaults to.
18
20
  */
19
21
  const social = computed(() => {
20
- if (options.value.footerSocial === false) return []
22
+ if (options.value.footerSocial === false) {
23
+ return [];
24
+ }
21
25
 
22
26
  return ((theme.value.socialLinks ?? []) as DefaultTheme.SocialLink[]).map((link) => ({
23
27
  ...link,
@@ -26,56 +30,98 @@ const social = computed(() => {
26
30
  ? `simple-icons:${link.icon}`
27
31
  : link.icon,
28
32
  text: link.ariaLabel ?? (typeof link.icon === 'string' ? link.icon : '')
29
- }))
30
- })
33
+ }));
34
+ });
31
35
 
32
36
  const visible = computed(
33
37
  () =>
34
38
  (theme.value.footer || columns.value.length || social.value.length) &&
35
39
  frontmatter.value.footer !== false
36
- )
40
+ );
37
41
  </script>
38
42
 
39
43
  <template>
40
- <footer v-if="visible" class="VPFooter ff-footer" :class="{ 'has-sidebar': hasSidebar }">
41
- <div class="ff-footer-container">
42
- <div v-if="columns.length || social.length" class="ff-footer-top">
43
- <div v-if="columns.length" class="ff-footer-columns">
44
- <div v-for="column in columns" :key="column.title" class="ff-footer-column">
45
- <p class="ff-label">{{ column.title }}</p>
44
+ <footer
45
+ v-if="visible"
46
+ class="VPFooter ff-footer"
47
+ :class="{ 'has-sidebar': hasSidebar }"
48
+ >
49
+ <div class="ff-footer-container">
50
+ <div
51
+ v-if="columns.length || social.length"
52
+ class="ff-footer-top"
53
+ >
54
+ <div
55
+ v-if="columns.length"
56
+ class="ff-footer-columns"
57
+ >
58
+ <div
59
+ v-for="column in columns"
60
+ :key="column.title"
61
+ class="ff-footer-column"
62
+ >
63
+ <p class="ff-label">
64
+ {{ column.title }}
65
+ </p>
46
66
 
47
- <ul>
48
- <li v-for="item in column.items" :key="item.link">
49
- <VPLink :href="item.link" :rel="item.rel" :target="item.target">
50
- {{ item.text }}
51
- </VPLink>
52
- </li>
53
- </ul>
54
- </div>
55
- </div>
56
-
57
- <div v-if="social.length" class="ff-footer-column ff-footer-social">
58
- <p class="ff-label">{{ labels.footerSocial }}</p>
67
+ <ul>
68
+ <li
69
+ v-for="item in column.items"
70
+ :key="item.link"
71
+ >
72
+ <VPLink
73
+ :href="item.link"
74
+ :rel="item.rel"
75
+ :target="item.target"
76
+ >
77
+ {{ item.text }}
78
+ </VPLink>
79
+ </li>
80
+ </ul>
81
+ </div>
82
+ </div>
59
83
 
60
- <ul>
61
- <li v-for="item in social" :key="item.link">
62
- <a
63
- :href="item.link"
64
- :target="item.target ?? '_blank'"
65
- rel="me noopener"
66
- >
67
- <VPIcon :icon="item.icon" />
68
- <span>{{ item.text }}</span>
69
- </a>
70
- </li>
71
- </ul>
72
- </div>
73
- </div>
84
+ <div
85
+ v-if="social.length"
86
+ class="ff-footer-column ff-footer-social"
87
+ >
88
+ <p class="ff-label">
89
+ {{ labels.footerSocial }}
90
+ </p>
74
91
 
75
- <div v-if="theme.footer" class="ff-footer-legal">
76
- <p v-if="theme.footer.message" class="message" v-html="theme.footer.message" />
77
- <p v-if="theme.footer.copyright" class="copyright" v-html="theme.footer.copyright" />
78
- </div>
92
+ <ul>
93
+ <li
94
+ v-for="item in social"
95
+ :key="item.link"
96
+ >
97
+ <a
98
+ :href="item.link"
99
+ :target="item.target ?? '_blank'"
100
+ rel="me noopener"
101
+ >
102
+ <VPIcon :icon="item.icon" />
103
+ <span>{{ item.text }}</span>
104
+ </a>
105
+ </li>
106
+ </ul>
79
107
  </div>
80
- </footer>
108
+ </div>
109
+
110
+ <div
111
+ v-if="theme.footer"
112
+ class="ff-footer-legal"
113
+ >
114
+ <p
115
+ v-if="theme.footer.message"
116
+ class="message"
117
+ v-html="theme.footer.message"
118
+ />
119
+ <p
120
+ v-if="theme.footer.copyright"
121
+ class="copyright"
122
+ v-html="theme.footer.copyright"
123
+ />
124
+ </div>
125
+ </div>
126
+ </footer>
81
127
  </template>
@@ -1,10 +1,12 @@
1
1
  <script setup lang="ts">
2
- import { Comment, computed, Fragment, Text, useSlots, type VNode } from 'vue'
3
- import { useData } from 'vitepress'
4
- import { VPImage } from '../internal'
5
- import FfHeroCommand from './FfHeroCommand.vue'
6
- import type { HeroExtras, HeroMetaItem } from '../types'
7
- import type { DefaultTheme } from 'vitepress/theme'
2
+ import {
3
+ Comment, computed, Fragment, Text, useSlots, type VNode
4
+ } from 'vue';
5
+ import { useData } from 'vitepress';
6
+ import { VPImage } from '../internal';
7
+ import FfHeroCommand from './FfHeroCommand.vue';
8
+ import type { HeroExtras, HeroMetaItem } from '../types';
9
+ import type { DefaultTheme } from 'vitepress/theme';
8
10
 
9
11
  export interface HeroAction {
10
12
  theme?: 'brand' | 'alt'
@@ -20,10 +22,10 @@ const props = defineProps<{
20
22
  tagline?: string
21
23
  image?: DefaultTheme.ThemeableImage
22
24
  actions?: HeroAction[]
23
- }>()
25
+ }>();
24
26
 
25
- const { frontmatter } = useData()
26
- const slots = useSlots()
27
+ const { frontmatter } = useData();
28
+ const slots = useSlots();
27
29
 
28
30
  // Three additions to the standard home frontmatter, all optional:
29
31
  //
@@ -31,12 +33,12 @@ const slots = useSlots()
31
33
  // hero.quote a short line ruled like a markdown blockquote — under the tagline normally, or
32
34
  // under the install line instead once one sits inline beneath it (see hasInlineCommand)
33
35
  // hero.meta a colophon strip under the hero: [{ label, value }, …]
34
- const hero = computed<HeroExtras>(() => frontmatter.value.hero ?? {})
35
- const command = computed<HeroExtras['command']>(() => hero.value.command)
36
- const hasCommand = computed(() => (Array.isArray(command.value) ? command.value.length > 0 : !!command.value))
37
- const hasActions = computed(() => !!props.actions?.length)
38
- const quote = computed<string | undefined>(() => hero.value.quote)
39
- const meta = computed<HeroMetaItem[]>(() => hero.value.meta ?? [])
36
+ const hero = computed<HeroExtras>(() => frontmatter.value.hero ?? {});
37
+ const command = computed<HeroExtras['command']>(() => hero.value.command);
38
+ const hasCommand = computed(() => (Array.isArray(command.value) ? command.value.length > 0 : !!command.value));
39
+ const hasActions = computed(() => !!props.actions?.length);
40
+ const quote = computed<string | undefined>(() => hero.value.quote);
41
+ const meta = computed<HeroMetaItem[]>(() => hero.value.meta ?? []);
40
42
 
41
43
  /**
42
44
  * The home layout always declares the `home-hero-image` slot, so its presence says nothing about
@@ -45,123 +47,180 @@ const meta = computed<HeroMetaItem[]>(() => hero.value.meta ?? [])
45
47
  */
46
48
  function filled(nodes?: VNode[]): boolean {
47
49
  return !!nodes?.some((node) => {
48
- if (node.type === Comment) return false
49
- if (node.type === Text) return String(node.children).trim() !== ''
50
+ if (node.type === Comment) {
51
+ return false;
52
+ }
53
+
54
+ if (node.type === Text) {
55
+ return String(node.children).trim() !== '';
56
+ }
57
+
50
58
  if (node.type === Fragment) {
51
- return Array.isArray(node.children) && filled(node.children as VNode[])
59
+ return Array.isArray(node.children) && filled(node.children as VNode[]);
52
60
  }
53
61
 
54
- return true
55
- })
62
+ return true;
63
+ });
56
64
  }
57
65
 
58
66
  // Called from the template rather than cached in a computed: the slot has to be rendered where its
59
67
  // dependencies are tracked, and it changes with the page.
60
68
  function hasImage() {
61
- return !!props.image || filled(slots['home-hero-image']?.())
69
+ return !!props.image || filled(slots['home-hero-image']?.());
62
70
  }
63
71
 
64
72
  // The second column carries the image when there is one, and the starting point otherwise. The
65
73
  // actions only move over there when they have a panel to sit in.
66
74
  function hasPanel() {
67
- return !hasImage() && hasCommand.value
75
+ return !hasImage() && hasCommand.value;
68
76
  }
69
77
 
70
78
  // An image claims the second column, so the install panel has nowhere to sit beside the text —
71
79
  // it drops under it instead rather than disappearing.
72
80
  function hasInlineCommand() {
73
- return hasImage() && hasCommand.value
81
+ return hasImage() && hasCommand.value;
74
82
  }
75
83
  </script>
76
84
 
77
85
  <template>
78
- <div
79
- class="VPHero ff-hero"
80
- :class="{ 'has-image': hasImage(), 'has-panel': hasPanel() }"
81
- >
82
- <span class="ff-hero-glow" aria-hidden="true" />
83
- <span class="ff-hero-glow ff-hero-glow-far" aria-hidden="true" />
84
-
85
- <div class="ff-hero-container">
86
- <div class="ff-hero-main">
87
- <slot name="home-hero-info-before" />
88
-
89
- <slot name="home-hero-info">
90
- <p v-if="name" class="ff-hero-kicker ff-label" v-html="name" />
91
-
92
- <h1 v-if="text" class="ff-hero-title ff-display" v-html="text" />
93
-
94
- <p v-if="tagline" class="ff-hero-tagline" v-html="tagline" />
95
-
96
- <blockquote v-if="quote && !hasInlineCommand()" class="ff-hero-quote" v-html="quote" />
97
- </slot>
98
-
99
- <slot name="home-hero-info-after" />
100
-
101
- <div v-if="hasActions && !hasPanel()" class="ff-hero-actions">
102
- <slot name="home-hero-actions-before-actions" />
103
-
104
- <a
105
- v-for="action in actions"
106
- :key="action.link"
107
- class="ff-btn"
108
- :class="`ff-btn-${action.theme ?? 'brand'}`"
109
- :href="action.link"
110
- :target="action.target"
111
- :rel="action.rel"
112
- >
113
- {{ action.text }}
114
- </a>
115
- </div>
116
-
117
- <slot name="home-hero-actions-after" />
118
-
119
- <FfHeroCommand
120
- v-if="hasInlineCommand()"
121
- :command="command!"
122
- bare
123
- class="ff-hero-panel ff-hero-panel-inline ff-hero-panel-bare"
124
- />
125
-
126
- <blockquote v-if="quote && hasInlineCommand()" class="ff-hero-quote" v-html="quote" />
127
- </div>
128
-
129
- <div v-if="hasImage()" class="ff-hero-image">
130
- <slot name="home-hero-image">
131
- <VPImage v-if="image" class="ff-hero-image-src" :image="image" />
132
- </slot>
133
- </div>
134
-
135
- <aside
136
- v-else-if="hasPanel()"
137
- class="ff-hero-panel"
138
- :class="{ 'ff-hero-panel-bare': !hasActions }"
139
- >
140
- <FfHeroCommand :command="command!" :bare="!hasActions" />
141
-
142
- <div v-if="hasActions" class="ff-hero-actions">
143
- <slot name="home-hero-actions-before-actions" />
144
-
145
- <a
146
- v-for="action in actions"
147
- :key="action.link"
148
- class="ff-btn"
149
- :class="`ff-btn-${action.theme ?? 'brand'}`"
150
- :href="action.link"
151
- :target="action.target"
152
- :rel="action.rel"
153
- >
154
- {{ action.text }}
155
- </a>
156
- </div>
157
- </aside>
86
+ <div
87
+ class="VPHero ff-hero"
88
+ :class="{ 'has-image': hasImage(), 'has-panel': hasPanel() }"
89
+ >
90
+ <span
91
+ class="ff-hero-glow"
92
+ aria-hidden="true"
93
+ />
94
+ <span
95
+ class="ff-hero-glow ff-hero-glow-far"
96
+ aria-hidden="true"
97
+ />
98
+
99
+ <div class="ff-hero-container">
100
+ <div class="ff-hero-main">
101
+ <slot name="home-hero-info-before" />
102
+
103
+ <slot name="home-hero-info">
104
+ <p
105
+ v-if="name"
106
+ class="ff-hero-kicker ff-label"
107
+ v-html="name"
108
+ />
109
+
110
+ <h1
111
+ v-if="text"
112
+ class="ff-hero-title ff-display"
113
+ v-html="text"
114
+ />
115
+
116
+ <p
117
+ v-if="tagline"
118
+ class="ff-hero-tagline"
119
+ v-html="tagline"
120
+ />
121
+
122
+ <blockquote
123
+ v-if="quote && !hasInlineCommand()"
124
+ class="ff-hero-quote"
125
+ v-html="quote"
126
+ />
127
+ </slot>
128
+
129
+ <slot name="home-hero-info-after" />
130
+
131
+ <div
132
+ v-if="hasActions && !hasPanel()"
133
+ class="ff-hero-actions"
134
+ >
135
+ <slot name="home-hero-actions-before-actions" />
136
+
137
+ <a
138
+ v-for="action in actions"
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"
145
+ >
146
+ {{ action.text }}
147
+ </a>
158
148
  </div>
159
149
 
160
- <dl v-if="meta.length" class="ff-hero-meta">
161
- <div v-for="item in meta" :key="item.label" class="ff-hero-meta-item">
162
- <dt class="ff-label">{{ item.label }}</dt>
163
- <dd>{{ item.value }}</dd>
164
- </div>
165
- </dl>
150
+ <slot name="home-hero-actions-after" />
151
+
152
+ <FfHeroCommand
153
+ v-if="hasInlineCommand()"
154
+ :command="command!"
155
+ bare
156
+ class="ff-hero-panel ff-hero-panel-inline ff-hero-panel-bare"
157
+ />
158
+
159
+ <blockquote
160
+ v-if="quote && hasInlineCommand()"
161
+ class="ff-hero-quote"
162
+ v-html="quote"
163
+ />
164
+ </div>
165
+
166
+ <div
167
+ v-if="hasImage()"
168
+ class="ff-hero-image"
169
+ >
170
+ <slot name="home-hero-image">
171
+ <VPImage
172
+ v-if="image"
173
+ class="ff-hero-image-src"
174
+ :image="image"
175
+ />
176
+ </slot>
177
+ </div>
178
+
179
+ <aside
180
+ v-else-if="hasPanel()"
181
+ class="ff-hero-panel"
182
+ :class="{ 'ff-hero-panel-bare': !hasActions }"
183
+ >
184
+ <FfHeroCommand
185
+ :command="command!"
186
+ :bare="!hasActions"
187
+ />
188
+
189
+ <div
190
+ v-if="hasActions"
191
+ class="ff-hero-actions"
192
+ >
193
+ <slot name="home-hero-actions-before-actions" />
194
+
195
+ <a
196
+ v-for="action in actions"
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"
203
+ >
204
+ {{ action.text }}
205
+ </a>
206
+ </div>
207
+ </aside>
166
208
  </div>
209
+
210
+ <dl
211
+ v-if="meta.length"
212
+ class="ff-hero-meta"
213
+ >
214
+ <div
215
+ v-for="item in meta"
216
+ :key="item.label"
217
+ class="ff-hero-meta-item"
218
+ >
219
+ <dt class="ff-label">
220
+ {{ item.label }}
221
+ </dt>
222
+ <dd>{{ item.value }}</dd>
223
+ </div>
224
+ </dl>
225
+ </div>
167
226
  </template>
@@ -1,7 +1,9 @@
1
1
  <script setup lang="ts">
2
- import { computed, ref, watch } from 'vue'
3
- import { format, useLabels } from '../composables/options'
4
- import type { HeroCommandTab } from '../types'
2
+ import {
3
+ computed, ref, watch
4
+ } from 'vue';
5
+ import { format, useLabels } from '../composables/options';
6
+ import type { HeroCommandTab } from '../types';
5
7
 
6
8
  // Used from both hero panel positions (inline and beside the headline, see FfHero), which are
7
9
  // mutually exclusive — so the active tab lives here rather than being lifted to the parent.
@@ -9,73 +11,90 @@ const props = defineProps<{
9
11
  command: string | HeroCommandTab[]
10
12
  /** No actions sit under this command — print the bare line, without the "Install" heading. */
11
13
  bare?: boolean
12
- }>()
14
+ }>();
13
15
 
14
- const labels = useLabels()
16
+ const labels = useLabels();
15
17
 
16
18
  const tabs = computed<HeroCommandTab[] | undefined>(() =>
17
19
  Array.isArray(props.command) ? props.command : undefined
18
- )
20
+ );
19
21
 
20
- const activeTab = ref(0)
22
+ const activeTab = ref(0);
21
23
 
22
24
  // Client-side navigation can swap the tabs a shorter or longer array without remounting this
23
25
  // component (two home pages in the same site), so the index is reset rather than left pointing
24
26
  // past the end.
25
- watch(tabs, () => (activeTab.value = 0))
27
+ watch(tabs, () => (activeTab.value = 0));
26
28
 
27
29
  const activeCommand = computed<string>(() =>
28
30
  tabs.value ? (tabs.value[activeTab.value]?.value ?? '') : (props.command as string)
29
- )
31
+ );
30
32
 
31
- const copied = ref(false)
33
+ const copied = ref(false);
32
34
 
33
35
  async function copy() {
34
- if (!activeCommand.value) return
36
+ if (!activeCommand.value) {
37
+ return;
38
+ }
35
39
 
36
- await navigator.clipboard.writeText(activeCommand.value)
37
- copied.value = true
38
- setTimeout(() => (copied.value = false), 2000)
40
+ await navigator.clipboard.writeText(activeCommand.value);
41
+ copied.value = true;
42
+ setTimeout(() => (copied.value = false), 2000);
39
43
  }
40
44
  </script>
41
45
 
42
46
  <template>
43
- <div class="ff-hero-command-panel">
44
- <p v-if="!bare" class="ff-hero-panel-label ff-label">{{ labels.heroInstall }}</p>
47
+ <div class="ff-hero-command-panel">
48
+ <p
49
+ v-if="!bare"
50
+ class="ff-hero-panel-label ff-label"
51
+ >
52
+ {{ labels.heroInstall }}
53
+ </p>
45
54
 
46
- <div v-if="tabs" class="ff-hero-command-tabs" role="tablist">
47
- <button
48
- v-for="(tab, index) in tabs"
49
- :key="tab.label"
50
- type="button"
51
- role="tab"
52
- class="ff-hero-command-tab"
53
- :class="{ active: index === activeTab }"
54
- :aria-selected="index === activeTab"
55
- @click="activeTab = index"
56
- >
57
- {{ tab.label }}
58
- </button>
59
- </div>
55
+ <div
56
+ v-if="tabs"
57
+ class="ff-hero-command-tabs"
58
+ role="tablist"
59
+ >
60
+ <button
61
+ v-for="(tab, index) in tabs"
62
+ :key="tab.label"
63
+ type="button"
64
+ role="tab"
65
+ class="ff-hero-command-tab"
66
+ :class="{ active: index === activeTab }"
67
+ :aria-selected="index === activeTab"
68
+ @click="activeTab = index"
69
+ >
70
+ {{ tab.label }}
71
+ </button>
72
+ </div>
60
73
 
61
- <div class="ff-hero-command">
62
- <code>
63
- <span class="ff-hero-prompt" aria-hidden="true">$</span>
64
- {{ activeCommand }}
65
- </code>
74
+ <div class="ff-hero-command">
75
+ <code>
76
+ <span
77
+ class="ff-hero-prompt"
78
+ aria-hidden="true"
79
+ >$</span>
80
+ {{ activeCommand }}
81
+ </code>
66
82
 
67
- <span class="ff-hero-copy-group">
68
- <span v-if="copied" class="ff-hero-copied ff-label">{{ labels.heroCopied }}</span>
83
+ <span class="ff-hero-copy-group">
84
+ <span
85
+ v-if="copied"
86
+ class="ff-hero-copied ff-label"
87
+ >{{ labels.heroCopied }}</span>
69
88
 
70
- <button
71
- type="button"
72
- class="ff-hero-copy"
73
- :class="{ copied }"
74
- :title="format(labels.heroCopyLabel, activeCommand)"
75
- :aria-label="format(labels.heroCopyLabel, activeCommand)"
76
- @click="copy"
77
- />
78
- </span>
79
- </div>
89
+ <button
90
+ type="button"
91
+ class="ff-hero-copy"
92
+ :class="{ copied }"
93
+ :title="format(labels.heroCopyLabel, activeCommand)"
94
+ :aria-label="format(labels.heroCopyLabel, activeCommand)"
95
+ @click="copy"
96
+ />
97
+ </span>
80
98
  </div>
99
+ </div>
81
100
  </template>