valaxy 0.19.2 → 0.19.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.
package/client/App.vue CHANGED
@@ -1,101 +1,3 @@
1
- <script setup lang="ts">
2
- import { computed } from 'vue'
3
- import { useHead, useSeoMeta } from '@unhead/vue'
4
-
5
- // @ts-expect-error virtual module
6
- import ValaxyUserApp from '/@valaxyjs/UserAppVue'
7
-
8
- // @ts-expect-error virtual module
9
- import ValaxyThemeApp from '/@valaxyjs/ThemeAppVue'
10
- import pkg from 'valaxy/package.json'
11
- import { useI18n } from 'vue-i18n'
12
- import { definePerson, defineWebPage, defineWebSite, useSchemaOrg } from '@unhead/schema-org'
13
-
14
- // https://github.com/vueuse/head
15
- // you can use this to manipulate the document head in any components,
16
- // they will be rendered correctly in the html results with vite-ssg
17
- import { useSiteConfig } from './config'
18
- import ValaxyAddons from './components/ValaxyAddons.vue'
19
- import { useFrontmatter } from './composables'
20
-
21
- // <link rel="apple-touch-icon" href="/pwa-192x192.png">
22
- // <link rel="mask-icon" href="/safari-pinned-tab.svg" color="#00aba9">
23
-
24
- const siteConfig = useSiteConfig()
25
- // todo, allow user config
26
- const fm = useFrontmatter()
27
-
28
- const { locale } = useI18n()
29
-
30
- const title = computed(() => fm.value[`title_${locale.value}`] || fm.value.title)
31
- useHead({
32
- title,
33
- titleTemplate: computed(() => fm.value.titleTemplate || ((title: string) => title ? `${title} - ${siteConfig.value.title}` : siteConfig.value.title)),
34
- link: [
35
- {
36
- rel: 'icon',
37
- href: siteConfig.value.favicon,
38
- type: siteConfig.value.favicon?.endsWith('svg') ? 'image/svg+xml' : 'image/png',
39
- },
40
- ],
41
- meta: [
42
- { name: 'description', content: computed(() => siteConfig.value.description) },
43
- {
44
- name: 'generator',
45
- content: `Valaxy ${pkg.version}`,
46
- },
47
- ],
48
-
49
- templateParams: {
50
- schemaOrg: {
51
- host: siteConfig.value.url,
52
- },
53
- },
54
- })
55
-
56
- // seo
57
- // todo: get first image url from markdown
58
- const siteUrl = computed(() => fm.value.url || siteConfig.value.url)
59
- const description = computed(() => fm.value.excerpt || fm.value.description || siteConfig.value.description)
60
-
61
- useSeoMeta({
62
- description,
63
- ogDescription: description,
64
- ogLocale: computed(() => locale.value || fm.value.lang || siteConfig.value.lang || 'en'),
65
- ogLocaleAlternate: computed(() => siteConfig.value.languages.filter(l => l !== locale.value)),
66
- ogSiteName: computed(() => siteConfig.value.title),
67
- ogTitle: computed(() => fm.value.title || siteConfig.value.title),
68
- ogImage: computed(() => fm.value.ogImage || fm.value.cover || siteConfig.value.favicon),
69
- ogType: 'website',
70
- ogUrl: siteUrl,
71
- })
72
-
73
- // for SEO
74
- useSchemaOrg([
75
- // https://unhead.unjs.io/guide/guides/identity.html
76
- // Personal Website or Blog
77
- definePerson({
78
- name: siteConfig.value.author.name,
79
- url: siteUrl.value,
80
- image: siteConfig.value.author.avatar,
81
- sameAs: siteConfig.value.social.map(s => s.link),
82
- }),
83
- defineWebSite({
84
- name: title.value,
85
- datePublished: computed(() => fm.value.date),
86
- dateModified: computed(() => fm.value.updated),
87
- }),
88
- defineWebPage(),
89
- ])
90
- </script>
91
-
92
1
  <template>
93
- <ValaxyThemeApp />
94
- <ValaxyAddons />
95
- <ValaxyUserApp />
96
- <router-view v-slot="{ Component, route }">
97
- <transition name="app-transition">
98
- <component :is="Component" :key="route" />
99
- </transition>
100
- </router-view>
2
+ <ValaxyApp />
101
3
  </template>
@@ -0,0 +1,106 @@
1
+ <script setup lang="ts">
2
+ // TODO: add docs to override ValaxyApp
3
+ import { computed } from 'vue'
4
+ import { useHead, useSeoMeta } from '@unhead/vue'
5
+
6
+ // @ts-expect-error virtual module
7
+ import ValaxyUserApp from '/@valaxyjs/UserAppVue'
8
+ // @ts-expect-error virtual module
9
+ import ValaxyThemeApp from '/@valaxyjs/ThemeAppVue'
10
+
11
+ import pkg from 'valaxy/package.json'
12
+ import { useI18n } from 'vue-i18n'
13
+ import { definePerson, defineWebPage, defineWebSite, useSchemaOrg } from '@unhead/schema-org'
14
+
15
+ // https://github.com/vueuse/head
16
+ // you can use this to manipulate the document head in any components,
17
+ // they will be rendered correctly in the html results with vite-ssg
18
+ import { useSiteConfig } from '../config'
19
+ import { useFrontmatter } from '../composables'
20
+ import ValaxyAddons from './ValaxyAddons.vue'
21
+
22
+ // <link rel="apple-touch-icon" href="/pwa-192x192.png">
23
+ // <link rel="mask-icon" href="/safari-pinned-tab.svg" color="#00aba9">
24
+
25
+ const siteConfig = useSiteConfig()
26
+ // todo, allow user config
27
+ const fm = useFrontmatter()
28
+
29
+ const { locale } = useI18n()
30
+
31
+ const title = computed(() => fm.value[`title_${locale.value}`] || fm.value.title)
32
+ useHead({
33
+ title,
34
+ titleTemplate: computed(() => fm.value.titleTemplate || ((title: string) => title ? `${title} - ${siteConfig.value.title}` : siteConfig.value.title)),
35
+ link: [
36
+ {
37
+ rel: 'icon',
38
+ href: siteConfig.value.favicon,
39
+ type: siteConfig.value.favicon?.endsWith('svg') ? 'image/svg+xml' : 'image/png',
40
+ },
41
+ ],
42
+ meta: [
43
+ { name: 'description', content: computed(() => siteConfig.value.description) },
44
+ {
45
+ name: 'generator',
46
+ content: `Valaxy ${pkg.version}`,
47
+ },
48
+ ],
49
+
50
+ templateParams: {
51
+ schemaOrg: {
52
+ host: siteConfig.value.url,
53
+ },
54
+ },
55
+
56
+ script: [
57
+ {
58
+ id: 'check-mac-os',
59
+ innerHTML: `document.documentElement.classList.toggle('mac', /Mac|iPhone|iPod|iPad/i.test(navigator.platform))`,
60
+ async: true,
61
+ },
62
+ ],
63
+ })
64
+
65
+ // seo
66
+ // todo: get first image url from markdown
67
+ const siteUrl = computed(() => fm.value.url || siteConfig.value.url)
68
+ const description = computed(() => fm.value.excerpt || fm.value.description || siteConfig.value.description)
69
+
70
+ useSeoMeta({
71
+ description,
72
+ ogDescription: description,
73
+ ogLocale: computed(() => locale.value || fm.value.lang || siteConfig.value.lang || 'en'),
74
+ ogLocaleAlternate: computed(() => siteConfig.value.languages.filter(l => l !== locale.value)),
75
+ ogSiteName: computed(() => siteConfig.value.title),
76
+ ogTitle: computed(() => fm.value.title || siteConfig.value.title),
77
+ ogImage: computed(() => fm.value.ogImage || fm.value.cover || siteConfig.value.favicon),
78
+ ogType: 'website',
79
+ ogUrl: siteUrl,
80
+ })
81
+
82
+ // for SEO
83
+ useSchemaOrg([
84
+ // https://unhead.unjs.io/guide/guides/identity.html
85
+ // Personal Website or Blog
86
+ definePerson({
87
+ name: siteConfig.value.author.name,
88
+ url: siteUrl.value,
89
+ image: siteConfig.value.author.avatar,
90
+ sameAs: siteConfig.value.social.map(s => s.link),
91
+ }),
92
+ defineWebSite({
93
+ name: title.value,
94
+ datePublished: computed(() => fm.value.date),
95
+ dateModified: computed(() => fm.value.updated),
96
+ }),
97
+ defineWebPage(),
98
+ ])
99
+ </script>
100
+
101
+ <template>
102
+ <ValaxyThemeApp />
103
+ <ValaxyAddons />
104
+ <ValaxyUserApp />
105
+ <router-view />
106
+ </template>
@@ -74,7 +74,8 @@ onMounted(() => {
74
74
  <input
75
75
  v-model="password"
76
76
  w-full
77
- border pl-5 pr-11 py-3 rounded hover:shadow transition
77
+ border="~ solid dark:dark-100"
78
+ pl-5 pr-11 py-3 rounded-full hover:shadow transition
78
79
  type="password" placeholder="Enter password"
79
80
  :class="hasError && 'border-red'"
80
81
  @input="hasError = false"
@@ -1,74 +1,10 @@
1
1
  import { computed, shallowRef } from 'vue'
2
- import type { DefaultTheme, Header } from 'valaxy/types'
2
+ import type { DefaultTheme } from 'valaxy/types'
3
+ import type { MenuItem } from '@valaxyjs/utils'
4
+ import { getHeaders } from '@valaxyjs/utils'
3
5
  import { onContentUpdated } from '../../utils'
4
6
  import { useFrontmatter, useThemeConfig } from '../..'
5
7
 
6
- /**
7
- * @en
8
- * Menu item, the title menu parsed from the article.
9
- *
10
- * @zh
11
- * 菜单项,从文章中解析出的标题菜单。
12
- */
13
- export type MenuItem = Omit<Header, 'slug' | 'children'> & {
14
- children?: MenuItem[]
15
- }
16
-
17
- export function resolveHeaders(
18
- headers: MenuItem[],
19
- levelsRange: Exclude<DefaultTheme.Config['outline'], false> = [2, 4],
20
- ) {
21
- const levels: [number, number]
22
- = typeof levelsRange === 'number'
23
- ? [levelsRange, levelsRange]
24
- : levelsRange === 'deep'
25
- ? [2, 6]
26
- : levelsRange
27
-
28
- return groupHeaders(headers, levels)
29
- }
30
-
31
- function groupHeaders(headers: MenuItem[], levelsRange: [number, number]) {
32
- const result: MenuItem[] = []
33
-
34
- headers = headers.map(h => ({ ...h }))
35
- headers.forEach((h, index) => {
36
- if (h.level >= levelsRange[0] && h.level <= levelsRange[1]) {
37
- if (addToParent(index, headers, levelsRange))
38
- result.push(h)
39
- }
40
- })
41
-
42
- return result
43
- }
44
-
45
- function addToParent(
46
- currIndex: number,
47
- headers: MenuItem[],
48
- levelsRange: [number, number],
49
- ) {
50
- if (currIndex === 0)
51
- return true
52
-
53
- const currentHeader = headers[currIndex]
54
- for (let index = currIndex - 1; index >= 0; index--) {
55
- const header = headers[index]
56
-
57
- if (
58
- header.level < currentHeader.level
59
- && header.level >= levelsRange[0]
60
- && header.level <= levelsRange[1]
61
- ) {
62
- if (header.children == null)
63
- header.children = []
64
- header.children.push(currentHeader)
65
- return false
66
- }
67
- }
68
-
69
- return true
70
- }
71
-
72
8
  /**
73
9
  * export headers & handleClick to generate outline
74
10
  */
@@ -83,7 +19,11 @@ export function useOutline() {
83
19
  onContentUpdated(() => {
84
20
  if (pageOutline.value === false)
85
21
  return
86
- headers.value = getHeaders(pageOutline.value)
22
+ headers.value = getHeaders({
23
+ range: pageOutline.value,
24
+ selector: '.markdown-body',
25
+ filter: el => !!el.id && el.hasChildNodes(),
26
+ })
87
27
  })
88
28
 
89
29
  const handleClick = ({ target: el }: Event) => {
@@ -107,46 +47,3 @@ export function useOutline() {
107
47
  handleClick,
108
48
  }
109
49
  }
110
-
111
- /**
112
- * get headers from document directly
113
- */
114
- export function getHeaders(range: Exclude<DefaultTheme.Config['outline'], false>) {
115
- // when transition, the markdown-body will be two
116
- // the first is the old one, the last is the new one
117
- const markdownBodyElements = document.querySelectorAll('.markdown-body') as NodeListOf<HTMLElement>
118
- const markdownBody = markdownBodyElements[markdownBodyElements.length - 1]
119
- const headers = Array.from(markdownBody.querySelectorAll('.markdown-body :where(h1,h2,h3,h4,h5,h6)'))
120
- .filter(el => el.id && el.hasChildNodes())
121
- .map((el) => {
122
- const level = Number(el.tagName[1])
123
- return {
124
- title: serializeHeader(el),
125
- link: `#${el.id}`,
126
- level,
127
- // @ts-expect-error lang
128
- lang: el.lang,
129
- }
130
- })
131
-
132
- return resolveHeaders(headers, range)
133
- }
134
-
135
- function serializeHeader(h: Element): string {
136
- let ret = ''
137
- for (const node of Array.from(h.childNodes)) {
138
- if (node.nodeType === 1) {
139
- if (
140
- (node as Element).classList.contains('VABadge')
141
- || (node as Element).classList.contains('header-anchor')
142
- )
143
- continue
144
-
145
- ret += node.textContent
146
- }
147
- else if (node.nodeType === 3) {
148
- ret += node.textContent
149
- }
150
- }
151
- return ret.trim()
152
- }
package/client/index.ts CHANGED
@@ -9,3 +9,6 @@ export * from './utils'
9
9
  export * from './setups'
10
10
 
11
11
  export * from './types'
12
+
13
+ // child packages
14
+ export * from '@valaxyjs/utils'
package/client/main.ts CHANGED
@@ -19,6 +19,7 @@ import { setupLayouts } from 'virtual:generated-layouts'
19
19
  import { initValaxyConfig, valaxyConfigSymbol } from 'valaxy'
20
20
  import AppLink from './components/AppLink.vue'
21
21
 
22
+ // import App from '/@valaxyjs/App.vue'
22
23
  import App from './App.vue'
23
24
 
24
25
  import setupMain from './setup/main'
@@ -12,10 +12,6 @@
12
12
  }
13
13
 
14
14
  @return $name;
15
-
16
-
17
-
18
-
19
15
  }
20
16
 
21
17
  // get-css-var('button', 'text-color') => var(--el-button-text-color)
@@ -31,11 +31,14 @@ $colors: map.merge(
31
31
  $colors
32
32
  );
33
33
  $c-primary: map.get($colors, "primary") !default;
34
+
35
+ // https://sass-lang.com/documentation/modules/color/
36
+ // The lighten() function increases lightness by a fixed amount, which is often not the desired effect. To make a color a certain percentage lighter than it was before, use scale() instead.
34
37
  $colors: map.merge(
35
38
  (
36
- "primary-light": color.adjust($c-primary, $lightness: 10%),
37
- "primary-lighter": color.adjust($c-primary, $lightness: 20%),
38
- "primary-dark": color.adjust($c-primary, $lightness: -5%),
39
+ "primary-light": color.scale($c-primary, $lightness: 10%),
40
+ "primary-lighter": color.scale($c-primary, $lightness: 20%),
41
+ "primary-dark": color.scale($c-primary, $lightness: -5%),
39
42
  ),
40
43
  $colors
41
44
  );
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var m=Object.create;var o=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var d=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty;var l=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var p=(e,t)=>()=>(e&&(t=e(e=0)),t);var R=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var a=(e,t,n,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of u(t))!f.call(e,r)&&r!==n&&o(e,r,{get:()=>t[r],enumerable:!(c=i(t,r))||c.enumerable});return e};var h=(e,t,n)=>(n=e!=null?m(d(e)):{},a(t||!e||!e.__esModule?o(n,"default",{value:e,enumerable:!0}):n,e));var s,I,U= exports.e =p(()=>{"use strict";s=()=>typeof document>"u"?new URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href,I= exports.d =s()});exports.a = l; exports.b = R; exports.c = h; exports.d = I; exports.e = U;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var m=Object.create;var o=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var d=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty;var l=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var p=(e,t)=>()=>(e&&(t=e(e=0)),t);var R=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var a=(e,t,n,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of u(t))!f.call(e,r)&&r!==n&&o(e,r,{get:()=>t[r],enumerable:!(c=i(t,r))||c.enumerable});return e};var h=(e,t,n)=>(n=e!=null?m(d(e)):{},a(t||!e||!e.__esModule?o(n,"default",{value:e,enumerable:!0}):n,e));var s,I,U= exports.e =p(()=>{"use strict";s=()=>typeof document>"u"?new URL(`file:${__filename}`).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href,I= exports.d =s()});exports.a = l; exports.b = R; exports.c = h; exports.d = I; exports.e = U;