valaxy-theme-yun 0.18.10 → 0.19.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/App.vue +13 -0
- package/components/YunBg.vue +3 -2
- package/components/YunConfig.vue +10 -3
- package/components/YunMdTimeWarning.vue +7 -8
- package/components/YunPostMeta.vue +3 -2
- package/components/YunSidebar.vue +9 -6
- package/layouts/home.vue +4 -3
- package/node/config.ts +4 -0
- package/package.json +4 -4
- package/setup/main.ts +14 -2
- package/stores/app.ts +5 -1
- package/stores/index.ts +1 -0
- package/types/index.d.ts +3 -1
package/App.vue
CHANGED
@@ -4,6 +4,8 @@ import { useAppStore, useSiteConfig } from 'valaxy'
|
|
4
4
|
import { onMounted } from 'vue'
|
5
5
|
import { useThemeConfig } from './composables'
|
6
6
|
|
7
|
+
const appStore = useAppStore()
|
8
|
+
|
7
9
|
useHead({
|
8
10
|
link: [
|
9
11
|
{
|
@@ -11,6 +13,17 @@ useHead({
|
|
11
13
|
href: 'https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@900&display=swap',
|
12
14
|
},
|
13
15
|
],
|
16
|
+
|
17
|
+
meta: [
|
18
|
+
{
|
19
|
+
name: 'theme-color',
|
20
|
+
content: appStore.themeColor,
|
21
|
+
},
|
22
|
+
{
|
23
|
+
name: 'msapplication-TileColor',
|
24
|
+
content: appStore.themeColor,
|
25
|
+
},
|
26
|
+
],
|
14
27
|
})
|
15
28
|
|
16
29
|
const siteConfig = useSiteConfig()
|
package/components/YunBg.vue
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
<script lang="ts" setup>
|
2
2
|
import { computed, watch } from 'vue'
|
3
3
|
import { useCssVar } from '@vueuse/core'
|
4
|
-
import {
|
4
|
+
import { useAppStore } from 'valaxy'
|
5
5
|
import { useThemeConfig } from '../composables'
|
6
6
|
|
7
|
+
const appStore = useAppStore()
|
7
8
|
const themeConfig = useThemeConfig()
|
8
9
|
|
9
10
|
if (typeof themeConfig.value.bg_image.url !== 'undefined') {
|
@@ -12,7 +13,7 @@ if (typeof themeConfig.value.bg_image.url !== 'undefined') {
|
|
12
13
|
bgImgOpacity.value = themeConfig.value.bg_image.opacity.toString() || '1'
|
13
14
|
|
14
15
|
const bgImgUrl = computed(() => {
|
15
|
-
return isDark
|
16
|
+
return appStore.isDark
|
16
17
|
? themeConfig.value.bg_image.dark
|
17
18
|
: themeConfig.value.bg_image.url
|
18
19
|
})
|
package/components/YunConfig.vue
CHANGED
@@ -1,18 +1,25 @@
|
|
1
1
|
<script lang="ts" setup>
|
2
2
|
import { useI18n } from 'vue-i18n'
|
3
3
|
import { computed } from 'vue'
|
4
|
-
import {
|
4
|
+
import { useAppStore } from 'valaxy'
|
5
5
|
|
6
|
+
const appStore = useAppStore()
|
6
7
|
const { t } = useI18n()
|
7
8
|
|
8
9
|
const themeTitle = computed(() => {
|
9
|
-
return isDark
|
10
|
+
return appStore.isDark ? t('button.toggle_light') : t('button.toggle_dark')
|
11
|
+
})
|
12
|
+
|
13
|
+
const styles = computed(() => {
|
14
|
+
return {
|
15
|
+
color: appStore.isDark ? '' : '#f1cb64',
|
16
|
+
}
|
10
17
|
})
|
11
18
|
</script>
|
12
19
|
|
13
20
|
<template>
|
14
21
|
<div>
|
15
|
-
<button class="yun-icon-btn" :title="themeTitle" :style="
|
22
|
+
<button class="yun-icon-btn" :title="themeTitle" :style="styles" @click="appStore.toggleDarkWithTransition">
|
16
23
|
<div i="ri-sun-line dark:ri-moon-line" />
|
17
24
|
</button>
|
18
25
|
|
@@ -1,21 +1,20 @@
|
|
1
1
|
<script lang="ts" setup>
|
2
|
-
import { computed } from 'vue'
|
2
|
+
import { computed, ref, watch } from 'vue'
|
3
3
|
import { useFrontmatter } from 'valaxy'
|
4
4
|
import { useI18n } from 'vue-i18n'
|
5
5
|
|
6
6
|
import { differenceInMilliseconds, formatDistanceToNow } from 'date-fns'
|
7
7
|
|
8
8
|
const fm = useFrontmatter()
|
9
|
-
const { t } = useI18n()
|
9
|
+
const { t, locale } = useI18n()
|
10
10
|
|
11
11
|
const updated = computed(() => fm.value.updated || fm.value.date || new Date())
|
12
|
-
const ago =
|
12
|
+
const ago = ref('')
|
13
|
+
|
14
|
+
watch(locale, () => {
|
13
15
|
const fromNow = formatDistanceToNow(updated.value, { addSuffix: true })
|
14
|
-
|
15
|
-
|
16
|
-
else
|
17
|
-
return fromNow
|
18
|
-
})
|
16
|
+
ago.value = /^\d/.test(fromNow) ? ` ${fromNow}` : fromNow
|
17
|
+
}, { immediate: true })
|
19
18
|
|
20
19
|
/**
|
21
20
|
* when the post is updated more than 180 days ago, show a warning
|
@@ -1,5 +1,6 @@
|
|
1
1
|
<script lang="ts" setup>
|
2
2
|
import type { Post } from 'valaxy'
|
3
|
+
import { formatISO } from 'date-fns'
|
3
4
|
import { formatDate, useSiteConfig } from 'valaxy'
|
4
5
|
import { useI18n } from 'vue-i18n'
|
5
6
|
|
@@ -30,14 +31,14 @@ const siteConfig = useSiteConfig()
|
|
30
31
|
flex="~ col" justify="center" items="center" text="sm" py="1"
|
31
32
|
>
|
32
33
|
<div v-if="frontmatter.date" class="post-time flex items-center">
|
33
|
-
<span class="posted-time inline-flex-center" :title="t('post.posted') + frontmatter.date">
|
34
|
+
<span class="posted-time inline-flex-center" :title="t('post.posted') + formatISO(frontmatter.date)">
|
34
35
|
<div class="inline-block" i-ri-calendar-line />
|
35
36
|
<time m="l-1">{{ formatDate(frontmatter.date) }}</time>
|
36
37
|
</span>
|
37
38
|
|
38
39
|
<span
|
39
40
|
v-if="frontmatter.updated && frontmatter.updated !== frontmatter.date"
|
40
|
-
class="edited-time inline-flex-center" :title="t('post.edited') + frontmatter.updated"
|
41
|
+
class="edited-time inline-flex-center" :title="t('post.edited') + formatISO(frontmatter.updated)"
|
41
42
|
>
|
42
43
|
<span m="x-2">-</span>
|
43
44
|
<div i-ri-calendar-2-line />
|
@@ -1,28 +1,31 @@
|
|
1
1
|
<script lang="ts" setup>
|
2
2
|
import { ref } from 'vue'
|
3
|
-
import {
|
3
|
+
import { useYunAppStore } from '../stores'
|
4
4
|
|
5
5
|
defineProps<{
|
6
6
|
showHamburger?: boolean
|
7
7
|
}>()
|
8
8
|
|
9
|
-
const
|
9
|
+
const yunApp = useYunAppStore()
|
10
10
|
const showOverview = ref(false)
|
11
11
|
</script>
|
12
12
|
|
13
13
|
<template>
|
14
|
-
<ValaxyOverlay class="md:hidden" :show="
|
14
|
+
<ValaxyOverlay class="md:hidden" :show="yunApp.leftSidebar.isOpen" @click="yunApp.leftSidebar.toggle()" />
|
15
15
|
|
16
16
|
<ValaxyHamburger
|
17
|
-
:active="
|
17
|
+
:active="yunApp.leftSidebar.isOpen"
|
18
18
|
class="menu-btn sidebar-toggle yun-icon-btn leading-4 fixed left-0.8rem top-0.6rem"
|
19
19
|
inline-flex cursor="pointer" z="$yun-z-menu-btn"
|
20
|
-
:class="showHamburger ? '' : 'md:hidden'" @click="
|
20
|
+
:class="showHamburger ? '' : 'md:hidden'" @click="yunApp.leftSidebar.toggle()"
|
21
21
|
/>
|
22
22
|
|
23
23
|
<aside
|
24
24
|
class="va-card transition sidebar fixed inset-y-0 left-0 overflow-y-auto"
|
25
|
-
:class="
|
25
|
+
:class="{
|
26
|
+
'open': yunApp.leftSidebar.isOpen,
|
27
|
+
'md:translate-x-0': !showHamburger,
|
28
|
+
}"
|
26
29
|
text="center" bg="$yun-sidebar-bg-color contain no-repeat" z="$yun-z-sidebar"
|
27
30
|
>
|
28
31
|
<div v-if="$slots.default" class="sidebar-nav" m="t-6">
|
package/layouts/home.vue
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
<script lang="ts" setup>
|
2
|
-
import {
|
2
|
+
import { useLayout } from 'valaxy'
|
3
3
|
import { computed } from 'vue'
|
4
4
|
import { useRoute } from 'vue-router'
|
5
5
|
import { useThemeConfig } from '../composables'
|
6
|
+
import { useYunAppStore } from '../stores'
|
6
7
|
|
7
|
-
const
|
8
|
+
const yunApp = useYunAppStore()
|
8
9
|
const isHome = useLayout('home')
|
9
10
|
const themeConfig = useThemeConfig()
|
10
11
|
|
@@ -20,7 +21,7 @@ const showNotice = computed(() => {
|
|
20
21
|
<template>
|
21
22
|
<main
|
22
23
|
class="yun-main flex-center"
|
23
|
-
:class="(isHome && !
|
24
|
+
:class="(isHome && !yunApp.leftSidebar.isOpen) ? 'pl-0' : 'md:pl-$va-sidebar-width'" flex="~ col" w="full"
|
24
25
|
>
|
25
26
|
<YunSidebar :show-hamburger="true" />
|
26
27
|
|
package/node/config.ts
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "valaxy-theme-yun",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.19.0",
|
4
4
|
"author": {
|
5
5
|
"email": "me@yunyoujun.cn",
|
6
6
|
"name": "YunYouJun",
|
@@ -20,12 +20,12 @@
|
|
20
20
|
"dependencies": {
|
21
21
|
"@explosions/fireworks": "^0.0.2",
|
22
22
|
"@iconify-json/ant-design": "^1.1.16",
|
23
|
-
"@iconify-json/simple-icons": "^1.1.
|
23
|
+
"@iconify-json/simple-icons": "^1.1.108",
|
24
24
|
"animejs": "^3.2.2"
|
25
25
|
},
|
26
26
|
"devDependencies": {
|
27
27
|
"@types/animejs": "^3.1.12",
|
28
|
-
"valaxy
|
29
|
-
"valaxy": "0.
|
28
|
+
"valaxy": "0.19.0",
|
29
|
+
"valaxy-addon-waline": "0.1.4"
|
30
30
|
}
|
31
31
|
}
|
package/setup/main.ts
CHANGED
@@ -1,5 +1,17 @@
|
|
1
|
-
import { defineAppSetup } from 'valaxy'
|
1
|
+
import { defineAppSetup, useAppStore } from 'valaxy'
|
2
|
+
import { nextTick } from 'vue'
|
3
|
+
import { useYunAppStore } from '../stores'
|
2
4
|
|
3
|
-
export default defineAppSetup((
|
5
|
+
export default defineAppSetup((ctx) => {
|
4
6
|
// can do for setup
|
7
|
+
|
8
|
+
const { router } = ctx
|
9
|
+
const appStore = useAppStore()
|
10
|
+
const yunAppStore = useYunAppStore()
|
11
|
+
router.afterEach(() => {
|
12
|
+
nextTick(() => {
|
13
|
+
if (appStore.isMobile)
|
14
|
+
yunAppStore.leftSidebar.close()
|
15
|
+
})
|
16
|
+
})
|
5
17
|
})
|
package/stores/app.ts
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
import { acceptHMRUpdate, defineStore } from 'pinia'
|
2
|
+
import { useDynamicLeftSidebar } from 'valaxy'
|
2
3
|
|
3
4
|
export const useYunAppStore = defineStore('yun-app', () => {
|
4
5
|
// global cache for yun
|
6
|
+
const leftSidebar = useDynamicLeftSidebar()
|
5
7
|
|
6
|
-
return {
|
8
|
+
return {
|
9
|
+
leftSidebar,
|
10
|
+
}
|
7
11
|
})
|
8
12
|
|
9
13
|
if (import.meta.hot)
|
package/stores/index.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export * from './app'
|
package/types/index.d.ts
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
import type { DefaultTheme } from 'valaxy/types'
|
2
|
+
|
1
3
|
export * from '../composables'
|
2
4
|
|
3
5
|
export namespace YunTheme {
|
@@ -48,7 +50,7 @@ export interface Page {
|
|
48
50
|
/**
|
49
51
|
* Theme Config
|
50
52
|
*/
|
51
|
-
export interface ThemeConfig {
|
53
|
+
export interface ThemeConfig extends DefaultTheme.Config {
|
52
54
|
/**
|
53
55
|
* toc title
|
54
56
|
* @default 'On this page'
|