valaxy-theme-press 0.15.5 → 0.15.7

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 CHANGED
@@ -1,11 +1,11 @@
1
1
  # valaxy-theme-press
2
2
 
3
- This is a theme for valaxy docs.
3
+ This is a theme for [valaxy docs](https://valaxy.site/).
4
4
 
5
5
  Inspired by [vitepress](https://vitepress.dev).
6
6
 
7
7
  我开发此主题以编写 Valaxy 的初期文档,同时以便发现 valaxy 编写主题中的痛点。
8
- <!-- 它增加了 VitePress 一些所没有的功能,而随着 VitePress 的完善,该主题将不再被维护,文档也将在未来迁移至 VitePress。 -->
8
+ 它增加了 VitePress 此前默认所没有的一些功能,KaTeX、文章分类、单页 CSS i18n + Vue i18n、Vue Router、Pinia 状态管理,组件自动注册等。
9
9
 
10
10
  - [预览](https://press.valaxy.site)
11
11
 
@@ -0,0 +1 @@
1
+ export const targetPadding = -40
package/client/index.ts CHANGED
@@ -1 +1,3 @@
1
+ export * from './config'
2
+
1
3
  export * from '../composables'
@@ -44,6 +44,7 @@ const { loaded, load, metaKey } = useAddonAlgolia()
44
44
  </template>
45
45
 
46
46
  <style>
47
+ /* stylelint-disable selector-class-pattern */
47
48
  .DocSearch-Button {
48
49
  display: flex;
49
50
  justify-content: center;
@@ -69,7 +70,7 @@ const { loaded, load, metaKey } = useAddonAlgolia()
69
70
  outline: none !important;
70
71
  }
71
72
 
72
- @media (min-width: 768px) {
73
+ @media (width >= 768px) {
73
74
  .DocSearch-Button {
74
75
  justify-content: flex-start;
75
76
  border: 1px solid transparent;
@@ -96,7 +97,7 @@ const { loaded, load, metaKey } = useAddonAlgolia()
96
97
  width: 16px;
97
98
  height: 16px;
98
99
  color: var(--va-c-text-1);
99
- fill: currentColor;
100
+ fill: currentcolor;
100
101
  transition: color 0.5s;
101
102
  }
102
103
 
@@ -104,7 +105,7 @@ const { loaded, load, metaKey } = useAddonAlgolia()
104
105
  color: var(--va-c-text-1);
105
106
  }
106
107
 
107
- @media (min-width: 768px) {
108
+ @media (width >= 768px) {
108
109
  .DocSearch-Button .DocSearch-Search-Icon {
109
110
  top: 1px;
110
111
  margin-right: 8px;
@@ -128,20 +129,20 @@ const { loaded, load, metaKey } = useAddonAlgolia()
128
129
  color: var(--va-c-text-1);
129
130
  }
130
131
 
131
- @media (min-width: 768px) {
132
+ @media (width >= 768px) {
132
133
  .DocSearch-Button .DocSearch-Button-Placeholder {
133
134
  display: inline-block;
134
135
  }
135
136
  }
136
137
 
137
138
  .DocSearch-Button .DocSearch-Button-Keys {
138
- /*rtl:ignore*/
139
+ /* rtl:ignore */
139
140
  direction: ltr;
140
141
  display: none;
141
142
  min-width: auto;
142
143
  }
143
144
 
144
- @media (min-width: 768px) {
145
+ @media (width >= 768px) {
145
146
  .DocSearch-Button .DocSearch-Button-Keys {
146
147
  display: flex;
147
148
  align-items: center;
@@ -150,13 +151,15 @@ const { loaded, load, metaKey } = useAddonAlgolia()
150
151
 
151
152
  .DocSearch-Button .DocSearch-Button-Key {
152
153
  display: block;
153
- margin: 2px 0 0 0;
154
+ margin: 2px 0 0;
154
155
  border: 1px solid var(--va-c-divider);
155
- /*rtl:begin:ignore*/
156
+
157
+ /* rtl:begin:ignore */
156
158
  border-right: none;
157
159
  border-radius: 4px 0 0 4px;
158
160
  padding-left: 6px;
159
- /*rtl:end:ignore*/
161
+
162
+ /* rtl:end:ignore */
160
163
  min-width: 0;
161
164
  width: auto;
162
165
  height: 22px;
@@ -167,13 +170,14 @@ const { loaded, load, metaKey } = useAddonAlgolia()
167
170
  }
168
171
 
169
172
  .DocSearch-Button .DocSearch-Button-Key + .DocSearch-Button-Key {
170
- /*rtl:begin:ignore*/
173
+ /* rtl:begin:ignore */
171
174
  border-right: 1px solid var(--va-c-divider);
172
175
  border-left: none;
173
176
  border-radius: 0 4px 4px 0;
174
177
  padding-left: 2px;
175
178
  padding-right: 6px;
176
- /*rtl:end:ignore*/
179
+
180
+ /* rtl:end:ignore */
177
181
  }
178
182
 
179
183
  .DocSearch-Button .DocSearch-Button-Key:first-child {
@@ -182,7 +186,8 @@ const { loaded, load, metaKey } = useAddonAlgolia()
182
186
  color: transparent;
183
187
  }
184
188
 
185
- .DocSearch-Button .DocSearch-Button-Key:first-child:after {
189
+ .DocSearch-Button .DocSearch-Button-Key:first-child::after {
190
+ /* stylelint-disable-next-line value-keyword-case */
186
191
  content: v-bind(metaKey);
187
192
  font-size: 12px;
188
193
  letter-spacing: normal;
@@ -47,9 +47,7 @@ const app = useAppStore()
47
47
  right: 0;
48
48
  z-index: var(--pr-z-aside);
49
49
  width: var(--va-aside-width);
50
-
51
50
  transform: translateX(100%);
52
-
53
51
  transition: box-shadow var(--va-transition-duration), opacity 0.25s,
54
52
  transform var(--va-transition-duration) cubic-bezier(0.19, 1, 0.22, 1);
55
53
 
@@ -13,10 +13,7 @@ defineProps<{
13
13
  <style scoped lang="scss">
14
14
  .press-backdrop {
15
15
  position: fixed;
16
- top: 0;
17
- right: 0;
18
- bottom: 0;
19
- left: 0;
16
+ inset: 0;
20
17
  z-index: var(--pr-z-backdrop);
21
18
  background: rgba(0, 0, 0, .6);
22
19
  transition: opacity 0.5s;
@@ -31,7 +28,7 @@ defineProps<{
31
28
  }
32
29
  }
33
30
 
34
- @media (min-width: 1280px) {
31
+ @media (width >= 1280px) {
35
32
  .press-backdrop {
36
33
  display: none;
37
34
  }
@@ -43,10 +43,11 @@ function getCategoryByName(name: string) {
43
43
  .category-list {
44
44
  &:first-child {
45
45
  .category-list-item {
46
- border-top: 0px;
46
+ border-top: 0;
47
47
  }
48
48
  }
49
49
  }
50
+
50
51
  .post-list-item {
51
52
  a {
52
53
  color: var(--va-c-text-light);
@@ -28,6 +28,7 @@ const { t } = useI18n()
28
28
  </template>
29
29
 
30
30
  <style scoped>
31
+ /* stylelint-disable selector-class-pattern */
31
32
  .press-lastUpdated {
32
33
  line-height: 24px;
33
34
  font-size: 14px;
@@ -35,7 +36,7 @@ const { t } = useI18n()
35
36
  color: var(--va-c-text-light);
36
37
  }
37
38
 
38
- @media (min-width: 640px) {
39
+ @media (width >= 640px) {
39
40
  .press-lastUpdated {
40
41
  line-height: 32px;
41
42
  font-size: 14px;
@@ -28,7 +28,7 @@ const { hasSidebar } = useSidebar()
28
28
  }
29
29
  }
30
30
 
31
- @media (min-width: 768px) {
31
+ @media (width >= 768px) {
32
32
  .pr-footer {
33
33
  padding: 32px;
34
34
  }
@@ -1,5 +1,9 @@
1
1
  <template>
2
- <div class="press-home" style="--va-code-mobile-margin-x: 0">
2
+ <div
3
+ class="press-home" style="
4
+
5
+ --va-code-mobile-margin-x: 0"
6
+ >
3
7
  <slot name="home-hero-before" />
4
8
  <PressHomeHero />
5
9
  <slot name="home-hero-after" />
@@ -95,7 +95,7 @@ const { headers } = useOutline()
95
95
  margin-right: 8px;
96
96
  width: 16px;
97
97
  height: 16px;
98
- fill: currentColor;
98
+ fill: currentcolor;
99
99
  }
100
100
 
101
101
  .top-link {
@@ -73,6 +73,7 @@ const { t } = useI18n()
73
73
  </template>
74
74
 
75
75
  <style scoped>
76
+ /* stylelint-disable selector-class-pattern */
76
77
  .VPLocalNavOutlineDropdown {
77
78
  padding: 12px 20px 11px;
78
79
  }
@@ -102,7 +103,7 @@ const { t } = useI18n()
102
103
  margin-left: 2px;
103
104
  width: 14px;
104
105
  height: 14px;
105
- fill: currentColor;
106
+ fill: currentcolor;
106
107
  }
107
108
 
108
109
  :deep(.outline-link) {
@@ -32,13 +32,8 @@ const classes = computed(() => ({
32
32
  z-index: var(--pr-z-nav);
33
33
  }
34
34
 
35
- .pr-Nav.fill-bg {
36
- background-color: var(--pr-nav-bg-color);
37
- }
38
-
39
35
  @include screen('md') {
40
36
  .press-nav {
41
- -webkit-backdrop-filter: saturate(50%) blur(8px);
42
37
  backdrop-filter: saturate(50%) blur(8px);
43
38
  }
44
39
  }
@@ -70,7 +70,6 @@ const themeConfig = useThemeConfig()
70
70
  .pr-navbar.has-sidebar .content {
71
71
  margin-right: -32px;
72
72
  padding-right: 32px;
73
- -webkit-backdrop-filter: saturate(50%) blur(8px);
74
73
  backdrop-filter: saturate(50%) blur(8px);
75
74
  }
76
75
 
@@ -27,6 +27,8 @@ defineEmits<{
27
27
  </template>
28
28
 
29
29
  <style scoped>
30
+ /* stylelint-disable selector-class-pattern */
31
+ /* stylelint-disable declaration-block-single-line-max-declarations */
30
32
  .pr-NavBarHamburger {
31
33
  display: flex;
32
34
  justify-content: center;
@@ -35,7 +37,7 @@ defineEmits<{
35
37
  height: var(--pr-nav-height);
36
38
  }
37
39
 
38
- @media (min-width: 768px) {
40
+ @media (width >= 768px) {
39
41
  .pr-NavBarHamburger {
40
42
  display: none;
41
43
  }
@@ -20,19 +20,20 @@ const PressAlgoliaSearch = isAlgolia.value
20
20
  </template>
21
21
 
22
22
  <style>
23
+ /* stylelint-disable selector-class-pattern */
23
24
  .VPNavBarSearch {
24
25
  display: flex;
25
26
  align-items: center;
26
27
  }
27
28
 
28
- @media (min-width: 768px) {
29
+ @media (width >= 768px) {
29
30
  .VPNavBarSearch {
30
31
  flex-grow: 1;
31
32
  padding-left: 24px;
32
33
  }
33
34
  }
34
35
 
35
- @media (min-width: 960px) {
36
+ @media (width >= 960px) {
36
37
  .VPNavBarSearch {
37
38
  padding-left: 32px;
38
39
  }
@@ -17,7 +17,7 @@ const themeConfig = useThemeConfig()
17
17
  display: none;
18
18
  }
19
19
 
20
- @media (min-width: 1280px) {
20
+ @media (width >= 1280px) {
21
21
  .pr-nav-bar-social-links {
22
22
  display: flex;
23
23
  align-items: center;
@@ -61,18 +61,17 @@ const { t } = useI18n()
61
61
  position: absolute;
62
62
  top: 20px;
63
63
  left: 50%;
64
-
65
64
  min-width: 128px;
66
65
  opacity: 0;
67
66
  visibility: hidden;
68
67
  transition: opacity 0.25s, visibility 0.25s, transform 0.25s;
69
68
  transform: translateX(-50%) translateY(calc(var(--pr-nav-height) / 2));
70
-
71
69
  border-radius: 12px;
72
70
  padding: 12px;
73
71
  border: 1px solid rgba(60, 60, 60, 0.12);
74
- background-color: #ffffff;
72
+ background-color: #fff;
75
73
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1), 0 2px 6px rgba(0, 0, 0, 0.08);
74
+
76
75
  .dark &{
77
76
  background-color: #242424;
78
77
  }
@@ -37,6 +37,7 @@ const { t } = useI18n()
37
37
  color: var(--va-c-brand);
38
38
  }
39
39
  }
40
+
40
41
  .active{
41
42
  color: var(--va-c-brand);
42
43
  }
@@ -31,14 +31,14 @@ const { lockBodyScroll, unlockBodyScroll } = useBodyScrollLock(screen)
31
31
  </template>
32
32
 
33
33
  <style scoped>
34
+ /* stylelint-disable selector-class-pattern */
34
35
  .pr-NavScreen {
35
36
  position: fixed;
36
- top: calc(var(--pr-nav-height) + var(--pr-layout-top-height, 0px) + 1px);
37
- /*rtl:ignore*/
38
- right: 0;
39
- bottom: 0;
40
- /*rtl:ignore*/
41
- left: 0;
37
+ inset: calc(var(--pr-nav-height) + var(--pr-layout-top-height, 0px) + 1px) 0 0 0;
38
+
39
+ /* rtl:ignore */
40
+
41
+ /* rtl:ignore */
42
42
  padding: 0 32px;
43
43
  width: 100%;
44
44
  background-color: var(--pr-nav-screen-bg-color);
@@ -67,7 +67,7 @@ const { lockBodyScroll, unlockBodyScroll } = useBodyScrollLock(screen)
67
67
  transform: translateY(-8px);
68
68
  }
69
69
 
70
- @media (min-width: 768px) {
70
+ @media (width >= 768px) {
71
71
  .pr-NavScreen {
72
72
  display: none;
73
73
  }
@@ -80,7 +80,7 @@ function toggle() {
80
80
  }
81
81
 
82
82
  .pr-nav-screen-menu-group.open .button-icon {
83
- /*rtl:ignore*/
83
+ /* rtl:ignore */
84
84
  transform: rotate(45deg);
85
85
  }
86
86
 
@@ -109,7 +109,7 @@ function toggle() {
109
109
  }
110
110
 
111
111
  .group:first-child {
112
- padding-top: 0px;
112
+ padding-top: 0;
113
113
  }
114
114
 
115
115
  .group + .group,
@@ -45,7 +45,6 @@ const { hasSidebar } = useSidebar()
45
45
 
46
46
  .press-sidebar {
47
47
  position: fixed;
48
- top: 0;
49
48
  bottom: 0;
50
49
  left: 0;
51
50
  padding: 1rem;
@@ -35,6 +35,6 @@ defineProps<{
35
35
  .pr-social-link > :deep(svg) {
36
36
  width: 20px;
37
37
  height: 20px;
38
- fill: currentColor;
38
+ fill: currentcolor;
39
39
  }
40
40
  </style>
@@ -37,7 +37,7 @@ import { isDark, toggleDark } from 'valaxy'
37
37
  width: 18px;
38
38
  height: 18px;
39
39
  border-radius: 50%;
40
- background-color: #ffffff;
40
+ background-color: #fff;
41
41
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
42
42
  transition: background-color 0.25s, transform 0.25s;
43
43
  }
@@ -1,9 +1,11 @@
1
1
  <script lang="ts" setup>
2
2
  import type { PageData, Post } from 'valaxy'
3
- import { useFrontmatter, useLayout, useSidebar, useSiteConfig } from 'valaxy'
4
- import { computed } from 'vue'
3
+ import { scrollTo, useFrontmatter, useLayout, useSidebar, useSiteConfig } from 'valaxy'
4
+ import { computed, nextTick } from 'vue'
5
5
  import { useI18n } from 'vue-i18n'
6
+ import { useRoute } from 'vue-router'
6
7
  import { getLocaleTitle } from '../utils'
8
+ import { targetPadding } from '../client'
7
9
 
8
10
  defineProps<{
9
11
  frontmatter: Post
@@ -19,6 +21,19 @@ const layout = useLayout()
19
21
 
20
22
  const { locale } = useI18n()
21
23
  const localeTitle = computed(() => getLocaleTitle(locale.value, frontmatter.value))
24
+
25
+ const route = useRoute()
26
+
27
+ nextTick(() => {
28
+ if (route.hash) {
29
+ setTimeout(() => {
30
+ scrollTo(document.body, route.hash, {
31
+ smooth: true,
32
+ targetPadding,
33
+ })
34
+ }, 0)
35
+ }
36
+ })
22
37
  </script>
23
38
 
24
39
  <template>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "valaxy-theme-press",
3
- "version": "0.15.5",
3
+ "version": "0.15.7",
4
4
  "description": "Docs Theme for Valaxy",
5
5
  "author": {
6
6
  "email": "me@yunyoujun.cn",
@@ -23,6 +23,6 @@
23
23
  "@docsearch/js": "^3.5.2"
24
24
  },
25
25
  "devDependencies": {
26
- "valaxy": "0.15.5"
26
+ "valaxy": "0.15.7"
27
27
  }
28
28
  }
package/setup/main.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { defineAppSetup } from 'valaxy'
1
+ import { defineAppSetup, scrollTo } from 'valaxy'
2
2
  import { nextTick } from 'vue'
3
3
 
4
4
  import 'vitepress/dist/client/theme-default/styles/vars.css'
@@ -12,6 +12,8 @@ import 'vitepress/dist/client/theme-default/styles/components/custom-block.css'
12
12
 
13
13
  // import 'vitepress/dist/client/theme-default/styles/components/vp-sponsor.css'
14
14
 
15
+ import { targetPadding } from '../client'
16
+
15
17
  export default defineAppSetup((ctx) => {
16
18
  const { router, isClient } = ctx
17
19
  if (!isClient)
@@ -46,7 +48,9 @@ export default defineAppSetup((ctx) => {
46
48
  // still emit the event so we can listen to it in themes
47
49
  window.dispatchEvent(new Event('hashchange'))
48
50
  // use smooth scroll when clicking on header anchor links
49
- scrollTo(link, hash, link.classList.contains('header-anchor'))
51
+ scrollTo(link, hash, {
52
+ smooth: link.classList.contains('header-anchor'),
53
+ })
50
54
  }
51
55
  }
52
56
  }
@@ -64,39 +68,10 @@ export default defineAppSetup((ctx) => {
64
68
  return
65
69
 
66
70
  nextTick(() => {
67
- scrollTo(document.body, to.hash, true)
71
+ scrollTo(document.body, to.hash, {
72
+ smooth: true,
73
+ targetPadding,
74
+ })
68
75
  })
69
76
  })
70
77
  })
71
-
72
- function scrollTo(el: HTMLElement, hash: string, smooth = false) {
73
- let target: Element | null = null
74
- try {
75
- target = el.classList.contains('header-anchor')
76
- ? el
77
- : ((decodeURIComponent(hash) && document.querySelector(decodeURIComponent(hash))) || null)
78
- }
79
- catch (e) {
80
- console.warn(e)
81
- }
82
-
83
- if (target) {
84
- const targetPadding = -64
85
- const targetTop
86
- = window.scrollY
87
- + (target as HTMLElement).getBoundingClientRect().top
88
- + targetPadding
89
-
90
- // only smooth scroll if distance is smaller than screen height.
91
- if (!smooth || Math.abs(targetTop - window.scrollY) > window.innerHeight) {
92
- window.scrollTo(0, targetTop)
93
- }
94
- else {
95
- window.scrollTo({
96
- left: 0,
97
- top: targetTop,
98
- behavior: 'smooth',
99
- })
100
- }
101
- }
102
- }
@@ -1,20 +1,14 @@
1
1
  :root {
2
2
  --pr-c-indigo-lighter: #c9def1;
3
- }
4
-
5
- :root {
6
3
  --pr-c-bg: var(--va-c-bg);
7
-
8
4
  --pr-c-text-code: #374562;
9
5
  --pr-c-text-1: #213547;
10
- --pr-c-text-2: rgba(60, 60, 60, .7);
6
+ --pr-c-text-2: rgba(60, 60, 60, 0.7);
11
7
 
12
8
  // aside
13
9
  --pr-aside-text-1: var(--pr-c-text-1);
14
10
  --pr-aside-text-2: rgba(60, 60, 60, 0.702);
15
-
16
11
  --pr-aside-divider: rgba(60, 60, 60, 0.122);
17
-
18
12
  --pr-c-divider-light: rgba(60, 60, 60, 0.12);
19
13
 
20
14
  // nav
@@ -39,7 +33,7 @@
39
33
  .dark {
40
34
  --pr-c-text-code: var(--pr-c-indigo-lighter);
41
35
  --pr-c-text-1: #ffffffde;
42
- --pr-c-text-2: rgba(235, 235, 235, .6);
36
+ --pr-c-text-2: rgba(235, 235, 235, 0.6);
43
37
 
44
38
  // aside
45
39
  --pr-aside-text-2: #ebebeb99;
@@ -1,5 +1,6 @@
1
1
  .gradient-text {
2
2
  background-clip: text;
3
+ /* stylelint-disable-next-line property-no-vendor-prefix */
3
4
  -webkit-background-clip: text;
4
5
  -webkit-text-fill-color: transparent;
5
6
  }
@@ -17,15 +18,12 @@
17
18
 
18
19
  .press-icon-btn {
19
20
  cursor: pointer;
20
-
21
21
  display: inline-flex;
22
22
  align-items: center;
23
23
  justify-content: center;
24
-
25
24
  border: none;
26
25
  width: 3rem;
27
26
  height: 3rem;
28
-
29
27
  border-radius: 50%;
30
28
 
31
29
  div {
@@ -40,7 +40,7 @@
40
40
  }
41
41
 
42
42
  ul {
43
- margin-top: 0em;
43
+ margin-top: 0;
44
44
  margin-bottom: 0.25em;
45
45
  }
46
46
  }