mirror of https://github.com/YunYouJun/valaxy
fix: seperate valaxy-addon-waline
This commit is contained in:
parent
54e50540ac
commit
7b334c7270
|
@ -17,7 +17,6 @@
|
|||
"valaxy-theme-yun": "link:../../packages/valaxy-theme-yun"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@waline/client": "^2.6.1",
|
||||
"nodemon": "^2.0.19",
|
||||
"vite-plugin-inspect": "^0.6.0",
|
||||
"vite-plugin-pwa": "^0.12.3"
|
||||
|
|
|
@ -330,6 +330,7 @@ When the page initializes or switches languages, add the corresponding language
|
|||
- 可在同一个 Markdown 文件中进行维护,书写便捷
|
||||
- 预加载与实时切换
|
||||
- URL 不变,便于管理与分享,且切换无需刷新页面
|
||||
- 渐进式翻译(只翻译部分内容并可共用示例内容等)
|
||||
|
||||
**劣势**:
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
"valaxy-theme-yun": "link:../packages/valaxy-theme-yun"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@waline/client": "^2.6.1",
|
||||
"nodemon": "^2.0.19"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ layout: album
|
|||
|
||||
## 自定义 index.html
|
||||
|
||||
新建 `template.html`,你可以在 `<head></head>` 与 `<body></body>` 全局地插入任意内容。
|
||||
新建 `index.html`,你可以在 `<head></head>` 与 `<body></body>` 全局地插入任意内容。
|
||||
|
||||
譬如:
|
||||
|
||||
|
|
|
@ -68,14 +68,14 @@ export interface ValaxyConfig {
|
|||
而由于评论系统各不相同,如 Hexo 等主题开发者们通常需在主题侧重复实现多款评论系统。
|
||||
这显然是繁琐的。
|
||||
|
||||
Valaxy 决定中心化地提供各类封装好的评论钩子函数。
|
||||
Valaxy 决定通过插件中心化地提供各类封装好的评论钩子函数。
|
||||
|
||||
譬如主题开发者,可以快速通过 `useWaline` 来实现 [Waline](https://waline.js.org/) 评论系统的集成。
|
||||
譬如主题开发者,可以从 `valaxy-addon-waline` 中导入 `useWaline` 来快速实现 [Waline](https://waline.js.org/) 评论系统的集成。
|
||||
而用户则可以使用相同的配置穿梭漫游于不同的主题之间。
|
||||
|
||||
```vue {2}
|
||||
<script lang="ts" setup>
|
||||
import { useConfig, useWaline } from 'valaxy'
|
||||
import { useConfig, useWaline } from 'valaxy-addon-waline'
|
||||
|
||||
// 读取用户配置
|
||||
const config = useConfig()
|
||||
|
|
|
@ -51,14 +51,15 @@
|
|||
"lint-staged": "^13.0.3",
|
||||
"prompts": "^2.4.2",
|
||||
"rimraf": "^3.0.2",
|
||||
"tsup": "^6.1.3",
|
||||
"tsup": "^6.2.0",
|
||||
"tsx": "^3.8.0",
|
||||
"typescript": "^4.7.4",
|
||||
"valaxy": "workspace:*",
|
||||
"valaxy-addon-waline": "workspace:*",
|
||||
"valaxy-theme-press": "workspace:*",
|
||||
"valaxy-theme-yun": "workspace:*",
|
||||
"vitest": "^0.18.1",
|
||||
"vue-tsc": "0.38.9",
|
||||
"vitest": "^0.19.1",
|
||||
"vue-tsc": "0.39.0",
|
||||
"zx": "^7.0.7"
|
||||
},
|
||||
"pnpm": {
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
export * from '../composables'
|
|
@ -4,7 +4,8 @@ import { useI18n } from 'vue-i18n'
|
|||
import { useRoute } from 'vue-router'
|
||||
|
||||
import type { WalineInitOptions, WalineInstance } from '@waline/client'
|
||||
import { cdnPrefix } from '../../utils'
|
||||
// waline css
|
||||
import '@waline/client/dist/waline.css'
|
||||
|
||||
/**
|
||||
* A Simple, Safe Comment System.
|
||||
|
@ -14,13 +15,10 @@ import { cdnPrefix } from '../../utils'
|
|||
* @param options
|
||||
* @returns
|
||||
*/
|
||||
export function useWaline(options: {} = {}, cdn = cdnPrefix) {
|
||||
export function useWaline(options: {} = {}, cdn = 'https://unpkg.com/') {
|
||||
if (!isClient)
|
||||
return
|
||||
|
||||
// import css
|
||||
import('@waline/client/dist/waline.css')
|
||||
|
||||
const route = useRoute()
|
||||
|
||||
const { locale } = useI18n()
|
|
@ -0,0 +1 @@
|
|||
export * from './client'
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"name": "valaxy-addon-waline",
|
||||
"version": "0.0.1",
|
||||
"description": "Waline Composition API for Valaxy",
|
||||
"keywords": [
|
||||
"valaxy",
|
||||
"addon",
|
||||
"waline"
|
||||
],
|
||||
"main": "client/index.ts",
|
||||
"types": "index.d.ts",
|
||||
"dependencies": {
|
||||
"@waline/client": "^2.6.2"
|
||||
}
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import { useConfig } from 'valaxy'
|
||||
// we need import on demand
|
||||
import { useWaline } from 'valaxy/client/composables/comments/waline'
|
||||
import { useWaline } from 'valaxy-addon-waline'
|
||||
|
||||
const config = useConfig()
|
||||
useWaline(config.value.comment.waline, config.value.cdn.prefix)
|
||||
|
|
|
@ -20,7 +20,8 @@
|
|||
"@docsearch/css": "^3.1.1",
|
||||
"@docsearch/js": "^3.1.1",
|
||||
"@iconify-json/ant-design": "^1.1.3",
|
||||
"@iconify-json/simple-icons": "^1.1.19"
|
||||
"@iconify-json/simple-icons": "^1.1.20",
|
||||
"valaxy-addon-waline": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"valaxy": "workspace:*"
|
||||
|
|
|
@ -30,6 +30,7 @@ function ThemeVitePlugin(options: ResolvedValaxyOptions<ThemeConfig>): Plugin {
|
|||
export default defineTheme<ThemeConfig>((options) => {
|
||||
return {
|
||||
themeConfig: defaultThemeConfig,
|
||||
addons: ['valaxy-addon-waline'],
|
||||
vite: {
|
||||
plugins: [ThemeVitePlugin(options)],
|
||||
},
|
||||
|
|
|
@ -1,3 +1 @@
|
|||
export * from './twikoo'
|
||||
// import on demand
|
||||
// export * from './waline'
|
||||
|
|
|
@ -1 +1 @@
|
|||
export const cdnPrefix = 'https://npm.elemecdn.com/'
|
||||
export const cdnPrefix = 'https://unpkg.com/'
|
||||
|
|
|
@ -27,7 +27,7 @@ export function defineConfig<ThemeConfig>(config: UserConfig<ThemeConfig>) {
|
|||
return config
|
||||
}
|
||||
|
||||
export type ValaxyConfigExtendKey = 'vite' | 'vue' | 'unocss' | 'unocssPresets' | 'markdown' | 'extendMd'
|
||||
export type ValaxyConfigExtendKey = 'vite' | 'vue' | 'unocss' | 'unocssPresets' | 'markdown' | 'extendMd' | 'addons'
|
||||
export type ValaxyPickConfig = Pick<ValaxyConfig, ValaxyConfigExtendKey>
|
||||
export type ValaxyTheme<ThemeConfig = DefaultThemeConfig> = ValaxyPickConfig & { themeConfig?: ThemeConfig }
|
||||
export function defineTheme<ThemeConfig = DefaultThemeConfig>(
|
||||
|
@ -107,7 +107,7 @@ export const defaultSiteConfig: SiteConfig = {
|
|||
},
|
||||
|
||||
cdn: {
|
||||
prefix: 'https://npm.elemecdn.com/',
|
||||
prefix: 'https://unpkg.com/',
|
||||
},
|
||||
|
||||
features: {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { dirname, join, resolve } from 'path'
|
||||
import type { InlineConfig, Plugin } from 'vite'
|
||||
import type { AliasOptions, InlineConfig, Plugin } from 'vite'
|
||||
import { mergeConfig, searchForWorkspaceRoot } from 'vite'
|
||||
import isInstalledGlobally from 'is-installed-globally'
|
||||
import fs from 'fs-extra'
|
||||
|
@ -21,15 +21,7 @@ export function createConfigPlugin(options: ResolvedValaxyOptions): Plugin {
|
|||
|
||||
define: getDefine(options),
|
||||
resolve: {
|
||||
alias: {
|
||||
'~/': `${toAtFS(options.userRoot)}/`,
|
||||
'valaxy/client/': `${toAtFS(options.clientRoot)}/`,
|
||||
'valaxy/package.json': toAtFS(resolve(options.clientRoot, '../package.json')),
|
||||
'valaxy': toAtFS(resolve(options.clientRoot, 'index.ts')),
|
||||
'@valaxyjs/client/': `${toAtFS(options.clientRoot)}/`,
|
||||
[`valaxy-theme-${options.theme}/`]: `${toAtFS(resolve(options.themeRoot))}/`,
|
||||
[`valaxy-theme-${options.theme}`]: `${toAtFS(resolve(options.themeRoot))}/client/index.ts`,
|
||||
},
|
||||
alias: getAlias(options),
|
||||
},
|
||||
|
||||
optimizeDeps: {
|
||||
|
@ -116,3 +108,21 @@ export function getDefine(options: ResolvedValaxyOptions): Record<string, any> {
|
|||
__ALGOLIA__: !!options.config?.search?.algolia?.enable,
|
||||
}
|
||||
}
|
||||
|
||||
export function getAlias(options: ResolvedValaxyOptions): AliasOptions {
|
||||
const alias = {
|
||||
'~/': `${toAtFS(options.userRoot)}/`,
|
||||
'valaxy/client/': `${toAtFS(options.clientRoot)}/`,
|
||||
'valaxy/package.json': toAtFS(resolve(options.clientRoot, '../package.json')),
|
||||
'valaxy': toAtFS(resolve(options.clientRoot, 'index.ts')),
|
||||
'@valaxyjs/client/': `${toAtFS(options.clientRoot)}/`,
|
||||
[`valaxy-theme-${options.theme}/`]: `${toAtFS(resolve(options.themeRoot))}/`,
|
||||
[`valaxy-theme-${options.theme}`]: `${toAtFS(resolve(options.themeRoot))}/client/index.ts`,
|
||||
}
|
||||
|
||||
options.addons.forEach((addon) => {
|
||||
alias[addon.name] = toAtFS(resolve(addon.root, 'client/index.ts'))
|
||||
})
|
||||
|
||||
return alias
|
||||
}
|
||||
|
|
|
@ -58,12 +58,12 @@
|
|||
"dependencies": {
|
||||
"@antfu/utils": "^0.5.2",
|
||||
"@ctrl/tinycolor": "^3.4.1",
|
||||
"@iconify-json/carbon": "^1.1.6",
|
||||
"@iconify-json/carbon": "^1.1.7",
|
||||
"@iconify-json/ri": "^1.1.3",
|
||||
"@intlify/vite-plugin-vue-i18n": "^5.0.0",
|
||||
"@intlify/vite-plugin-vue-i18n": "^5.0.1",
|
||||
"@vitejs/plugin-vue": "^2.3.3",
|
||||
"@vueuse/core": "^8.9.4",
|
||||
"@vueuse/head": "^0.7.6",
|
||||
"@vueuse/head": "^0.7.7",
|
||||
"consola": "^2.15.3",
|
||||
"critters": "^0.0.16",
|
||||
"cross-spawn": "^7.0.3",
|
||||
|
@ -89,16 +89,16 @@
|
|||
"nprogress": "^0.2.0",
|
||||
"open": "^8.4.0",
|
||||
"pascal-case": "^3.1.2",
|
||||
"pinia": "^2.0.16",
|
||||
"sass": "^1.53.0",
|
||||
"pinia": "^2.0.17",
|
||||
"sass": "^1.54.0",
|
||||
"shiki": "^0.10.1",
|
||||
"star-markdown-css": "^0.4.0",
|
||||
"unconfig": "^0.3.5",
|
||||
"unocss": "^0.44.5",
|
||||
"unocss": "^0.44.7",
|
||||
"unplugin-vue-components": "^0.21.1",
|
||||
"vite": "^2.9.14",
|
||||
"vite-plugin-pages": "^0.25.0",
|
||||
"vite-plugin-vue-layouts": "^0.6.0",
|
||||
"vite-plugin-vue-layouts": "^0.7.0",
|
||||
"vite-ssg": "0.19.2",
|
||||
"vite-ssg-sitemap": "0.3.1",
|
||||
"vue": "^3.2.37",
|
||||
|
|
|
@ -18,7 +18,6 @@ export default defineConfig((options) => {
|
|||
external: [
|
||||
'/@valaxyjs/site',
|
||||
'/@valaxyjs/context',
|
||||
'@waline/client',
|
||||
],
|
||||
}
|
||||
})
|
||||
|
|
|
@ -151,7 +151,7 @@ export interface SiteConfig<T = DefaultThemeConfig> {
|
|||
/**
|
||||
* third-party plugin need cdn
|
||||
* aplayer, twikoo
|
||||
* @default 'https://npm.elemecdn.com/'
|
||||
* @default 'https://unpkg.com/'
|
||||
*/
|
||||
cdn: {
|
||||
prefix: string
|
||||
|
|
616
pnpm-lock.yaml
616
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue