Merge pull request #23 from pengzhanbo/rc-0

RC: breaking changes and more changes
This commit is contained in:
pengzhanbo 2023-12-23 09:48:52 +08:00 committed by GitHub
commit 94a824436a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
292 changed files with 1294 additions and 1006 deletions

View File

@ -1,12 +1,12 @@
const fs = require('fs')
const path = require('path')
const packages = fs.readdirSync(path.resolve(__dirname, 'packages'))
const packages = fs.readdirSync(path.resolve(__dirname, 'plugins'))
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'scope-enum': [2, 'always', ['docs', ...packages]],
'scope-enum': [2, 'always', ['docs', 'theme', ...packages]],
'footer-max-line-length': [0],
},
}

View File

@ -1,5 +1,6 @@
node_modules/
.temp/
.cache/
lib/
dist/
!.vuepress/

View File

@ -48,7 +48,7 @@ module.exports = {
},
},
{
files: ['docs/**'],
files: ['docs/**/*.ts'],
rules: {
'import/no-extraneous-dependencies': 'off',
},

3
.gitignore vendored
View File

@ -3,7 +3,6 @@
docs/.vuepress/.cache
docs/.vuepress/.temp
docs/.vuepress/dist
packages/theme-back
lib/
dist/
@ -13,5 +12,3 @@ dist/
*.log
*.tsbuildinfo
.mind
packages/theme-back

View File

@ -9,6 +9,7 @@
"files.trimTrailingWhitespace": false
},
"typescript.tsdk": "node_modules/typescript/lib",
"eslint.experimental.useFlatConfig": false,
"eslint.validate": [
"javascript",
"javascriptreact",
@ -33,6 +34,7 @@
"pnpm",
"portfinder",
"shiki",
"shikiji",
"Tongji",
"tsbuildinfo",
"vite",

View File

@ -2,7 +2,7 @@ import * as path from 'path'
import { viteBundler } from '@vuepress/bundler-vite'
import { webpackBundler } from '@vuepress/bundler-webpack'
import { defineUserConfig } from '@vuepress/cli'
import themePlume from '@vuepress-plume/vuepress-theme-plume'
import themePlume from 'vuepress-theme-plume'
import { enNotes, zhNotes } from './notes.js'
export default defineUserConfig({

View File

@ -1,4 +1,4 @@
import { definePlumeNotesConfig } from '@vuepress-plume/vuepress-theme-plume'
import { definePlumeNotesConfig } from 'vuepress-theme-plume'
export const zhNotes = definePlumeNotesConfig({
dir: 'notes',

View File

@ -41,7 +41,6 @@ __基于 `vuepress 2.0` 制作的 `Blog` 主题。__
``` sh
yarn add @vuepress-plume/vuepress-theme-plume
```
:::
@tab npm
``` sh
npm i @vuepress-plume/vuepress-theme-plume
@ -56,13 +55,12 @@ npm i @vuepress-plume/vuepress-theme-plume
// .vuepress/config.ts
import { defineUserConfig } from 'vuepress'
import { themePlume } from '@vuepress-plume/vuepress-theme-plume'
export default defineUserConfig({
theme: themePlume({
export default defineUserConfig({ // [!code focus]
theme: themePlume({
// more...
})
})
```
@tab js
``` js
// .vuepress/config.js

View File

@ -9,7 +9,6 @@
"docs:serve": "anywhere -s -h localhost -d .vuepress/dist"
},
"dependencies": {
"@vuepress-plume/vuepress-theme-plume": "workspace:*",
"@vuepress/bundler-vite": "2.0.0-rc.0",
"@vuepress/bundler-webpack": "2.0.0-rc.0",
"@vuepress/cli": "2.0.0-rc.0",
@ -19,6 +18,7 @@
"leancloud-storage": "^4.15.2",
"sass": "^1.69.5",
"sass-loader": "^13.3.2",
"vue": "^3.3.13"
"vue": "^3.3.13",
"vuepress-theme-plume": "workspace:*"
}
}

View File

@ -1,5 +1,5 @@
{
"name": "vuepress-theme-plume",
"name": "vuepress-theme-plume-monorepo",
"version": "1.0.0-beta.89",
"private": true,
"keywords": [
@ -7,8 +7,6 @@
"vuepress-next",
"Theme",
"vuepress theme",
"vuepress-theme",
"theme-plume",
"vuepress-theme-plume"
],
"license": "MIT",
@ -17,11 +15,11 @@
"scripts": {
"autoUpdate": "node scripts/autoInstall.js",
"build": "pnpm run build:package",
"build:package": "pnpm --filter=!vuepress-theme-plume run -r --stream build",
"build:package": "pnpm --filter=!vuepress-theme-plume-monorepo --filter=!docs run -r --stream build",
"commit": "cz",
"dev": "concurrently \"pnpm run dev:package\" \"pnpm run docs\"",
"dev:package": "pnpm --filter=!vuepress-theme-plume --parallel dev",
"dev:theme": "concurrently \"pnpm --filter=@vuepress-plume/vuepress-theme-plume dev\" \"pnpm run docs\"",
"dev:package": "pnpm --filter=!vuepress-theme-plume-monorepo --filter=!docs --parallel dev",
"dev:theme": "concurrently \"pnpm --filter=vuepress-theme-plume dev\" \"pnpm run docs\"",
"docs": "pnpm --filter=docs docs:dev",
"docs:build": "pnpm --filter=docs docs:build",
"docs:clean": "pnpm --filter=docs docs:clean",
@ -76,7 +74,6 @@
"rimraf": "^5.0.5",
"sort-package-json": "^2.6.0",
"taze": "^0.13.0",
"ts-node": "^10.9.2",
"tsconfig-vuepress": "^4.5.0",
"typescript": "^5.3.3",
"vite": "^5.0.10"

View File

@ -1,18 +0,0 @@
# `@vuepress-plume/vuepress-plugin-copy-code`
## Install
```
yarn add @vuepress-plume/vuepress-plugin-copy-code
```
## Usage
``` js
// .vuepress/config.js
const { copyCodePlugin } = require('@vuepress-plume/vuepress-plugin-copy-code')
module.exports = {
//...
plugins: [
copyCodePlugin()
]
// ...
}
```

View File

@ -1,36 +0,0 @@
.copy-code-button {
border: none;
background-color: transparent;
outline: 0;
border-radius: 4px;
padding: 5px 10px;
color: #d1d5db;
text-align: center;
cursor: pointer;
div[class*='language-'] & {
position: absolute;
right: 0;
top: 2rem;
z-index: 99;
opacity: 0;
transition: opacity var(--t-color);
}
div[class*='language-']:hover & {
opacity: 1;
}
.icon-success {
display: inline-block;
width: 1.5rem;
height: 1.5rem;
vertical-align: middle;
}
}
.icon-copy {
display: inline-block;
width: 1.5rem;
height: 1.5rem;
}

View File

@ -1,5 +0,0 @@
export const successSVG =
'<svg t="1651745829084" class="icon-success" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2061" width="200" height="200"><path d="M469.333333 640l0.384 0.384L469.333333 640z m-106.282666 0l-0.384 0.384 0.384-0.384z m48.512 106.666667a87.466667 87.466667 0 0 1-61.653334-24.874667l-179.52-173.632a67.797333 67.797333 0 0 1 0-98.24c28.032-27.157333 73.493333-27.157333 101.589334 0l139.584 134.997333 319.168-308.544c28.032-27.157333 73.493333-27.157333 101.589333 0a67.925333 67.925333 0 0 1 0 98.24L472.981333 722.069333A87.530667 87.530667 0 0 1 411.562667 746.666667z" fill="#78C326" p-id="2062"></path></svg>'
export const copySVG =
'<svg xmlns="http://www.w3.org/2000/svg" class="icon-copy" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z" fill="currentColor"></path></svg>'

View File

@ -1,19 +0,0 @@
{
"extends": "../tsconfig.build.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./lib",
"baseUrl": ".",
"paths": {
"@theme-plume/*": ["./src/client/components/*"]
},
"types": ["@vuepress/client/types", "vite/client"]
},
"include": ["./src"],
"references": [
{ "path": "../plugin-caniuse/tsconfig.build.json" },
{ "path": "../plugin-copy-code/tsconfig.build.json" },
{ "path": "../plugin-baidu-tongji/tsconfig.build.json" }
],
"files": []
}

View File

@ -1,15 +1,15 @@
# `@vuepress-plume/vuepress-plugin-auto-frontmatter`
# `@vuepress-plume/plugin-auto-frontmatter`
自动生成 `*.md` 文件的 `frontmatter` 配置。
## Install
```
yarn add @vuepress-plume/vuepress-plugin-auto-frontmatter
yarn add @vuepress-plume/plugin-auto-frontmatter
```
## Usage
``` js
// .vuepress/config.js
import { autoFrontmatterPlugin } from '@vuepress-plume/vuepress-plugin-auto-frontmatter'
import { autoFrontmatterPlugin } from '@vuepress-plume/plugin-auto-frontmatter'
export default {
//...
plugins: [

View File

@ -1,5 +1,5 @@
{
"name": "@vuepress-plume/vuepress-plugin-auto-frontmatter",
"name": "@vuepress-plume/plugin-auto-frontmatter",
"version": "1.0.0-beta.89",
"description": "The Plugin for VuePres 2",
"homepage": "https://github.com/pengzhanbo/vuepress-theme-plume#readme",

View File

@ -68,7 +68,7 @@ export const autoFrontmatterPlugin = ({
}
return {
name: '@vuepress-plume/vuepress-plugin-auto-frontmatter',
name: '@vuepress-plume/plugin-auto-frontmatter',
onInitialized: async (app) => {
const markdownList = await readMarkdownList(app.dir.source(), globFilter)
for (const file of markdownList) {

View File

@ -1,15 +1,15 @@
# `@vuepress-plume/vuepress-plugin-baidu-tongji`
# `@vuepress-plume/plugin-baidu-tongji`
在vuepress中接入百度统计
## Install
```
yarn add @vuepress-plume/vuepress-plugin-baidu-tongji
yarn add @vuepress-plume/plugin-baidu-tongji
```
## Usage
``` js
// .vuepress/config.js
const { baiduTongjiPlugin } = require('@vuepress-plume/vuepress-plugin-baidu-tongji')
const { baiduTongjiPlugin } = require('@vuepress-plume/plugin-baidu-tongji')
module.exports = {
//...
plugins: [

View File

@ -1,5 +1,5 @@
{
"name": "@vuepress-plume/vuepress-plugin-baidu-tongji",
"name": "@vuepress-plume/plugin-baidu-tongji",
"version": "1.0.0-beta.89",
"description": "The Plugin for VuePres 2",
"homepage": "https://github.com/pengzhanbo/vuepress-theme-plume#readme",

View File

@ -6,7 +6,7 @@ export interface BaiduTongjiOptions {
export const baiduTongjiPlugin = ({ key = '' }: BaiduTongjiOptions): Plugin => {
return {
name: '@vuepress-plume/vuepress-plugin-baidu-tongji',
name: '@vuepress-plume/plugin-baidu-tongji',
extendsPage: (page) => {
page.frontmatter.head = page.frontmatter.head || [];
page.frontmatter.head?.push([

View File

@ -1,13 +1,13 @@
# `@vuepress-plume/vuepress-plugin-blog-data`
# `@vuepress-plume/plugin-blog-data`
## Install
```
yarn add @vuepress-plume/vuepress-plugin-blog-data
yarn add @vuepress-plume/plugin-blog-data
```
## Usage
``` js
// .vuepress/config.js
const { blogDataPlugin } = require('@vuepress-plume/vuepress-plugin-blog-data')
const { blogDataPlugin } = require('@vuepress-plume/plugin-blog-data')
module.exports = {
//...
plugins: [

View File

@ -1,5 +1,5 @@
{
"name": "@vuepress-plume/vuepress-plugin-blog-data",
"name": "@vuepress-plume/plugin-blog-data",
"version": "1.0.0-beta.89",
"description": "The Plugin for VuePres 2",
"homepage": "https://github.com/pengzhanbo/vuepress-theme-plume#readme",

View File

@ -19,7 +19,7 @@ export const blogDataPlugin = ({
})
return {
name: '@vuepress-plume/vuepress-plugin-blog-data',
name: '@vuepress-plume/plugin-blog-data',
clientConfigFile: path.resolve(__dirname, '../client/config.js'),
extendsPage(page) {
if (page.filePathRelative && pageFilter(page.filePathRelative)) {

View File

@ -1,14 +1,14 @@
# `@vuepress-plume/vuepress-plugin-caniuse`
# `@vuepress-plume/plugin-caniuse`
为 markdown 添加 can-i-use 容器支持
## Install
```
yarn add @vuepress-plume/vuepress-plugin-caniuse
yarn add @vuepress-plume/plugin-caniuse
```
## Usage
``` js
// .vuepress/config.js
const { caniusePlugin } = require('@vuepress-plume/vuepress-plugin-caniuse')
const { caniusePlugin } = require('@vuepress-plume/plugin-caniuse')
module.exports = {
//...
plugins: [

View File

@ -1,5 +1,5 @@
{
"name": "@vuepress-plume/vuepress-plugin-caniuse",
"name": "@vuepress-plume/plugin-caniuse",
"version": "1.0.0-beta.89",
"description": "The Plugin for VuePres 2, Support Can-I-Use feature",
"keywords": [

View File

@ -8,7 +8,7 @@ VuePress 2 插件
## Install
``` sh
yarn add @vuepress-plume/vuepress-plugin-caniuse
yarn add @vuepress-plume/plugin-caniuse
```
## Usage
@ -19,7 +19,7 @@ yarn add @vuepress-plume/vuepress-plugin-caniuse
export default {
// ...
plugins: [
['@vuepress-plume/vuepress-plugin-caniuse', { mode: 'image' }]
['@vuepress-plume/plugin-caniuse', { mode: 'image' }]
]
// ...
}

View File

@ -16,7 +16,7 @@ export const caniusePlugin = ({
const type = 'caniuse'
const validateReg = new RegExp(`^${type}\\s+(.*)$`)
const pluginObj: PluginObject = {
name: '@vuepress-plume/vuepress-plugin-caniuse',
name: '@vuepress-plume/plugin-caniuse',
clientConfigFile: path.resolve(__dirname, '../client/clientConfig.js'),
define: {
__CAN_I_USE_INJECT_MODE__: mode,

View File

@ -0,0 +1,18 @@
# `@vuepress-plume/plugin-copy-code`
## Install
```
yarn add @vuepress-plume/plugin-copy-code
```
## Usage
``` js
// .vuepress/config.js
const { copyCodePlugin } = require('@vuepress-plume/plugin-copy-code')
module.exports = {
//...
plugins: [
copyCodePlugin()
]
// ...
}
```

View File

@ -1,5 +1,5 @@
{
"name": "@vuepress-plume/vuepress-plugin-copy-code",
"name": "@vuepress-plume/plugin-copy-code",
"version": "1.0.0-beta.89",
"description": "The Plugin for VuePres 2",
"homepage": "https://github.com/pengzhanbo/vuepress-theme-plume#readme",

View File

@ -2,7 +2,6 @@
import { onMounted, watch } from 'vue'
import { useRoute } from 'vue-router'
import type { CopyCodeOptions } from '../../shared/index.js'
import { copySVG, successSVG } from '../svg.js'
import { copyToClipboard } from './copyToClipboard.js'
declare const __COPY_CODE_OPTIONS__: CopyCodeOptions
// declare const __COPY_CODE_LOCALES_OPTIONS__: CopyCodeLocaleOption
@ -29,14 +28,13 @@ export const setupCopyCode = (): void => {
if (codeBlockEl.hasAttribute('has-copy-code')) return
const button = document.createElement('button')
button.className = 'copy-code-button'
button.innerHTML = copySVG
button.addEventListener('click', () => {
copyToClipboard(codeBlockEl.innerText)
button.innerHTML = successSVG
button.classList.add('copied')
options.duration &&
setTimeout(() => {
button.innerHTML = copySVG
button.classList.remove('copied')
}, options.duration)
})

View File

@ -0,0 +1,90 @@
:root {
--icon-copy: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' height='20' width='20' stroke='rgba(128,128,128,1)' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M9 5H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2M9 5a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2M9 5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2'/%3E%3C/svg%3E");
--icon-copied: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' height='20' width='20' stroke='rgba(128,128,128,1)' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M9 5H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2M9 5a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2M9 5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2m-6 9 2 2 4-4'/%3E%3C/svg%3E");
}
:root {
--code-copy-code-border-color: #e2e2e3;
--code-copy-code-bg: #f6f6f7;
--code-copy-code-hover-border-color: #e2e2e3;
--code-copy-code-hover-bg: #fff;
--code-copy-code-active-text: rgba(60, 60, 67, 0.78);
--code-copy-copied-text-content: 'Copied';
}
.dark {
--code-copy-code-border-color: #2e2e32;
--code-copy-code-bg: #202127;
--code-copy-code-hover-bg: #1b1b1f;
--code-copy-code-hover-border-color: #2e2e32;
--code-copy-code-active-text: rgba(235, 235, 245, 0.6);
}
.copy-code-button {
/*rtl:ignore*/
direction: ltr;
position: absolute;
top: 12px;
/*rtl:ignore*/
right: 12px;
z-index: 3;
border: 1px solid var(--code-copy-code-border-color);
border-radius: 4px;
width: 40px;
height: 40px;
background-color: var(--code-copy-code-bg);
opacity: 0;
cursor: pointer;
background-image: var(--icon-copy);
background-position: 50%;
background-size: 20px;
background-repeat: no-repeat;
transition:
border-color 0.25s,
background-color 0.25s,
opacity 0.25s;
}
[class*='language-']:hover > .copy-code-button,
[class*='language-'] > .copy-code-button:focus {
opacity: 1;
}
[class*='language-'] > .copy-code-button:hover,
[class*='language-'] > .copy-code-button.copied {
border-color: var(--code-copy-code-hover-border-color);
background-color: var(--code-copy-code-hover-bg);
}
[class*='language-'] > .copy-code-button.copied,
[class*='language-'] > .copy-code-button:hover.copied {
/*rtl:ignore*/
border-radius: 0 4px 4px 0;
background-color: var(--code-copy-code-hover-bg);
background-image: var(--icon-copied);
}
[class*='language-'] > .copy-code-button.copied::before,
[class*='language-'] > .copy-code-button:hover.copied::before {
position: relative;
top: -1px;
/*rtl:ignore*/
transform: translateX(calc(-100% - 1px));
display: flex;
justify-content: center;
align-items: center;
border: 1px solid var(--code-copy-code-hover-border-color);
/*rtl:ignore*/
border-right: 0;
border-radius: 4px 0 0 4px;
padding: 0 10px;
width: fit-content;
height: 40px;
text-align: center;
font-size: 12px;
font-weight: 500;
color: var(--code-copy-code-active-text);
background-color: var(--code-copy-code-hover-bg);
white-space: nowrap;
content: var(--code-copy-copied-text-content);
}

View File

@ -30,7 +30,7 @@ export const copyCodePlugin = (options: CopyCodeOptions): Plugin => {
const localesOption = Object.assign({}, defaultLocalesOption, locales)
return {
name: '@vuepress-plume/vuepress-plugin-copy-code',
name: '@vuepress-plume/plugin-copy-code',
define: (): Record<string, unknown> => ({
__COPY_CODE_OPTIONS__: options,

View File

@ -1,15 +1,15 @@
# `@vuepress-plume/vuepress-plugin-iconify`
# `@vuepress-plume/plugin-iconify`
添加 `iconify` 图标库支持。并注入全局组件 `<Iconify>`
## Install
```
yarn add @vuepress-plume/vuepress-plugin-iconify
yarn add @vuepress-plume/plugin-iconify
```
## Usage
``` js
// .vuepress/config.js
const iconifyPlugin = require('@vuepress-plume/vuepress-plugin-iconify')
const iconifyPlugin = require('@vuepress-plume/plugin-iconify')
module.exports = {
//...
plugins: [

View File

@ -1,5 +1,5 @@
{
"name": "@vuepress-plume/vuepress-plugin-iconify",
"name": "@vuepress-plume/plugin-iconify",
"version": "1.0.0-beta.89",
"description": "The Plugin for VuePres 2",
"homepage": "https://github.com/pengzhanbo/vuepress-theme-plume#readme",

View File

@ -9,7 +9,7 @@ export const iconifyPlugin = ({
}: IconifyOptions = {}): Plugin => {
return (app: App) => {
return {
name: '@vuepress-plume/vuepress-plugin-iconify',
name: '@vuepress-plume/plugin-iconify',
define: {
__VUEPRESS_PLUGIN_ICONIFY_COMPONENT_NAME__: componentName,
__VUEPRESS_PLUGIN_ICONIFY_DEFAULT_SIZE__: size,

View File

@ -1,4 +1,4 @@
# `@vuepress-plume/vuepress-plugin-netlify-functions`
# `@vuepress-plume/plugin-netlify-functions`
If your vuepress site is deployed on `netlify` and you want to be able to use `netlify functions` for ` serverless`.
@ -24,7 +24,7 @@ You may need this plugin to provide support.
## Install
```
yarn add @vuepress-plume/vuepress-plugin-netlify-functions
yarn add @vuepress-plume/plugin-netlify-functions
```
## Usage
@ -33,7 +33,7 @@ yarn add @vuepress-plume/vuepress-plugin-netlify-functions
在 vuepress 项目中,或者在一个 vuepress 主题中
``` js
// .vuepress/config.js
import { netlifyFunctionsPlugin } from '@vuepress-plume/vuepress-plugin-netlify-functions'
import { netlifyFunctionsPlugin } from '@vuepress-plume/plugin-netlify-functions'
module.exports = {
//...
plugins: [
@ -47,7 +47,7 @@ yarn add @vuepress-plume/vuepress-plugin-netlify-functions
在 vuepress plugin 中:
``` js
import { useNetlifyFunctionsPlugin } from '@vuepress-plume/vuepress-plugin-netlify-functions'
import { useNetlifyFunctionsPlugin } from '@vuepress-plume/plugin-netlify-functions'
const myPlugin = (): Plugin => {
return (app: App) => {

View File

@ -1,5 +1,5 @@
{
"name": "@vuepress-plume/vuepress-plugin-netlify-functions",
"name": "@vuepress-plume/plugin-netlify-functions",
"version": "1.0.0-beta.89",
"description": "The Plugin for VuePres 2, Support Netlify Functions",
"keywords": [

View File

@ -78,7 +78,7 @@ export const netlifyFunctionsPlugin = (
let server: NetlifyServe
cache.options = opts
return {
name: '@vuepress-plume/vuepress-plugin-netlify-functions',
name: '@vuepress-plume/plugin-netlify-functions',
onInitialized: async (app) => {
// 启动netlify functions server

View File

@ -35,7 +35,7 @@ export const useNetlifyFunctionsPlugin = (
if (
!plugins.some(
(plugin: PluginObject) =>
plugin.name === '@vuepress-plume/vuepress-plugin-netlify-functions'
plugin.name === '@vuepress-plume/plugin-netlify-functions'
)
) {
app.use(netlifyFunctionsPlugin())

Some files were not shown because too many files have changed in this diff Show More