diff --git a/docs/.vuepress/config.ts b/docs/.vuepress/config.ts index a94afbc4..fc92894a 100644 --- a/docs/.vuepress/config.ts +++ b/docs/.vuepress/config.ts @@ -1,14 +1,14 @@ import * as path from 'path' -import type { PlumeThemeOptions } from '@vuepress-plume/vuepress-theme-plume' +import { themePlume } from '@vuepress-plume/vuepress-theme-plume' import { defineUserConfig } from '@vuepress/cli' -export default defineUserConfig({ +export default defineUserConfig({ + base: '/', lang: 'zh', title: 'Plume Theme', description: '', public: path.resolve(__dirname, 'public'), - theme: '@vuepress-plume/vuepress-theme-plume', - themeConfig: { + theme: themePlume({ logo: 'https://pengzhanbo.cn/g.gif', hostname: 'https://pengzhanbo.cn', avatar: { @@ -101,5 +101,5 @@ export default defineUserConfig({ }, }, }, - }, + }), }) diff --git a/package.json b/package.json index f227702d..4aba6850 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "docs:webpack-build": "vuepress-webpack build docs", "docs:webpack-serve": "vuepress-webpack dev docs", "lerna": "lerna clean && lerna bootstrap", - "lerna:publish": "node scripts/release/index.mjs --input-type module", + "lerna:publish": "node scripts/release/index.mjs", "lint": "eslint --ext .js,.ts,.vue .", "package:clean": "lerna run clean", "package:update": "node scripts/dependencies.js", @@ -51,7 +51,7 @@ "devDependencies": { "@commitlint/cli": "^16.2.3", "@commitlint/config-conventional": "^16.2.1", - "@vuepress/cli": "^2.0.0-beta.38", + "@vuepress/cli": "^2.0.0-beta.41", "commitizen": "^4.2.4", "concurrently": "^7.0.0", "cpx2": "^4.2.0", @@ -67,8 +67,8 @@ "prettier-config-vuepress": "^1.4.0", "rimraf": "^3.0.2", "typescript": "^4.6.3", - "vuepress-vite": "^2.0.0-beta.39", - "vuepress-webpack": "^2.0.0-beta.38", + "vuepress-vite": "^2.0.0-beta.41", + "vuepress-webpack": "^2.0.0-beta.41", "webpack-env": "^0.8.0" } } diff --git a/packages/plugin-caniuse/package.json b/packages/plugin-caniuse/package.json index 09df9839..8741f8dc 100644 --- a/packages/plugin-caniuse/package.json +++ b/packages/plugin-caniuse/package.json @@ -2,36 +2,34 @@ "name": "@vuepress-plume/vuepress-plugin-caniuse", "version": "1.0.0-beta.8", "description": "The Plugin for VuePres 2, Support Can-I-Use feature", - "author": "pengzhanbo ", "homepage": "https://github.com/pengzhanbo/vuepress-theme-plume#readme", - "license": "MIT", - "main": "lib/node/index.js", - "files": [ - "lib" - ], + "bugs": { + "url": "https://github.com/pengzhanbo/vuepress-theme-plume/issues" + }, "repository": { "type": "git", "url": "git+https://github.com/pengzhanbo/vuepress-theme-plume.git" }, - "bugs": { - "url": "https://github.com/pengzhanbo/vuepress-theme-plume/issues" - }, + "license": "MIT", + "author": "pengzhanbo ", + "main": "lib/node/index.js", + "files": [ + "lib" + ], "scripts": { - "ts": "tsc -b tsconfig.build.json", - "ts:watch": "tsc -b tsconfig.build.json --watch", + "build": "yarn clean && yarn ts", "clean": "rimraf lib *.tsbuildinfo", "dev": "yarn ts:watch", - "build": "yarn clean && yarn ts" + "ts": "tsc -b tsconfig.build.json", + "ts:watch": "tsc -b tsconfig.build.json --watch" }, "dependencies": { - "@vuepress/client": "^2.0.0-beta.38", - "@vuepress/core": "^2.0.0-beta.38", - "@vuepress/utils": "^2.0.0-beta.38", + "@vuepress/cli": "^2.0.0-beta.41", + "@vuepress/client": "^2.0.0-beta.41", + "@vuepress/core": "^2.0.0-beta.41", + "@vuepress/utils": "^2.0.0-beta.41", "markdown-it-container": "^3.0.0" }, - "peerDependencies": { - "vuepress": "^2.0.0-beta.38" - }, "publishConfig": { "access": "public" }, diff --git a/packages/plugin-caniuse/src/node/index.ts b/packages/plugin-caniuse/src/node/index.ts index 72167fa0..bd0e900d 100644 --- a/packages/plugin-caniuse/src/node/index.ts +++ b/packages/plugin-caniuse/src/node/index.ts @@ -1,6 +1,6 @@ -import { plugin } from './plugin' +import { caniusePlugin } from './plugin' export * from './plugin' export * from '../shared' -export default plugin +export default caniusePlugin diff --git a/packages/plugin-caniuse/src/node/plugin.ts b/packages/plugin-caniuse/src/node/plugin.ts index 98ec772f..0a73ab8a 100644 --- a/packages/plugin-caniuse/src/node/plugin.ts +++ b/packages/plugin-caniuse/src/node/plugin.ts @@ -1,4 +1,4 @@ -import type { Plugin, PluginObject } from '@vuepress/core' +import type { PluginObject } from '@vuepress/core' import { path } from '@vuepress/utils' import * as container from 'markdown-it-container' import type * as Token from 'markdown-it/lib/token' @@ -8,7 +8,9 @@ import { resolveCanIUse } from './resolveCanIUse' const modeMap: CanIUseMode[] = ['image', 'embed'] const isMode = (mode: CanIUseMode): boolean => modeMap.includes(mode) -export const plugin: Plugin = ({ mode = modeMap[0] }: CanIUsePluginOptions) => { +export const caniusePlugin = ({ + mode = modeMap[0], +}: CanIUsePluginOptions): PluginObject => { mode = isMode(mode) ? mode : modeMap[0] const type = 'caniuse' const validateReg = new RegExp(`^${type}\\s+(.*)$`) diff --git a/packages/theme/package.json b/packages/theme/package.json index 094cce1c..47093dc7 100644 --- a/packages/theme/package.json +++ b/packages/theme/package.json @@ -29,21 +29,21 @@ "dependencies": { "@types/lodash.merge": "^4.6.6", "@vuepress-plume/vuepress-plugin-caniuse": "1.0.0-beta.8", - "@vuepress/client": "^2.0.0-beta.38", - "@vuepress/core": "^2.0.0-beta.38", - "@vuepress/plugin-active-header-links": "^2.0.0-beta.38", - "@vuepress/plugin-container": "^2.0.0-beta.38", - "@vuepress/plugin-docsearch": "^2.0.0-beta.38", - "@vuepress/plugin-external-link-icon": "^2.0.0-beta.38", - "@vuepress/plugin-medium-zoom": "^2.0.0-beta.38", - "@vuepress/plugin-nprogress": "^2.0.0-beta.38", - "@vuepress/plugin-palette": "^2.0.0-beta.38", - "@vuepress/plugin-prismjs": "^2.0.0-beta.38", - "@vuepress/plugin-search": "^2.0.0-beta.38", - "@vuepress/plugin-theme-data": "^2.0.0-beta.38", - "@vuepress/plugin-toc": "^2.0.0-beta.38", - "@vuepress/shared": "^2.0.0-beta.38", - "@vuepress/utils": "^2.0.0-beta.38", + "@vuepress/client": "^2.0.0-beta.41", + "@vuepress/core": "^2.0.0-beta.41", + "@vuepress/plugin-active-header-links": "^2.0.0-beta.41", + "@vuepress/plugin-container": "^2.0.0-beta.41", + "@vuepress/plugin-docsearch": "^2.0.0-beta.41", + "@vuepress/plugin-external-link-icon": "^2.0.0-beta.41", + "@vuepress/plugin-medium-zoom": "^2.0.0-beta.41", + "@vuepress/plugin-nprogress": "^2.0.0-beta.41", + "@vuepress/plugin-palette": "^2.0.0-beta.41", + "@vuepress/plugin-prismjs": "^2.0.0-beta.41", + "@vuepress/plugin-search": "^2.0.0-beta.41", + "@vuepress/plugin-theme-data": "^2.0.0-beta.41", + "@vuepress/plugin-toc": "^2.0.0-beta.41", + "@vuepress/shared": "^2.0.0-beta.41", + "@vuepress/utils": "^2.0.0-beta.41", "@vueuse/core": "^8.2.3", "chokidar": "^3.5.3", "date-fns": "^2.28.0", @@ -62,6 +62,14 @@ "vuepress-plugin-seo2": "^2.0.0-beta.47", "vuepress-plugin-sitemap2": "^2.0.0-beta.47" }, + "peerDependencies": { + "sass-loader": "^12.6.0" + }, + "peerDependenciesMeta": { + "sass-loader": { + "optional": true + } + }, "publishConfig": { "access": "public" }, diff --git a/packages/theme/src/client/clientAppEnhance.ts b/packages/theme/src/client/clientAppEnhance.ts index f0613872..91d5b79c 100644 --- a/packages/theme/src/client/clientAppEnhance.ts +++ b/packages/theme/src/client/clientAppEnhance.ts @@ -1,5 +1,4 @@ import { defineClientAppEnhance } from '@vuepress/client' -import type { Component } from 'vue' import { h } from 'vue' import { useScrollPromise } from './composables' @@ -7,14 +6,22 @@ import './styles/index.scss' export default defineClientAppEnhance(({ app, router }) => { app.component('NavbarSearch', () => { - const SearchComponent = (app.component('Docsearch') || - app.component('SearchBox')) as Component + const SearchComponent = + app.component('Docsearch') || app.component('SearchBox') if (SearchComponent) { return h(SearchComponent) } return null }) + app.component('Comment', (props) => { + const CommentService = app.component('CommentService') + if (CommentService) { + return h(CommentService, props) + } + return null + }) + const scrollBehavior = router.options.scrollBehavior! router.options.scrollBehavior = async (...args) => { await useScrollPromise().wait() diff --git a/packages/theme/src/client/components/HomeBigBanner.vue b/packages/theme/src/client/components/HomeBigBanner.vue index cee6e611..cba25da7 100644 --- a/packages/theme/src/client/components/HomeBigBanner.vue +++ b/packages/theme/src/client/components/HomeBigBanner.vue @@ -22,6 +22,7 @@ const bannerStyle = computed(() => { }) function handleResize(): void { + if (__VUEPRESS_SSR__) return const width = document.documentElement.offsetWidth if (!hasBanner.value) return if (width < MOBILE_WIDTH) { diff --git a/packages/theme/src/client/components/Page.vue b/packages/theme/src/client/components/Page.vue index 3dee559f..4409bd99 100644 --- a/packages/theme/src/client/components/Page.vue +++ b/packages/theme/src/client/components/Page.vue @@ -19,26 +19,6 @@ const isNote = computed(() => { const enabledSidebar = computed(() => { return isNote.value }) - -let layout: HTMLElement | null -watchEffect(async () => { - await nextTick() - if (!enabledSidebar.value) return - layout = document.querySelector('.plume-theme') - const footer: HTMLElement | null = document.querySelector( - '.theme-plume-footer' - ) - if (themeLocale.value.footer) { - const h = getCssValue(footer, 'height') - layout?.setAttribute('style', `padding-bottom: ${h}px`) - } else { - layout?.setAttribute('style', `padding-bottom: 0`) - } -}) - -onUnmounted(() => { - layout?.removeAttribute('style') -})