@frontfactory/vitepress-theme 1.5.1 → 1.5.3
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/README.md +6 -0
- package/config.js +3 -1
- package/package.json +1 -1
- package/src/components/FfFeature.vue +4 -6
- package/src/components/FfHeroCommand.vue +7 -2
- package/src/composables/link.ts +14 -0
- package/src/content/Card.vue +3 -6
package/README.md
CHANGED
|
@@ -10,6 +10,12 @@ token to make it yours.
|
|
|
10
10
|
It extends the VitePress default theme rather than forking it: search, i18n, mobile navigation and
|
|
11
11
|
every markdown feature keep working, while the whole surface is redrawn.
|
|
12
12
|
|
|
13
|
+
## Playground
|
|
14
|
+
|
|
15
|
+
Try it live on StackBlitz — no installation required:
|
|
16
|
+
|
|
17
|
+
[](https://stackblitz.com/~/github.com/front-factory/vitepress-theme?startScript=dev:playground)
|
|
18
|
+
|
|
13
19
|
## Install
|
|
14
20
|
|
|
15
21
|
```bash
|
package/config.js
CHANGED
|
@@ -69,11 +69,13 @@ const config = {
|
|
|
69
69
|
return [];
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
const key = JSON.stringify(`ff-banner-${id}`);
|
|
73
|
+
|
|
72
74
|
return [
|
|
73
75
|
[
|
|
74
76
|
'script',
|
|
75
77
|
{},
|
|
76
|
-
`try{if(localStorage.getItem(
|
|
78
|
+
`try{if(localStorage.getItem(${key}))` +
|
|
77
79
|
'document.documentElement.classList.add(\'ff-banner-dismissed\')}catch(e){}'
|
|
78
80
|
]
|
|
79
81
|
];
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { VPImage, VPLink } from '../internal';
|
|
3
|
+
import { cardLinkProps } from '../composables/link';
|
|
3
4
|
import type { DefaultTheme } from 'vitepress/theme';
|
|
4
5
|
|
|
5
|
-
defineProps<{
|
|
6
|
+
const props = defineProps<{
|
|
6
7
|
icon?: DefaultTheme.FeatureIcon
|
|
7
8
|
title: string
|
|
8
9
|
details?: string | string[]
|
|
@@ -16,11 +17,7 @@ defineProps<{
|
|
|
16
17
|
<template>
|
|
17
18
|
<VPLink
|
|
18
19
|
class="VPFeature ff-feature"
|
|
19
|
-
|
|
20
|
-
:rel="rel"
|
|
21
|
-
:target="target"
|
|
22
|
-
:no-icon="true"
|
|
23
|
-
:tag="link ? 'a' : 'div'"
|
|
20
|
+
v-bind="cardLinkProps(props.link, props.rel, props.target)"
|
|
24
21
|
>
|
|
25
22
|
<span
|
|
26
23
|
class="ff-feature-index"
|
|
@@ -41,6 +38,7 @@ defineProps<{
|
|
|
41
38
|
<div
|
|
42
39
|
v-else-if="icon"
|
|
43
40
|
class="ff-feature-icon"
|
|
41
|
+
aria-hidden="true"
|
|
44
42
|
v-html="icon"
|
|
45
43
|
/>
|
|
46
44
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import {
|
|
3
|
-
computed, ref, watch
|
|
3
|
+
computed, onUnmounted, ref, watch
|
|
4
4
|
} from 'vue';
|
|
5
5
|
import { format, useLabels } from '../composables/options';
|
|
6
6
|
import type { HeroCommandTab } from '../types';
|
|
@@ -31,6 +31,7 @@ const activeCommand = computed<string>(() =>
|
|
|
31
31
|
);
|
|
32
32
|
|
|
33
33
|
const copied = ref(false);
|
|
34
|
+
let copiedTimer: ReturnType<typeof setTimeout> | undefined;
|
|
34
35
|
|
|
35
36
|
async function copy() {
|
|
36
37
|
if (!activeCommand.value) {
|
|
@@ -39,8 +40,12 @@ async function copy() {
|
|
|
39
40
|
|
|
40
41
|
await navigator.clipboard.writeText(activeCommand.value);
|
|
41
42
|
copied.value = true;
|
|
42
|
-
|
|
43
|
+
|
|
44
|
+
clearTimeout(copiedTimer);
|
|
45
|
+
copiedTimer = setTimeout(() => (copied.value = false), 2000);
|
|
43
46
|
}
|
|
47
|
+
|
|
48
|
+
onUnmounted(() => clearTimeout(copiedTimer));
|
|
44
49
|
</script>
|
|
45
50
|
|
|
46
51
|
<template>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `VPLink` wiring shared by every card-like block that is either a link or a plain container
|
|
3
|
+
* (`FfFeature`, `Card`): the tag follows the link, and the icon VitePress would otherwise add next
|
|
4
|
+
* to external links is always suppressed since these blocks draw their own.
|
|
5
|
+
*/
|
|
6
|
+
export function cardLinkProps(link?: string, rel?: string, target?: string) {
|
|
7
|
+
return {
|
|
8
|
+
href: link,
|
|
9
|
+
rel,
|
|
10
|
+
target,
|
|
11
|
+
noIcon: true,
|
|
12
|
+
tag: link ? 'a' : 'div'
|
|
13
|
+
} as const;
|
|
14
|
+
}
|
package/src/content/Card.vue
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { VPLink } from '../internal';
|
|
3
|
+
import { cardLinkProps } from '../composables/link';
|
|
3
4
|
|
|
4
|
-
defineProps<{
|
|
5
|
+
const props = defineProps<{
|
|
5
6
|
title: string
|
|
6
7
|
/** Inline SVG or emoji shown above the title. */
|
|
7
8
|
icon?: string
|
|
@@ -14,11 +15,7 @@ defineProps<{
|
|
|
14
15
|
<template>
|
|
15
16
|
<VPLink
|
|
16
17
|
class="ff-card"
|
|
17
|
-
|
|
18
|
-
:rel="rel"
|
|
19
|
-
:target="target"
|
|
20
|
-
:no-icon="true"
|
|
21
|
-
:tag="link ? 'a' : 'div'"
|
|
18
|
+
v-bind="cardLinkProps(props.link, props.rel, props.target)"
|
|
22
19
|
>
|
|
23
20
|
<span
|
|
24
21
|
v-if="icon"
|