valaxy-theme-press 0.26.13 → 0.28.0-beta.1
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/components/PressAlgoliaSearch.vue +243 -231
- package/components/PressArticle.vue +51 -10
- package/components/PressArticleCard.vue +18 -6
- package/components/PressDocFooter.vue +1 -1
- package/components/PressNavBarAskAiButton.vue +42 -0
- package/components/PressNavBarSearch.vue +132 -10
- package/components/PressNavBarSearchButton.vue +158 -0
- package/components/PressPostActions.vue +274 -0
- package/components/PressPostList.vue +5 -2
- package/components/ValaxyMain.vue +7 -4
- package/layouts/posts.vue +23 -0
- package/layouts/tags.vue +85 -0
- package/package.json +6 -4
- package/setup/main.ts +7 -1
- package/styles/docsearch.css +106 -0
- package/valaxy.config.ts +1 -1
package/layouts/tags.vue
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { useFrontmatter, useSiteStore, useTags, useValaxyI18n } from 'valaxy'
|
|
3
|
+
import { computed } from 'vue'
|
|
4
|
+
import { useRoute, useRouter } from 'vue-router'
|
|
5
|
+
|
|
6
|
+
const route = useRoute()
|
|
7
|
+
const router = useRouter()
|
|
8
|
+
const frontmatter = useFrontmatter()
|
|
9
|
+
const site = useSiteStore()
|
|
10
|
+
const { $tO } = useValaxyI18n()
|
|
11
|
+
|
|
12
|
+
const tags = useTags()
|
|
13
|
+
|
|
14
|
+
const curTag = computed(() => route.query.tag as string || '')
|
|
15
|
+
|
|
16
|
+
const filteredPosts = computed(() => {
|
|
17
|
+
return site.postList.filter((post) => {
|
|
18
|
+
if (post.tags) {
|
|
19
|
+
if (typeof post.tags === 'string')
|
|
20
|
+
return post.tags === curTag.value
|
|
21
|
+
else
|
|
22
|
+
return post.tags.includes(curTag.value)
|
|
23
|
+
}
|
|
24
|
+
return false
|
|
25
|
+
})
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
const title = computed(() => $tO(frontmatter.value.title) || 'Tags')
|
|
29
|
+
|
|
30
|
+
const tagArr = computed(() => Array.from(tags.value).sort())
|
|
31
|
+
|
|
32
|
+
function getTagSize(count: number) {
|
|
33
|
+
const counts = Array.from(tags.value).map(([_, v]) => v.count)
|
|
34
|
+
const max = Math.max(...counts)
|
|
35
|
+
const min = Math.min(...counts)
|
|
36
|
+
const range = max - min || 1
|
|
37
|
+
const percent = (count - min) / range
|
|
38
|
+
return `${percent * 20 + 14}px`
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function selectTag(tag: string) {
|
|
42
|
+
router.push({ query: { tag } })
|
|
43
|
+
}
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<template>
|
|
47
|
+
<Layout>
|
|
48
|
+
<template #main-content>
|
|
49
|
+
<div class="max-w-6xl mx-auto w-full pb-12 px-4 sm:px-6 lg:px-8">
|
|
50
|
+
<div class="pt-6 pb-8 space-y-2 md:space-y-5">
|
|
51
|
+
<h1 class="text-3xl leading-9 font-extrabold text-gray-900 dark:text-gray-100 tracking-tight sm:text-4xl sm:leading-10 md:text-5xl md:leading-13">
|
|
52
|
+
{{ title }}
|
|
53
|
+
</h1>
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
<!-- Tag Cloud -->
|
|
57
|
+
<div class="flex flex-wrap items-end gap-3 pb-8">
|
|
58
|
+
<button
|
|
59
|
+
v-for="([key, tag]) in tagArr"
|
|
60
|
+
:key="key"
|
|
61
|
+
class="inline-flex items-baseline gap-1 rounded-full px-3 py-1 transition-colors border-none cursor-pointer"
|
|
62
|
+
:class="curTag === key
|
|
63
|
+
? 'bg-primary/15 text-primary dark:bg-primary/20 dark:text-primary'
|
|
64
|
+
: 'bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400 hover:bg-primary/10 hover:text-primary'"
|
|
65
|
+
:style="{ fontSize: getTagSize(tag.count) }"
|
|
66
|
+
@click="selectTag(key.toString())"
|
|
67
|
+
>
|
|
68
|
+
<span>#{{ key }}</span>
|
|
69
|
+
<span class="text-xs op-70">({{ tag.count }})</span>
|
|
70
|
+
</button>
|
|
71
|
+
</div>
|
|
72
|
+
|
|
73
|
+
<!-- Filtered Posts -->
|
|
74
|
+
<div v-if="curTag">
|
|
75
|
+
<h2 class="text-xl font-bold text-gray-900 dark:text-gray-100 mb-6 flex items-center gap-2">
|
|
76
|
+
<span class="i-ri-hashtag" />
|
|
77
|
+
{{ curTag }}
|
|
78
|
+
<span class="text-sm font-normal text-gray-500">({{ filteredPosts.length }})</span>
|
|
79
|
+
</h2>
|
|
80
|
+
<PressPostList :posts="filteredPosts" />
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
</template>
|
|
84
|
+
</Layout>
|
|
85
|
+
</template>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "valaxy-theme-press",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0-beta.1",
|
|
4
4
|
"description": "Docs Theme for Valaxy",
|
|
5
5
|
"author": {
|
|
6
6
|
"email": "me@yunyoujun.cn",
|
|
@@ -22,10 +22,12 @@
|
|
|
22
22
|
"main": "node/index.ts",
|
|
23
23
|
"types": "types/index.d.ts",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@docsearch/css": "^
|
|
26
|
-
"@docsearch/js": "^
|
|
25
|
+
"@docsearch/css": "^4.6.0",
|
|
26
|
+
"@docsearch/js": "^4.6.0",
|
|
27
|
+
"@docsearch/sidepanel-js": "^4.6.0",
|
|
28
|
+
"reka-ui": "^2.8.2"
|
|
27
29
|
},
|
|
28
30
|
"devDependencies": {
|
|
29
|
-
"valaxy": "0.
|
|
31
|
+
"valaxy": "0.28.0-beta.1"
|
|
30
32
|
}
|
|
31
33
|
}
|
package/setup/main.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { defineAppSetup, scrollTo } from 'valaxy'
|
|
2
2
|
import { nextTick } from 'vue'
|
|
3
|
+
import PressToggleLocale from '../components/PressToggleLocale.vue'
|
|
3
4
|
|
|
4
5
|
import 'valaxy/client/styles/common/index.scss'
|
|
5
6
|
|
|
@@ -18,7 +19,12 @@ import 'vitepress/dist/client/theme-default/styles/components/vp-doc.css'
|
|
|
18
19
|
// import 'vitepress/dist/client/theme-default/styles/components/vp-sponsor.css'
|
|
19
20
|
|
|
20
21
|
export default defineAppSetup((ctx) => {
|
|
21
|
-
const { router, isClient } = ctx
|
|
22
|
+
const { app, router, isClient } = ctx
|
|
23
|
+
|
|
24
|
+
// Register components that may appear in post excerpts
|
|
25
|
+
// (runtime-compiled templates can only resolve globally registered components)
|
|
26
|
+
app.component('PressToggleLocale', PressToggleLocale)
|
|
27
|
+
|
|
22
28
|
if (!isClient)
|
|
23
29
|
return
|
|
24
30
|
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
@import '@docsearch/css/dist/style.css';
|
|
2
|
+
@import '@docsearch/css/dist/sidepanel.css';
|
|
3
|
+
|
|
4
|
+
/* stylelint-disable selector-class-pattern */
|
|
5
|
+
|
|
6
|
+
/* Hide docsearch container by default, shown when JS initializes */
|
|
7
|
+
#press-docsearch,
|
|
8
|
+
#press-docsearch-sidepanel,
|
|
9
|
+
.DocSearch-SidepanelButton {
|
|
10
|
+
display: none;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/* Override DocSearch CSS variables with Press theme variables */
|
|
14
|
+
:root:root {
|
|
15
|
+
--docsearch-primary-color: var(--va-c-primary);
|
|
16
|
+
--docsearch-text-color: var(--va-c-text-1);
|
|
17
|
+
--docsearch-muted-color: var(--va-c-text-2);
|
|
18
|
+
--docsearch-container-background: rgb(150 150 150 / 0.7);
|
|
19
|
+
--docsearch-background-color: var(--va-c-bg-soft);
|
|
20
|
+
--docsearch-modal-background: var(--va-c-bg-soft);
|
|
21
|
+
--docsearch-modal-shadow: var(--va-shadow-3);
|
|
22
|
+
--docsearch-searchbox-background: var(--va-c-bg-alt);
|
|
23
|
+
--docsearch-searchbox-focus-background: transparent;
|
|
24
|
+
--docsearch-hit-background: var(--va-c-bg);
|
|
25
|
+
--docsearch-hit-color: var(--va-c-text-1);
|
|
26
|
+
--docsearch-hit-active-color: var(--va-c-white);
|
|
27
|
+
--docsearch-hit-shadow: none;
|
|
28
|
+
--docsearch-footer-background: var(--va-c-bg-alt);
|
|
29
|
+
--docsearch-footer-shadow: 0 -1px 0 0 var(--va-c-divider);
|
|
30
|
+
--docsearch-key-background: var(--va-c-code-bg, var(--va-c-bg-soft));
|
|
31
|
+
--docsearch-key-color: var(--va-c-text-2);
|
|
32
|
+
--docsearch-highlight-color: var(--docsearch-primary-color);
|
|
33
|
+
--docsearch-logo-color: #5468ff;
|
|
34
|
+
--docsearch-icon-color: var(--va-c-text-2);
|
|
35
|
+
--docsearch-secondary-text-color: var(--va-c-text-2);
|
|
36
|
+
--docsearch-focus-color: var(--va-c-primary);
|
|
37
|
+
--docsearch-subtle-color: var(--va-c-divider);
|
|
38
|
+
--docsearch-dropdown-menu-background: var(--va-c-bg);
|
|
39
|
+
--docsearch-soft-primary-color: var(--va-c-primary-soft, rgba(0, 61, 255, 0.1));
|
|
40
|
+
--docsearch-soft-muted-color: var(--va-c-bg-soft);
|
|
41
|
+
--docsearch-sidepanel-accent-muted: var(--va-c-text-3, var(--va-c-text-2));
|
|
42
|
+
--docsearch-sidepanel-text-base: var(--va-c-text-1);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
:root.dark {
|
|
46
|
+
--docsearch-container-background: rgb(0 0 0 / 0.64);
|
|
47
|
+
--docsearch-modal-shadow: none;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/* DocSearch component tweaks */
|
|
51
|
+
.DocSearch-Commands-Key {
|
|
52
|
+
padding: 4px;
|
|
53
|
+
border: 1px solid var(--docsearch-subtle-color);
|
|
54
|
+
border-radius: 4px;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.DocSearch-Hit a:focus-visible {
|
|
58
|
+
outline: 2px solid var(--docsearch-focus-color);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.DocSearch-Logo [class^='cls-'] {
|
|
62
|
+
fill: currentColor;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.DocSearch-Menu-content {
|
|
66
|
+
margin-top: -4px;
|
|
67
|
+
padding: 6px;
|
|
68
|
+
border: 1px solid var(--va-c-divider);
|
|
69
|
+
border-radius: 6px;
|
|
70
|
+
box-shadow: var(--va-shadow-2, 0 4px 12px rgba(0, 0, 0, 0.06));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.DocSearch-Menu-item {
|
|
74
|
+
border-radius: 4px;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.DocSearch-SearchBar + .DocSearch-Footer {
|
|
78
|
+
border-top-color: transparent;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.DocSearch-Title {
|
|
82
|
+
font-size: revert;
|
|
83
|
+
line-height: revert;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/* Sidepanel tweaks */
|
|
87
|
+
.DocSearch-Sidepanel-Prompt--form {
|
|
88
|
+
border-color: var(--docsearch-subtle-color);
|
|
89
|
+
transition: border-color 0.2s;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.DocSearch-Sidepanel-Prompt--submit {
|
|
93
|
+
background-color: var(--docsearch-soft-primary-color);
|
|
94
|
+
color: var(--docsearch-primary-color);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.DocSearch-Sidepanel-Prompt--submit:hover {
|
|
98
|
+
background-color: var(--va-c-primary);
|
|
99
|
+
color: var(--va-c-white);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.DocSearch-Sidepanel-Prompt--submit:disabled,
|
|
103
|
+
.DocSearch-Sidepanel-Prompt--submit[aria-disabled='true'] {
|
|
104
|
+
background-color: var(--docsearch-soft-muted-color);
|
|
105
|
+
color: var(--docsearch-muted-color);
|
|
106
|
+
}
|
package/valaxy.config.ts
CHANGED