valaxy 0.3.9 → 0.4.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.
@@ -1,6 +1,6 @@
1
1
  import * as vite from 'vite';
2
2
  import { InlineConfig } from 'vite';
3
- import { V as ValaxyConfig } from '../config-97204b79.js';
3
+ import { V as ValaxyConfig } from '../config-de04677b.js';
4
4
  import 'type-fest';
5
5
  import 'unocss/vite';
6
6
  import 'markdown-it';
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkAQBALXBFjs = require('../chunk-AQBALXBF.js');var _chunkQIXBXHEKjs = require('../chunk-QIXBXHEK.js');_chunkQIXBXHEKjs.i.call(void 0, );exports.createServer = _chunkAQBALXBFjs.g;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkHRARZPSAjs = require('../chunk-HRARZPSA.js');require('../chunk-V3BMKLEW.js');exports.createServer = _chunkHRARZPSAjs.g;
@@ -1 +1 @@
1
- import{g as r}from"../chunk-ZUG5LNG5.mjs";import{i as o}from"../chunk-T3K5KZOK.mjs";o();export{r as createServer};
1
+ import{g as o}from"../chunk-N6HD5SHF.mjs";import"../chunk-6LIOFBAA.mjs";export{o as createServer};
package/package.json CHANGED
@@ -1,44 +1,47 @@
1
1
  {
2
2
  "name": "valaxy",
3
- "version": "0.3.9",
3
+ "version": "0.4.0",
4
4
  "description": "📄 Vite & Vue powered static blog generator.",
5
- "keywords": [
6
- "vite",
7
- "vue",
8
- "blog"
9
- ],
10
- "license": "MIT",
11
5
  "author": {
12
6
  "email": "me@yunyoujun.cn",
13
7
  "name": "YunYouJun",
14
8
  "url": "https://www.yunyoujun.cn"
15
9
  },
10
+ "license": "MIT",
11
+ "homepage": "https://valaxy.yyj.moe",
16
12
  "repository": "https://github.com/YunYouJun/valaxy",
17
- "main": "dist/index.js",
18
- "types": "dist/index.d.ts",
13
+ "keywords": [
14
+ "vite",
15
+ "vue",
16
+ "blog"
17
+ ],
19
18
  "exports": {
20
19
  ".": "./src/index.ts",
21
20
  "./*": "./*"
22
21
  },
22
+ "main": "dist/index.js",
23
+ "types": "dist/index.d.ts",
23
24
  "bin": {
24
25
  "vala": "./bin/valaxy.js",
25
26
  "valaxy": "./bin/valaxy.js"
26
27
  },
27
- "homepage": "https://valaxy.yyj.moe",
28
+ "engines": {
29
+ "node": ">=14.0.0"
30
+ },
28
31
  "dependencies": {
29
32
  "@ctrl/tinycolor": "^3.4.1",
30
- "@iconify-json/carbon": "^1.1.4",
31
- "@iconify-json/ri": "^1.1.1",
33
+ "@iconify-json/carbon": "^1.1.5",
34
+ "@iconify-json/ri": "^1.1.2",
32
35
  "@intlify/vite-plugin-vue-i18n": "^3.4.0",
33
36
  "@vitejs/plugin-vue": "^2.3.3",
34
- "@vueuse/core": "^8.4.2",
37
+ "@vueuse/core": "^8.6.0",
35
38
  "@vueuse/head": "^0.7.6",
36
39
  "consola": "^2.15.3",
37
40
  "critters": "^0.0.16",
38
- "dayjs": "^1.11.2",
41
+ "dayjs": "^1.11.3",
39
42
  "escape-html": "^1.0.3",
40
43
  "feed": "^4.2.2",
41
- "katex": "^0.15.3",
44
+ "katex": "^0.16.0",
42
45
  "kolorist": "^1.5.1",
43
46
  "markdown-it-anchor": "^8.6.4",
44
47
  "markdown-it-attrs": "^4.1.4",
@@ -50,25 +53,24 @@
50
53
  "nprogress": "^0.2.0",
51
54
  "open": "^8.4.0",
52
55
  "pinia": "^2.0.14",
53
- "prism-theme-vars": "^0.2.2",
56
+ "prism-theme-vars": "^0.2.3",
54
57
  "prismjs": "^1.28.0",
55
- "sass": "^1.51.0",
58
+ "sass": "^1.52.2",
56
59
  "star-markdown-css": "^0.3.3",
57
60
  "unconfig": "^0.3.4",
58
- "unocss": "^0.33.4",
59
- "unplugin-vue-components": "^0.19.5",
60
- "vite": "^2.9.9",
61
+ "unocss": "^0.38.1",
62
+ "unplugin-vue-components": "^0.19.6",
63
+ "vite": "^2.9.10",
61
64
  "vite-plugin-inspect": "^0.5.0",
62
65
  "vite-plugin-md": "^0.13.1",
63
66
  "vite-plugin-pages": "^0.23.0",
64
- "vite-plugin-pwa": "^0.12.0",
65
67
  "vite-plugin-vue-layouts": "^0.6.0",
66
68
  "vite-ssg": "0.19.2",
67
69
  "vite-ssg-sitemap": "0.2.7",
68
- "vue": "^3.2.33",
70
+ "vue": "^3.2.37",
69
71
  "vue-i18n": "^9.1.10",
70
72
  "vue-router": "^4.0.15",
71
- "yargs": "^17.5.0"
73
+ "yargs": "^17.5.1"
72
74
  },
73
75
  "devDependencies": {
74
76
  "@types/katex": "^0.14.0",
@@ -78,18 +80,13 @@
78
80
  "debug": "^4.3.4",
79
81
  "diacritics": "^1.3.0",
80
82
  "https-localhost": "^4.7.1",
81
- "type-fest": "^2.12.2",
82
- "vue-tsc": "^0.34.13"
83
- },
84
- "engines": {
85
- "node": ">=14.0.0"
83
+ "type-fest": "^2.13.0"
86
84
  },
87
85
  "scripts": {
88
86
  "build": "rimraf dist && tsup --splitting",
89
87
  "dev": "tsup --watch --splitting",
90
88
  "lint": "eslint \"**/*.{vue,ts,js}\"",
91
89
  "preview": "vite preview",
92
- "preview-https": "serve dist",
93
- "typecheck": "vue-tsc --noEmit"
90
+ "preview-https": "serve dist"
94
91
  }
95
92
  }
@@ -1,17 +1,37 @@
1
1
  <script setup lang="ts">
2
+ import { computed } from 'vue'
3
+ import { useHead } from '@vueuse/head'
4
+ import { useCssVar } from '@vueuse/core'
5
+ import { isDark } from './composables'
6
+
2
7
  // https://github.com/vueuse/head
3
8
  // you can use this to manipulate the document head in any components,
4
9
  // they will be rendered correctly in the html results with vite-ssg
5
- import { useHead } from '@vueuse/head'
6
10
  import { useConfig } from './config'
7
11
 
8
12
  const config = useConfig()
9
13
  useHead({
10
14
  title: config.value.title,
15
+ link: [
16
+ {
17
+ rel: 'icon',
18
+ href: config.value.favicon,
19
+ type: config.value.favicon.endsWith('svg') ? 'image/svg+xml' : 'image/png',
20
+ },
21
+ ],
11
22
  meta: [
12
23
  { name: 'description', content: config.value.description },
24
+ {
25
+ name: 'theme-color',
26
+ content: computed(() => isDark.value ? '#00aba9' : '#ffffff'),
27
+ },
13
28
  ],
14
29
  })
30
+
31
+ const bgImg = useCssVar('--yun-bg-img')
32
+ const bgImgUrl = computed(() => config.value.themeConfig.bg_image.url)
33
+ if (bgImgUrl.value)
34
+ bgImg.value = config.value.themeConfig.bg_image.url
15
35
  </script>
16
36
 
17
37
  <template>
@@ -0,0 +1,51 @@
1
+ <script lang="ts" setup>
2
+ import { computed } from 'vue'
3
+ import { useThemeConfig } from 'valaxy'
4
+ import { useCssVar } from '@vueuse/core'
5
+ import { isDark } from '~/composables'
6
+
7
+ const themeConfig = useThemeConfig()
8
+
9
+ const bgImgOpacity = useCssVar('--va-bg-img-opacity')
10
+ if (themeConfig.value.bg_image.opacity)
11
+ bgImgOpacity.value = themeConfig.value.bg_image.opacity.toString() || '1'
12
+
13
+ const styles = computed(() => {
14
+ return {
15
+ backgroundImage: `url('${isDark.value
16
+ ? themeConfig.value.bg_image.dark
17
+ : themeConfig.value.bg_image.url
18
+ }')`,
19
+ }
20
+ })
21
+ </script>
22
+
23
+ <template>
24
+ <div class="va-bg" :style="styles" />
25
+ </template>
26
+
27
+ <style lang="scss">
28
+ .va-bg {
29
+ position: fixed;
30
+ width: 100%;
31
+ height: 100%;
32
+ z-index: -1;
33
+ background-image: var(--va-bg-image);
34
+ background-size: cover;
35
+ background-position: center;
36
+ background-repeat: no-repeat;
37
+ animation-name: bgFadeIn;
38
+ animation-duration: 2s;
39
+ opacity: var(--va-bg-img-opacity, 1);
40
+ }
41
+
42
+ @keyframes bgFadeIn {
43
+ from {
44
+ opacity: 0;
45
+ }
46
+
47
+ to {
48
+ opacity: var(--va-bg-img-opacity, 1);
49
+ }
50
+ }
51
+ </style>
@@ -26,7 +26,6 @@ export function useTwikoo(options: {} = {}) {
26
26
 
27
27
  // 直接使用 CDN
28
28
  useScriptTag('//cdn.jsdelivr.net/npm/twikoo@1.5.1/dist/twikoo.all.min.js', () => {
29
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
30
29
  initTwikoo(options)
31
30
  })
32
31
  }
@@ -42,14 +42,16 @@ export function useActiveSidebarLinks(container: Ref<HTMLElement>, marker: Ref<H
42
42
  : container.value.querySelector(`.va-toc a[href="${hash}"]`) as HTMLAnchorElement)
43
43
 
44
44
  // marker animation
45
- if (activeLink) {
46
- activeLink.classList.add('active')
47
- marker.value.style.opacity = '1'
48
- marker.value.style.top = `${activeLink.offsetTop + 2}px`
49
- }
50
- else {
51
- marker.value.style.opacity = '0'
52
- marker.value.style.top = '54px'
45
+ if (marker.value) {
46
+ if (activeLink) {
47
+ activeLink.classList.add('active')
48
+ marker.value.style.opacity = '1'
49
+ marker.value.style.top = `${activeLink.offsetTop + 2}px`
50
+ }
51
+ else {
52
+ marker.value.style.opacity = '0'
53
+ marker.value.style.top = '54px'
54
+ }
53
55
  }
54
56
  }
55
57
 
@@ -4,13 +4,12 @@
4
4
  <head>
5
5
  <meta charset="UTF-8">
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
- <link rel="icon" href="/favicon.svg" type="image/svg+xml">
8
7
  <link rel="apple-touch-icon" href="/pwa-192x192.png">
9
8
  <link rel="mask-icon" href="/safari-pinned-tab.svg" color="#00aba9">
10
9
  <meta name="msapplication-TileColor" content="#00aba9">
11
10
  <meta name="theme-color" content="#ffffff">
12
11
  <script>
13
- (function() {
12
+ (function () {
14
13
  const prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches
15
14
  const setting = localStorage.getItem('vueuse-color-scheme') || 'auto'
16
15
  if (setting === 'dark' || (prefersDark && setting !== 'light'))
@@ -15,7 +15,11 @@ const routes = setupLayouts(__DEV__ ? generatedRoutes : generatedRoutes.filter(i
15
15
  // https://github.com/antfu/vite-ssg
16
16
  export const createApp = ViteSSG(
17
17
  App,
18
- { routes, base: import.meta.env.BASE_URL },
18
+ {
19
+ routes,
20
+ base: import.meta.env.BASE_URL,
21
+ scrollBehavior() { return { top: 0 } },
22
+ },
19
23
  (ctx) => {
20
24
  // install all modules under `modules/`
21
25
  Object.values(import.meta.globEager('./modules/*.ts')).forEach(i => i.install?.(ctx))
@@ -9,6 +9,7 @@ import { createI18n } from 'vue-i18n'
9
9
  // import messages from '@intlify/vite-plugin-vue-i18n/messages'
10
10
 
11
11
  import { useStorage } from '@vueuse/core'
12
+
12
13
  import { initConfig, valaxyConfigSymbol } from '../config'
13
14
 
14
15
  import type { UserModule } from '~/types'
@@ -38,7 +39,6 @@ function shouldHotReload(payload: any): boolean {
38
39
  return payloadPath === locationPath
39
40
  }
40
41
 
41
- // https://github.com/antfu/vite-plugin-pwa#automatic-reload-when-new-content-available
42
42
  export const install: UserModule = ({ app, router }) => {
43
43
  // inject valaxy config before modules
44
44
  const config = initConfig()
@@ -1,9 +1,13 @@
1
- @use 'sass:map';
1
+ @use "sass:map";
2
2
 
3
3
  .markdown-body {
4
4
  --prism-font-family: var(--va-font-mono);
5
5
 
6
6
  --smc-font-family: var(--va-font-sans);
7
+
8
+ video {
9
+ margin: auto;
10
+ }
7
11
  }
8
12
 
9
13
  // for anchor
@@ -10,29 +10,4 @@ body,
10
10
 
11
11
  body {
12
12
  background-color: var(--va-c-bg);
13
-
14
- &::before {
15
- content: '';
16
- position: fixed;
17
- width: 100%;
18
- height: 100%;
19
- z-index: -1;
20
- background-image: var(--yun-bg-image);
21
- background-size: cover;
22
- background-position: center;
23
- background-repeat: no-repeat;
24
- animation-name: bgFadeIn;
25
- animation-duration: 2s;
26
- opacity: 1;
27
- }
28
- }
29
-
30
- @keyframes bgFadeIn {
31
- from {
32
- opacity: 0;
33
- }
34
-
35
- to {
36
- opacity: 1;
37
- }
38
13
  }
@@ -174,7 +174,7 @@ export default function math_plugin(md: any, options: KatexOptions) {
174
174
  }
175
175
  catch (error) {
176
176
  if (options.throwOnError)
177
- // eslint-disable-next-line no-console
177
+
178
178
  console.warn(error)
179
179
  return latex
180
180
  }
@@ -191,7 +191,7 @@ export default function math_plugin(md: any, options: KatexOptions) {
191
191
  }
192
192
  catch (error) {
193
193
  if (options.throwOnError)
194
- // eslint-disable-next-line no-console
194
+
195
195
  console.warn(error)
196
196
  return latex
197
197
  }
@@ -35,6 +35,7 @@ export function createConfigPlugin(options: ResolvedValaxyOptions): Plugin {
35
35
  'dayjs',
36
36
  'nprogress',
37
37
  ],
38
+
38
39
  },
39
40
  }
40
41
  return mergeConfig(config, injection)
@@ -11,7 +11,7 @@ export type ViteMdOptions = Parameters<typeof Markdown>[0]
11
11
  export const excerpt_separator = '<!-- more -->'
12
12
 
13
13
  // https://github.com/antfu/vite-plugin-md
14
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
14
+
15
15
  export function createMarkdownPlugin(options: ResolvedValaxyOptions): Plugin[] {
16
16
  const mdOptions = options.config.markdownIt
17
17
 
@@ -10,7 +10,6 @@ import Vue from '@vitejs/plugin-vue'
10
10
  import Pages from 'vite-plugin-pages'
11
11
  import Layouts from 'vite-plugin-vue-layouts'
12
12
  import Components from 'unplugin-vue-components/vite'
13
- import { VitePWA } from 'vite-plugin-pwa'
14
13
  import VueI18n from '@intlify/vite-plugin-vue-i18n'
15
14
  import Inspect from 'vite-plugin-inspect'
16
15
 
@@ -173,35 +172,6 @@ export async function ViteValaxyPlugins(
173
172
 
174
173
  ...MarkdownPlugin,
175
174
 
176
- // https://github.com/antfu/vite-plugin-pwa
177
- VitePWA({
178
- registerType: 'autoUpdate',
179
- includeAssets: ['favicon.svg', 'safari-pinned-tab.svg'],
180
- manifest: {
181
- name: 'Theme Yun',
182
- short_name: 'Yun',
183
- theme_color: '#ffffff',
184
- icons: [
185
- {
186
- src: '/pwa-192x192.png',
187
- sizes: '192x192',
188
- type: 'image/png',
189
- },
190
- {
191
- src: '/pwa-512x512.png',
192
- sizes: '512x512',
193
- type: 'image/png',
194
- },
195
- {
196
- src: '/pwa-512x512.png',
197
- sizes: '512x512',
198
- type: 'image/png',
199
- purpose: 'any maskable',
200
- },
201
- ],
202
- },
203
- }),
204
-
205
175
  // https://github.com/intlify/bundle-tools/tree/main/packages/vite-plugin-vue-i18n
206
176
  VueI18n({
207
177
  runtimeOnly: true,
package/src/node/rss.ts CHANGED
@@ -101,7 +101,7 @@ export async function build(options: ResolvedValaxyOptions) {
101
101
  // write
102
102
  feedOptions.author = author
103
103
  feedOptions.image = config.author.avatar.startsWith('http') ? config.author.avatar : `${DOMAIN}${config.author.avatar}`
104
- feedOptions.favicon = `${DOMAIN}/${config.feed.favicon}`
104
+ feedOptions.favicon = `${DOMAIN}/${config.feed.favicon || config.favicon}`
105
105
 
106
106
  const feed = new Feed(feedOptions)
107
107
  posts.forEach(item => feed.addItem(item))
@@ -12,10 +12,12 @@ export async function createServer(
12
12
  // default editor vscode
13
13
  process.env.EDITOR = process.env.EDITOR || 'code'
14
14
 
15
- const server = await createViteServer(mergeConfig(
16
- viteConfig,
17
- await createViteConfig(options, serverOptions),
18
- ))
15
+ const server = await createViteServer(
16
+ mergeConfig(
17
+ viteConfig,
18
+ await createViteConfig(options, serverOptions),
19
+ ),
20
+ )
19
21
 
20
22
  return server
21
23
  }
@@ -71,6 +71,11 @@ export interface ValaxyConfig<T = ValaxyThemeConfig> {
71
71
  }
72
72
  }
73
73
 
74
+ /**
75
+ * icon for your website
76
+ */
77
+ favicon: string
78
+
74
79
  feed: {
75
80
  /**
76
81
  * name: feed -> feed.xml / feed.atom / feed.json
@@ -206,9 +211,10 @@ export const defaultValaxyConfig: ValaxyConfig = {
206
211
  message: 'All at sea.',
207
212
  },
208
213
  },
214
+ favicon: 'favicon.svg',
209
215
  feed: {
210
216
  name: '',
211
- favicon: 'favicon.png',
217
+ favicon: 'favicon.svg',
212
218
  },
213
219
  social: [],
214
220