valaxy 0.25.2 → 0.25.4

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.
@@ -0,0 +1,33 @@
1
+ <script setup lang="ts">
2
+ import type { Component } from 'vue'
3
+ import { compile, defineAsyncComponent, onMounted, shallowRef } from 'vue'
4
+
5
+ const props = withDefaults(
6
+ defineProps<{
7
+ templateStr: string
8
+ data?: Record<string, any>
9
+ }>(),
10
+ {
11
+ data: () => ({}),
12
+ },
13
+ )
14
+
15
+ const dynamicComponent = shallowRef<Component | null>(null)
16
+
17
+ async function createComponent() {
18
+ const render = compile(props.templateStr)
19
+ const componentDefinition = {
20
+ render,
21
+ data: () => props.data,
22
+ }
23
+ dynamicComponent.value = defineAsyncComponent(() => Promise.resolve(componentDefinition))
24
+ }
25
+
26
+ onMounted(() => {
27
+ createComponent()
28
+ })
29
+ </script>
30
+
31
+ <template>
32
+ <component :is="dynamicComponent" />
33
+ </template>
@@ -1,16 +1,13 @@
1
1
  <script setup lang="ts">
2
- // import { useValaxyI18n } from 'valaxy'
3
2
  import { useI18n } from 'vue-i18n'
4
3
 
5
4
  defineProps<{
6
- title: string
5
+ content: string
7
6
  }>()
8
7
 
9
8
  const { t } = useI18n()
10
9
  </script>
11
10
 
12
11
  <template>
13
- <span>
14
- {{ t(title) }}
15
- </span>
12
+ {{ t(content) }}
16
13
  </template>
@@ -26,7 +26,7 @@ export function useValaxyApp() {
26
26
  // seo
27
27
  // todo: get first image url from markdown
28
28
  const siteUrl = computed(() => fm.value.url || siteConfig.value.url)
29
- const description = computed(() => $tO(fm.value.excerpt) || $tO(fm.value.description) || $tO(siteConfig.value.description))
29
+ const description = computed(() => $tO(fm.value.excerpt) || $tO(fm.value.description) || $t(siteConfig.value.description))
30
30
 
31
31
  useSeoMeta({
32
32
  description,
@@ -47,7 +47,7 @@ export function useValaxyApp() {
47
47
  definePerson({
48
48
  name: $t(siteConfig.value.author.name),
49
49
  url: siteUrl.value,
50
- image: siteConfig.value.author.avatar,
50
+ image: $t(siteConfig.value.author.avatar),
51
51
  sameAs: siteConfig.value.social.map(s => s.link),
52
52
  }),
53
53
  defineWebSite({
@@ -16,7 +16,7 @@ export function useValaxyHead() {
16
16
  title: $title,
17
17
  titleTemplate: (title) => {
18
18
  const siteTitle = $t(siteConfig.value.title)
19
- return fm.value.titleTemplate || (title ? `${title} - ${siteTitle}` : siteTitle)
19
+ return $tO(fm.value.titleTemplate) || (title ? `${title} - ${siteTitle}` : siteTitle)
20
20
  },
21
21
  link: [
22
22
  {
@@ -29,7 +29,7 @@ export function useValaxyHead() {
29
29
  computed(() => {
30
30
  return {
31
31
  name: 'description',
32
- content: fm.value.description || siteConfig.value.description,
32
+ content: $tO(fm.value.description) || $t(siteConfig.value.description),
33
33
  }
34
34
  }),
35
35
  {
package/client/main.ts CHANGED
@@ -1,4 +1,3 @@
1
- import type { ViteSSGContext } from 'vite-ssg'
2
1
  import { DataLoaderPlugin } from 'unplugin-vue-router/data-loaders'
3
2
  import { dataSymbol, initValaxyConfig, valaxyConfigSymbol } from 'valaxy'
4
3
  import { setupLayouts } from 'virtual:generated-layouts'
@@ -9,10 +8,8 @@ import { routes } from 'vue-router/auto-routes'
9
8
  import App from './App.vue'
10
9
 
11
10
  import { initData } from './app/data'
12
- import AppLink from './components/AppLink.vue'
13
11
 
14
12
  import setupMain from './setup/main'
15
-
16
13
  import { setupValaxyDevTools } from './utils/dev'
17
14
  /**
18
15
  * user styles
@@ -23,14 +20,6 @@ import 'uno.css'
23
20
 
24
21
  const valaxyConfig = initValaxyConfig()
25
22
 
26
- /**
27
- * register global components
28
- * @param ctx
29
- */
30
- export function registerComponents(ctx: ViteSSGContext) {
31
- ctx.app.component('AppLink', AppLink)
32
- }
33
-
34
23
  const { redirectRoutes, useVueRouter } = valaxyConfig.value.runtimeConfig.redirects
35
24
  if (useVueRouter)
36
25
  routes.push(...redirectRoutes)
@@ -84,7 +73,6 @@ export const createApp = ViteSSG(
84
73
 
85
74
  app.provide(valaxyConfigSymbol, valaxyConfig)
86
75
 
87
- registerComponents(ctx)
88
76
  setupMain(ctx, valaxyConfig)
89
77
  },
90
78
  )
@@ -0,0 +1,13 @@
1
+ import type { ViteSSGContext } from 'vite-ssg'
2
+
3
+ import AppLink from '../components/AppLink.vue'
4
+ import ValaxyTranslate from '../components/builtin/ValaxyTranslate.vue'
5
+
6
+ /**
7
+ * register global components
8
+ * @param ctx
9
+ */
10
+ export function registerGlobalComponents(ctx: ViteSSGContext) {
11
+ ctx.app.component('AppLink', AppLink)
12
+ ctx.app.component('VT', ValaxyTranslate)
13
+ }
@@ -9,6 +9,7 @@ import type { ViteSSGContext } from 'vite-ssg'
9
9
  import type { ComputedRef } from 'vue'
10
10
 
11
11
  import { consola } from 'consola'
12
+ import { registerGlobalComponents } from '../modules/components'
12
13
  import { install as installFloatingVue } from '../modules/floating-vue'
13
14
  import { install as installNprogress } from '../modules/nprogress'
14
15
  import { install as installPinia } from '../modules/pinia'
@@ -20,6 +21,7 @@ export default function setupMain(ctx: ViteSSGContext, config: ComputedRef<Valax
20
21
  // eslint-disable-next-line unused-imports/no-unused-vars
21
22
  const injection_arg = ctx
22
23
 
24
+ registerGlobalComponents(ctx)
23
25
  installValaxy(ctx, config)
24
26
  installUnhead(ctx)
25
27
  installPinia(ctx)
@@ -23,14 +23,14 @@ html:not(.dark) .vp-code-dark {
23
23
  }
24
24
  }
25
25
 
26
- @media (width >= 640px) {
26
+ @media (width >=640px) {
27
27
  .markdown-body div[class*="language-"] {
28
28
  border-radius: 6px;
29
29
  margin: 16px 0;
30
30
  }
31
31
  }
32
32
 
33
- @media (width <= 639.9px) {
33
+ @media (width <=639.9px) {
34
34
  .markdown-body li div[class*="language-"] {
35
35
  border-radius: 6px 0 0 6px;
36
36
  }
@@ -101,7 +101,7 @@ html:not(.dark) .vp-code-dark {
101
101
  }
102
102
 
103
103
  // copy
104
- [class*='language-'] > button.copy {
104
+ [class*='language-']>button.copy {
105
105
  /* rtl:ignore */
106
106
  direction: ltr;
107
107
  position: absolute;
@@ -126,28 +126,28 @@ html:not(.dark) .vp-code-dark {
126
126
  background-color 0.25s,
127
127
  opacity 0.25s;
128
128
  }
129
-
130
- [class*='language-']:hover > button.copy,
131
- [class*='language-'] > button.copy:focus {
129
+
130
+ [class*='language-']:hover>button.copy,
131
+ [class*='language-']>button.copy:focus {
132
132
  opacity: 1;
133
133
  }
134
-
135
- [class*='language-'] > button.copy:hover,
136
- [class*='language-'] > button.copy.copied {
134
+
135
+ [class*='language-']>button.copy:hover,
136
+ [class*='language-']>button.copy.copied {
137
137
  border-color: var(--va-code-copy-code-hover-border-color);
138
138
  background-color: var(--va-code-copy-code-hover-bg);
139
139
  }
140
-
141
- [class*='language-'] > button.copy.copied,
142
- [class*='language-'] > button.copy:hover.copied {
140
+
141
+ [class*='language-']>button.copy.copied,
142
+ [class*='language-']>button.copy:hover.copied {
143
143
  /* rtl:ignore */
144
144
  border-radius: 0 4px 4px 0;
145
145
  background-color: var(--va-code-copy-code-hover-bg);
146
146
  background-image: var(--va-icon-copied);
147
147
  }
148
-
149
- [class*='language-'] > button.copy.copied::before,
150
- [class*='language-'] > button.copy:hover.copied::before {
148
+
149
+ [class*='language-']>button.copy.copied::before,
150
+ [class*='language-']>button.copy:hover.copied::before {
151
151
  position: relative;
152
152
  top: -1px;
153
153
 
@@ -173,7 +173,7 @@ html:not(.dark) .vp-code-dark {
173
173
  content: var(--va-code-copy-copied-text-content);
174
174
  }
175
175
 
176
- [class*='language-'] > span.lang {
176
+ [class*='language-']>span.lang {
177
177
  position: absolute;
178
178
  top: 2px;
179
179
 
@@ -187,9 +187,9 @@ html:not(.dark) .vp-code-dark {
187
187
  color 0.4s,
188
188
  opacity 0.4s;
189
189
  }
190
-
191
- [class*='language-']:hover > button.copy + span.lang,
192
- [class*='language-'] > button.copy:focus + span.lang {
190
+
191
+ [class*='language-']:hover>button.copy+span.lang,
192
+ [class*='language-']>button.copy:focus+span.lang {
193
193
  opacity: 0;
194
194
  }
195
195
 
@@ -227,7 +227,7 @@ html:not(.dark) .vp-code-dark {
227
227
  }
228
228
 
229
229
  // collapse
230
- [class*='language-'] > button.collapse {
230
+ [class*='language-']>button.collapse {
231
231
  display: none;
232
232
  position: absolute;
233
233
  z-index: 10;
@@ -237,7 +237,7 @@ html:not(.dark) .vp-code-dark {
237
237
  height: 24px;
238
238
  opacity: 1;
239
239
  cursor: pointer;
240
- background-image: linear-gradient(-180deg,rgb(0 0 0 / 0) 0%,var(--va-c-bg-dark) 100%);
240
+ background-image: linear-gradient(-180deg, rgb(0 0 0 / 0) 0%, var(--va-c-bg-dark) 100%);
241
241
 
242
242
  &::before {
243
243
  display: block;
@@ -251,7 +251,7 @@ html:not(.dark) .vp-code-dark {
251
251
  }
252
252
  }
253
253
 
254
- [class*='language-'].folded > button.collapse {
254
+ [class*='language-'].folded>button.collapse {
255
255
  display: block;
256
256
  }
257
257
  }
@@ -1,6 +1,7 @@
1
1
  @use "sass:map";
2
2
 
3
3
  .markdown-body {
4
+
4
5
  h1,
5
6
  h2,
6
7
  h3,
@@ -94,11 +95,10 @@
94
95
  }
95
96
 
96
97
 
97
- @media (width >= 768px) {
98
+ @media (width >=768px) {
98
99
  .markdown-body h1 {
99
100
  letter-spacing: -0.02em;
100
101
  line-height: 40px;
101
102
  font-size: 32px;
102
103
  }
103
104
  }
104
-
@@ -4,7 +4,7 @@ import yargs from "yargs";
4
4
  import { hideBin } from "yargs/helpers";
5
5
 
6
6
  // package.json
7
- var version = "0.25.2";
7
+ var version = "0.25.4";
8
8
 
9
9
  // node/modules/fuse.ts
10
10
  import path4 from "path";
@@ -2075,7 +2075,7 @@ function createContainer(key, block = {}, md3) {
2075
2075
  let iconTag = "";
2076
2076
  if (block.icon)
2077
2077
  iconTag = `<i class="icon ${block.icon}" ${block.color ? `style="color: ${block.color}"` : ""}></i>`;
2078
- const title = `<ValaxyContainerBlockTitle title="blocks.${key}" />`;
2078
+ const title = `<VT content="blocks.${key}" />`;
2079
2079
  const titleClass = `custom-block-title${info ? "" : " custom-block-title-default"}`;
2080
2080
  if (classes === "details")
2081
2081
  return `<details ${attrs}><summary>${title}</summary>
@@ -2531,6 +2531,24 @@ function snippetPlugin(md3, srcDir) {
2531
2531
  md3.block.ruler.before("fence", "snippet", parser);
2532
2532
  }
2533
2533
 
2534
+ // node/plugins/markdown/plugins/markdown-it/titleCollector.ts
2535
+ var globalTitleCollector = /* @__PURE__ */ new Set();
2536
+ function getGlobalTitleCollector() {
2537
+ return globalTitleCollector;
2538
+ }
2539
+ function titleCollectorPlugin(md3) {
2540
+ const fence = md3.renderer.rules.fence;
2541
+ md3.renderer.rules.fence = (...args) => {
2542
+ const [tokens, idx] = args;
2543
+ const token = tokens[idx];
2544
+ const title = extractTitle(token.info);
2545
+ if (title && title !== extractTitle("")) {
2546
+ globalTitleCollector.add(title);
2547
+ }
2548
+ return fence(...args);
2549
+ };
2550
+ }
2551
+
2534
2552
  // node/plugins/markdown/setup.ts
2535
2553
  var defaultCodeTheme = { light: "github-light", dark: "github-dark" };
2536
2554
  async function setupMarkdownPlugins(md3, options, base = "/") {
@@ -2539,7 +2557,7 @@ async function setupMarkdownPlugins(md3, options, base = "/") {
2539
2557
  const siteConfig = options?.config.siteConfig || {};
2540
2558
  if (mdOptions.preConfig)
2541
2559
  mdOptions.preConfig(md3);
2542
- md3.use(highlightLinePlugin).use(preWrapperPlugin, { theme, siteConfig }).use(snippetPlugin, options?.userRoot).use(containerPlugin, {
2560
+ md3.use(highlightLinePlugin).use(titleCollectorPlugin).use(preWrapperPlugin, { theme, siteConfig }).use(snippetPlugin, options?.userRoot).use(containerPlugin, {
2543
2561
  languages: siteConfig.languages,
2544
2562
  ...mdOptions?.container,
2545
2563
  blocks: {
@@ -4052,6 +4070,7 @@ async function ViteValaxyPlugins(valaxyApp, serverOptions = {}) {
4052
4070
  console.log();
4053
4071
  }
4054
4072
  }
4073
+ const codeBlockTitles = getGlobalTitleCollector();
4055
4074
  const builtinCustomIcon = {
4056
4075
  nodejs: "vscode-icons:file-type-node",
4057
4076
  playwright: "vscode-icons:file-type-playwright",
@@ -4067,7 +4086,8 @@ async function ViteValaxyPlugins(valaxyApp, serverOptions = {}) {
4067
4086
  defaultLabels: [
4068
4087
  ...valaxyConfig.groupIcons?.defaultLabels || [],
4069
4088
  ...Object.keys(builtinCustomIcon),
4070
- ...Object.keys(valaxyConfig.groupIcons?.customIcon || {})
4089
+ ...Object.keys(valaxyConfig.groupIcons?.customIcon || {}),
4090
+ ...Array.from(codeBlockTitles)
4071
4091
  ]
4072
4092
  })
4073
4093
  );
@@ -3,7 +3,7 @@ import {
3
3
  registerDevCommand,
4
4
  run,
5
5
  startValaxyDev
6
- } from "../../chunk-FOH2JIW7.js";
6
+ } from "../../chunk-FQD2JPI3.js";
7
7
  export {
8
8
  cli,
9
9
  registerDevCommand,
@@ -50,7 +50,7 @@ import {
50
50
  startValaxyDev,
51
51
  toAtFS,
52
52
  transformObject
53
- } from "../chunk-FOH2JIW7.js";
53
+ } from "../chunk-FQD2JPI3.js";
54
54
  export {
55
55
  $t,
56
56
  ALL_ROUTE,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "valaxy",
3
3
  "type": "module",
4
- "version": "0.25.2",
4
+ "version": "0.25.4",
5
5
  "description": "📄 Vite & Vue powered static blog generator.",
6
6
  "author": {
7
7
  "email": "me@yunyoujun.cn",
@@ -58,7 +58,7 @@
58
58
  "@clack/prompts": "^0.11.0",
59
59
  "@iconify-json/ri": "^1.2.5",
60
60
  "@intlify/unplugin-vue-i18n": "^6.0.8",
61
- "@shikijs/transformers": "^3.7.0",
61
+ "@shikijs/transformers": "^3.8.0",
62
62
  "@types/katex": "^0.16.7",
63
63
  "@unhead/addons": "^2.0.12",
64
64
  "@unhead/schema-org": "^2.0.12",
@@ -112,7 +112,7 @@
112
112
  "qrcode": "^1.5.4",
113
113
  "resolve-global": "^2.0.0",
114
114
  "sass": "^1.89.2",
115
- "shiki": "^3.7.0",
115
+ "shiki": "^3.8.0",
116
116
  "star-markdown-css": "^0.5.3",
117
117
  "table": "^6.9.0",
118
118
  "unhead": "^2.0.12",
@@ -132,8 +132,8 @@
132
132
  "vue-i18n": "^11.1.9",
133
133
  "vue-router": "^4.5.1",
134
134
  "yargs": "^18.0.0",
135
- "@valaxyjs/devtools": "0.25.2",
136
- "@valaxyjs/utils": "0.25.2"
135
+ "@valaxyjs/devtools": "0.25.4",
136
+ "@valaxyjs/utils": "0.25.4"
137
137
  },
138
138
  "devDependencies": {
139
139
  "@mdit-vue/plugin-component": "^2.1.4",