├── .commitlintrc.js ├── .editorconfig ├── .eslintignore ├── .eslintrc.js ├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── feature_request.md │ └── question.md ├── PULL_REQUEST_TEMPLATE.md ├── lock.yml ├── stale.yml └── workflows │ └── check.yml ├── .gitignore ├── .vscode └── settings.json ├── LICENSE ├── README.md ├── jest.config.js ├── lerna.json ├── package.json ├── packages ├── docs │ ├── .gitignore │ ├── CHANGELOG.md │ ├── package.json │ ├── src │ │ ├── .vuepress │ │ │ ├── components │ │ │ │ ├── GitHubLink.vue │ │ │ │ └── NpmLink.vue │ │ │ ├── config.js │ │ │ ├── ecosystem.js │ │ │ ├── public │ │ │ │ └── logo │ │ │ │ │ └── 600x600.png │ │ │ └── styles │ │ │ │ ├── container.styl │ │ │ │ ├── content.styl │ │ │ │ ├── index.styl │ │ │ │ └── mathjax.styl │ │ ├── en │ │ │ ├── README.md │ │ │ ├── plugins │ │ │ │ ├── clean-urls.md │ │ │ │ ├── container.md │ │ │ │ ├── copyright.md │ │ │ │ ├── dehydrate.md │ │ │ │ ├── git-log.md │ │ │ │ ├── mathjax.md │ │ │ │ ├── medium-zoom.md │ │ │ │ ├── migrate.md │ │ │ │ ├── named-chunks.md │ │ │ │ ├── nprogress.md │ │ │ │ ├── redirect.md │ │ │ │ ├── serve.md │ │ │ │ ├── smooth-scroll.md │ │ │ │ ├── table-of-contents.md │ │ │ │ ├── typescript.md │ │ │ │ └── zooming.md │ │ │ └── tools │ │ │ │ ├── mergeable.md │ │ │ │ └── types.md │ │ └── zh │ │ │ ├── README.md │ │ │ ├── plugins │ │ │ ├── clean-urls.md │ │ │ ├── container.md │ │ │ ├── copyright.md │ │ │ ├── dehydrate.md │ │ │ ├── git-log.md │ │ │ ├── mathjax.md │ │ │ ├── medium-zoom.md │ │ │ ├── migrate.md │ │ │ ├── named-chunks.md │ │ │ ├── nprogress.md │ │ │ ├── redirect.md │ │ │ ├── serve.md │ │ │ ├── smooth-scroll.md │ │ │ ├── table-of-contents.md │ │ │ ├── typescript.md │ │ │ └── zooming.md │ │ │ └── tools │ │ │ ├── mergeable.md │ │ │ └── types.md │ └── tsconfig.json ├── vuepress-mergeable │ ├── CHANGELOG.md │ ├── README.md │ ├── package.json │ ├── src │ │ └── index.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── vuepress-plugin-clean-urls │ ├── CHANGELOG.md │ ├── README.md │ ├── package.json │ ├── src │ │ └── index.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── vuepress-plugin-container │ ├── .gitignore │ ├── CHANGELOG.md │ ├── README.md │ ├── package.json │ ├── src │ │ ├── index.ts │ │ └── markdown-it-container.ts │ ├── test │ │ └── e2e │ │ │ ├── __fragments__ │ │ │ ├── hint-default.md │ │ │ ├── hint-locale-jp.md │ │ │ ├── hint-override.md │ │ │ └── theorem.md │ │ │ ├── __snapshots__ │ │ │ └── index.spec.ts.snap │ │ │ └── index.spec.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── vuepress-plugin-dehydrate │ ├── .gitignore │ ├── CHANGELOG.md │ ├── README.md │ ├── package.json │ ├── src │ │ └── index.ts │ ├── test │ │ └── e2e │ │ │ ├── __snapshots__ │ │ │ └── index.spec.ts.snap │ │ │ ├── docs │ │ │ ├── .vuepress │ │ │ │ ├── config.js │ │ │ │ └── theme │ │ │ │ │ └── layouts │ │ │ │ │ └── Layout.vue │ │ │ ├── README.md │ │ │ └── noscript.md │ │ │ └── index.spec.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── vuepress-plugin-medium-zoom │ ├── CHANGELOG.md │ ├── README.md │ ├── package.json │ ├── src │ │ ├── VuepressMediumZoom.ts │ │ ├── clientRootMixin.ts │ │ └── index.ts │ ├── styles │ │ └── index.styl │ ├── tsconfig.build.json │ └── tsconfig.json ├── vuepress-plugin-named-chunks │ ├── .gitignore │ ├── CHANGELOG.md │ ├── README.md │ ├── package.json │ ├── src │ │ └── index.ts │ ├── test │ │ └── e2e │ │ │ ├── __snapshots__ │ │ │ └── index.spec.ts.snap │ │ │ ├── docs │ │ │ ├── .vuepress │ │ │ │ ├── config.js │ │ │ │ └── theme │ │ │ │ │ └── layouts │ │ │ │ │ ├── Custom.vue │ │ │ │ │ └── Layout.vue │ │ │ ├── README.md │ │ │ └── custom.md │ │ │ └── index.spec.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── vuepress-plugin-nprogress │ ├── CHANGELOG.md │ ├── README.md │ ├── package.json │ ├── src │ │ ├── clientRootMixin.ts │ │ └── index.ts │ ├── styles │ │ └── index.styl │ ├── tsconfig.build.json │ └── tsconfig.json ├── vuepress-plugin-redirect │ ├── CHANGELOG.md │ ├── README.md │ ├── package.json │ ├── src │ │ ├── enhanceApp.ts │ │ └── index.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── vuepress-plugin-serve │ ├── CHANGELOG.md │ ├── README.md │ ├── package.json │ ├── src │ │ └── index.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── vuepress-plugin-smooth-scroll │ ├── CHANGELOG.md │ ├── README.md │ ├── package.json │ ├── src │ │ ├── clientRootMixin.ts │ │ ├── enhanceApp.ts │ │ └── index.ts │ ├── styles │ │ └── index.styl │ ├── tsconfig.build.json │ └── tsconfig.json ├── vuepress-plugin-table-of-contents │ ├── CHANGELOG.md │ ├── README.md │ ├── package.json │ ├── src │ │ ├── components │ │ │ └── TableOfContents.ts │ │ └── index.ts │ ├── tsconfig.build.json │ └── tsconfig.json ├── vuepress-plugin-typescript │ ├── .gitignore │ ├── CHANGELOG.md │ ├── README.md │ ├── package.json │ ├── src │ │ └── index.ts │ ├── test │ │ ├── .eslintrc.js │ │ └── e2e │ │ │ ├── __snapshots__ │ │ │ └── index.spec.ts.snap │ │ │ ├── docs │ │ │ ├── .vuepress │ │ │ │ ├── config.js │ │ │ │ ├── shims-vue.d.ts │ │ │ │ └── theme │ │ │ │ │ ├── components │ │ │ │ │ ├── Test.vue │ │ │ │ │ ├── TestIndexTsFile │ │ │ │ │ │ └── index.ts │ │ │ │ │ └── TestTsFile.ts │ │ │ │ │ ├── enhanceApp.ts │ │ │ │ │ └── layouts │ │ │ │ │ └── Layout.vue │ │ │ ├── README.md │ │ │ ├── enhance-app-ts.md │ │ │ └── ts-in-md.md │ │ │ ├── index.spec.ts │ │ │ └── tsconfig.json │ ├── tsconfig.build.json │ └── tsconfig.json ├── vuepress-plugin-zooming │ ├── CHANGELOG.md │ ├── README.md │ ├── package.json │ ├── src │ │ ├── VuepressZooming.ts │ │ ├── clientRootMixin.ts │ │ └── index.ts │ ├── tsconfig.build.json │ └── tsconfig.json └── vuepress-types │ ├── CHANGELOG.md │ ├── README.md │ ├── package.json │ ├── tsconfig.json │ └── types │ ├── computed.d.ts │ ├── config.d.ts │ ├── context.d.ts │ ├── core.d.ts │ ├── enhance-app.d.ts │ ├── index.d.ts │ ├── markdown.d.ts │ ├── page.d.ts │ ├── plugin-api.d.ts │ ├── plugin.d.ts │ ├── store.d.ts │ ├── theme-api.d.ts │ └── theme.d.ts ├── tsconfig.json └── yarn.lock /.commitlintrc.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs') 2 | const path = require('path') 3 | 4 | const packages = fs 5 | .readdirSync(path.resolve(__dirname, 'packages')) 6 | .filter(name => !['docs'].includes(name)) 7 | 8 | module.exports = { 9 | extends: ['@commitlint/config-conventional'], 10 | rules: { 11 | 'scope-enum': [ 12 | 2, 13 | 'always', 14 | packages.map(name => name.replace(/^vuepress-/, '')), 15 | ], 16 | }, 17 | } 18 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | !.vuepress/ 3 | !.eslintrc.js 4 | !.commitlintrc.js 5 | lib/ 6 | dist/ 7 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | extends: 'vuepress', 4 | overrides: [ 5 | { 6 | files: ['*.ts'], 7 | extends: 'vuepress-typescript', 8 | rules: { 9 | '@typescript-eslint/no-var-requires': 'off', 10 | }, 11 | }, 12 | { 13 | files: ['packages/*/test/**/*.ts'], 14 | env: { 15 | jest: true, 16 | }, 17 | rules: { 18 | '@typescript-eslint/explicit-function-return-type': 'off', 19 | }, 20 | }, 21 | ], 22 | } 23 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text eol=lf 2 | *.txt text eol=crlf 3 | 4 | *.png binary 5 | *.jpg binary 6 | *.jpeg binary 7 | *.ico binary 8 | *.tff binary 9 | *.woff binary 10 | *.woff2 binary 11 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a bug report to help us improve 4 | title: '[Bug Report] ' 5 | labels: '' 6 | assignees: '' 7 | --- 8 | 9 | ## Environment 10 | 11 | 12 | 13 | 20 | 21 | - Package version: 22 | - VuePress version: 23 | - OS: 24 | - Browser: 25 | 26 | ## Describe the bug 27 | 28 | 29 | 30 | ## Steps To Reproduce 31 | 32 | 33 | 34 | 41 | 42 | ## Screenshots 43 | 44 | 45 | 46 | ## Expected behavior 47 | 48 | 49 | 50 | ## Additional context 51 | 52 | 53 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea 4 | title: '[Feature Request] ' 5 | labels: '' 6 | assignees: '' 7 | --- 8 | 9 | ## What problem does the feature solve? 10 | 11 | 12 | 13 | ## Proposed solution 14 | 15 | 16 | 17 | ## Alternative solutions 18 | 19 | 20 | 21 | ## Additional context 22 | 23 | 24 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Question 3 | about: Any Questions or Problems 4 | title: '[Question] ' 5 | labels: '' 6 | assignees: '' 7 | --- 8 | 9 | ## Environment 10 | 11 | 12 | 13 | 20 | 21 | - Package version: 22 | - VuePress version: 23 | - OS: 24 | - Browser: 25 | 26 | ## What's your question? 27 | 28 | 29 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | **Summary** 7 | 8 | **Which package does this PR involve?** (check one) 9 | 10 | - [ ] root project 11 | - [ ] vuepress-plugin-clean-urls 12 | - [ ] vuepress-plugin-container 13 | - [ ] vuepress-plugin-dehydrate 14 | - [ ] vuepress-plugin-medium-zoom 15 | - [ ] vuepress-plugin-named-chunks 16 | - [ ] vuepress-plugin-nprogress 17 | - [ ] vuepress-plugin-redirect 18 | - [ ] vuepress-plugin-smooth-scroll 19 | - [ ] vuepress-plugin-table-of-contents 20 | - [ ] vuepress-plugin-typescript 21 | - [ ] vuepress-plugin-zooming 22 | - [ ] vuepress-mergeable 23 | - [ ] vuepress-types 24 | 25 | **What kind of change does this PR introduce?** (check at least one) 26 | 27 | - [ ] Bugfix (fix) 28 | - [ ] Feature (feat) 29 | - [ ] Performance enhancement (perf) 30 | - [ ] Code Style (style) 31 | - [ ] Refactor (refactor) 32 | - [ ] Docs (docs) 33 | - [ ] Build-related changes (build) 34 | - [ ] CI-related changes (ci) 35 | - [ ] Testing (test) 36 | - [ ] Other, please describe: 37 | 38 | **Does this PR introduce a breaking change?** (check one) 39 | 40 | - [ ] Yes 41 | - [ ] No 42 | 43 | If yes, please describe the impact and migration path for existing applications: 44 | 45 | **The PR fulfills these requirements:** 46 | 47 | - [ ] When resolving a specific issue, it's referenced in the PR's title (e.g. `fix #xxx[,#xxx]`, where "xxx" is the issue number) 48 | 49 | **Other information:** 50 | -------------------------------------------------------------------------------- /.github/lock.yml: -------------------------------------------------------------------------------- 1 | # Configuration for Lock Threads - https://github.com/dessant/lock-threads 2 | 3 | # Number of days of inactivity before a closed issue or pull request is locked 4 | daysUntilLock: 120 5 | 6 | # Skip issues and pull requests created before a given timestamp. Timestamp must 7 | # follow ISO 8601 (`YYYY-MM-DD`). Set to `false` to disable 8 | skipCreatedBefore: false 9 | 10 | # Issues and pull requests with these labels will be ignored. Set to `[]` to disable 11 | exemptLabels: [] 12 | 13 | # Label to add before locking, such as `outdated`. Set to `false` to disable 14 | lockLabel: false 15 | 16 | # Comment to post before locking. Set to `false` to disable 17 | lockComment: > 18 | This thread has been automatically locked since there has not been 19 | any recent activity after it was closed. Please open a new issue for 20 | related bugs. 21 | 22 | # Assign `resolved` as the reason for locking. Set to `false` to disable 23 | setLockReason: true 24 | # Limit to only `issues` or `pulls` 25 | # only: issues 26 | 27 | # Optionally, specify configuration settings just for `issues` or `pulls` 28 | # issues: 29 | # exemptLabels: 30 | # - help-wanted 31 | # lockLabel: outdated 32 | 33 | # pulls: 34 | # daysUntilLock: 30 35 | 36 | # Repository to extend settings from 37 | # _extends: repo 38 | -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | # Configuration for probot-stale - https://github.com/probot/stale 2 | 3 | # Number of days of inactivity before an Issue or Pull Request becomes stale 4 | daysUntilStale: 60 5 | 6 | # Number of days of inactivity before an Issue or Pull Request with the stale label is closed. 7 | # Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale. 8 | daysUntilClose: 7 9 | 10 | # Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled) 11 | onlyLabels: [] 12 | 13 | # Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable 14 | exemptLabels: 15 | - bug 16 | 17 | # Set to true to ignore issues in a project (defaults to false) 18 | exemptProjects: false 19 | 20 | # Set to true to ignore issues in a milestone (defaults to false) 21 | exemptMilestones: false 22 | 23 | # Set to true to ignore issues with an assignee (defaults to false) 24 | exemptAssignees: false 25 | 26 | # Label to use when marking as stale 27 | staleLabel: stale 28 | 29 | # Comment to post when marking as stale. Set to `false` to disable 30 | markComment: > 31 | This issue has been automatically marked as stale because it has not had 32 | recent activity. It will be closed if no further activity occurs. Thank you 33 | for your contributions. 34 | 35 | # Comment to post when removing the stale label. 36 | # unmarkComment: > 37 | # Your comment here. 38 | 39 | # Comment to post when closing a stale Issue or Pull Request. 40 | # closeComment: > 41 | # Your comment here. 42 | 43 | # Limit the number of actions per hour, from 1-30. Default is 30 44 | limitPerRun: 30 45 | # Limit to only `issues` or `pulls` 46 | # only: issues 47 | 48 | # Optionally, specify configuration settings that are specific to just 'issues' or 'pulls': 49 | # pulls: 50 | # daysUntilStale: 30 51 | # markComment: > 52 | # This pull request has been automatically marked as stale because it has not had 53 | # recent activity. It will be closed if no further activity occurs. Thank you 54 | # for your contributions. 55 | 56 | # issues: 57 | # exemptLabels: 58 | # - confirmed 59 | -------------------------------------------------------------------------------- /.github/workflows/check.yml: -------------------------------------------------------------------------------- 1 | name: check 2 | 3 | on: 4 | push: 5 | branches: [main] 6 | pull_request: 7 | branches: [main] 8 | workflow_dispatch: 9 | 10 | jobs: 11 | check: 12 | strategy: 13 | matrix: 14 | os: [ubuntu-latest, windows-latest, macos-latest] 15 | node: [12.x, 14.x] 16 | 17 | runs-on: ${{ matrix.os }} 18 | 19 | steps: 20 | - uses: actions/checkout@v2 21 | 22 | - name: Use Node.js ${{ matrix.node }} 23 | uses: actions/setup-node@v1 24 | with: 25 | node-version: ${{ matrix.node }} 26 | 27 | - name: Cache dependencies 28 | uses: actions/cache@v2 29 | id: yarn-cache 30 | with: 31 | path: | 32 | **/node_modules 33 | key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} 34 | restore-keys: | 35 | ${{ runner.os }}-yarn- 36 | 37 | - name: Install dependencies 38 | if: steps.yarn-cache.outputs.cache-hit != 'true' 39 | run: yarn --frozen-lockfile 40 | 41 | - name: Lint 42 | run: yarn lint 43 | 44 | - name: Build 45 | run: yarn build 46 | 47 | - name: Test 48 | run: yarn test 49 | 50 | - name: Docs build 51 | run: yarn build:docs 52 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Dist files 2 | lib/ 3 | 4 | # Node modules 5 | node_modules/ 6 | 7 | # MacOS Desktop Services Store 8 | .DS_Store 9 | 10 | # Log files 11 | *.log 12 | 13 | # Typescript build info 14 | *.tsbuildinfo 15 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.insertSpaces": true, 3 | "editor.tabSize": 2, 4 | "files.encoding": "utf8", 5 | "files.eol": "\n", 6 | "files.trimFinalNewlines": true, 7 | "files.trimTrailingWhitespace": true, 8 | "[markdown]": { 9 | "files.trimTrailingWhitespace": false 10 | }, 11 | "eslint.validate": [ 12 | "javascript", 13 | "javascriptreact", 14 | "typescript", 15 | "typescriptreact", 16 | "vue" 17 | ], 18 | "vetur.validation.template": false, 19 | "cSpell.words": [ 20 | "frontmatter", 21 | "globby", 22 | "mathjax", 23 | "mergeable", 24 | "netlify", 25 | "nprogress", 26 | "prefetch", 27 | "preload", 28 | "redirector", 29 | "redirectors", 30 | "serializers", 31 | "vuepress", 32 | "zoomable" 33 | ] 34 | } 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2019-present VuePress Community 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | logo 4 | 5 |

6 | 7 |

8 | VuePress Community 9 |

10 | 11 |

12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 |

24 | 25 |

26 | Community supported ecosystem for VuePress 27 |

28 | 29 | ## Documentation 30 | 31 | [vuepress-community.netlify.app](https://vuepress-community.netlify.app) 32 | 33 | ## License 34 | 35 | [MIT](https://github.com/vuepress/vuepress-community/blob/main/LICENSE) © [VuePress Community](https://github.com/vuepress) 36 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | const { resolve } = require('path') 2 | const { readdirSync } = require('fs') 3 | 4 | const packages = readdirSync(resolve(__dirname, 'packages'), { 5 | withFileTypes: true, 6 | }) 7 | .filter(item => item.isDirectory()) 8 | .map(({ name }) => name) 9 | 10 | module.exports = { 11 | rootDir: resolve(__dirname), 12 | testEnvironment: 'node', 13 | preset: 'ts-jest', 14 | globals: { 15 | 'ts-jest': { 16 | tsConfig: '/tsconfig.json', 17 | }, 18 | }, 19 | moduleNameMapper: { 20 | [`^(${packages.join('|')})$`]: '/packages/$1', 21 | }, 22 | testMatch: ['/packages/*/test/**/*.spec.ts'], 23 | snapshotSerializers: [require.resolve('jest-serializer-vue')], 24 | 25 | // coverage config 26 | collectCoverageFrom: ['/packages/*/src/**/*.ts', '!**/*.d.ts'], 27 | coverageDirectory: 'coverage', 28 | } 29 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "npmClient": "yarn", 3 | "useWorkspaces": true, 4 | "version": "independent", 5 | "command": { 6 | "version": { 7 | "allowBranch": "main", 8 | "conventionalCommits": true, 9 | "exact": true, 10 | "ignoreChanges": ["**/*.md", "packages/docs/*"], 11 | "message": "build: publish" 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "workspaces": [ 4 | "packages/*" 5 | ], 6 | "scripts": { 7 | "build": "lerna run build --stream --ignore docs", 8 | "build:docs": "yarn workspace docs build", 9 | "dev": "yarn workspace docs dev --no-cache", 10 | "dev:docs": "yarn workspace docs dev", 11 | "postinstall": "yarn build", 12 | "lint": "eslint --ext .js,.ts,.vue packages", 13 | "release": "yarn lint && yarn build && yarn test && lerna publish", 14 | "serve": "yarn workspace docs serve", 15 | "test": "jest --runInBand" 16 | }, 17 | "husky": { 18 | "hooks": { 19 | "pre-commit": "lint-staged", 20 | "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" 21 | } 22 | }, 23 | "lint-staged": { 24 | "*.{js,ts,vue}": "eslint --fix", 25 | "*.{json,md,yml}": "prettier --write", 26 | "package.json": "sort-package-json" 27 | }, 28 | "prettier": "prettier-config-vuepress", 29 | "devDependencies": { 30 | "@commitlint/cli": "^9.1.2", 31 | "@commitlint/config-conventional": "^9.1.2", 32 | "@types/jest": "^24.0.18", 33 | "eslint": "^7.8.0", 34 | "eslint-config-vuepress": "^2.2.0", 35 | "eslint-config-vuepress-typescript": "^1.3.0", 36 | "husky": "^4.2.5", 37 | "jest": "^24.9.0", 38 | "jest-serializer-vue": "^2.0.2", 39 | "lerna": "^3.16.4", 40 | "lint-staged": "^10.2.2", 41 | "prettier": "^2.0.5", 42 | "prettier-config-vuepress": "^1.1.0", 43 | "rimraf": "^3.0.2", 44 | "sort-package-json": "^1.42.2", 45 | "ts-jest": "^24.1.0", 46 | "typescript": "^3.8.3", 47 | "vuepress": "^1.4.1" 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /packages/docs/.gitignore: -------------------------------------------------------------------------------- 1 | .temp/ 2 | dist/ 3 | -------------------------------------------------------------------------------- /packages/docs/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [1.0.12](https://github.com/vuepress/vuepress-community/compare/docs@1.0.11...docs@1.0.12) (2020-09-01) 7 | 8 | **Note:** Version bump only for package docs 9 | 10 | ## [1.0.11](https://github.com/vuepress/vuepress-community/compare/docs@1.0.10...docs@1.0.11) (2020-05-21) 11 | 12 | **Note:** Version bump only for package docs 13 | 14 | ## [1.0.10](https://github.com/vuepress/vuepress-community/compare/docs@1.0.9...docs@1.0.10) (2020-04-08) 15 | 16 | **Note:** Version bump only for package docs 17 | 18 | ## [1.0.9](https://github.com/vuepress/vuepress-community/compare/docs@1.0.8...docs@1.0.9) (2020-02-20) 19 | 20 | **Note:** Version bump only for package docs 21 | 22 | ## [1.0.8](https://github.com/vuepress/vuepress-community/compare/docs@1.0.7...docs@1.0.8) (2020-02-03) 23 | 24 | **Note:** Version bump only for package docs 25 | 26 | ## [1.0.7](https://github.com/vuepress/vuepress-community/compare/docs@1.0.6...docs@1.0.7) (2020-01-03) 27 | 28 | **Note:** Version bump only for package docs 29 | 30 | ## [1.0.6](https://github.com/vuepress/vuepress-community/compare/docs@1.0.5...docs@1.0.6) (2019-12-27) 31 | 32 | **Note:** Version bump only for package docs 33 | 34 | ## [1.0.5](https://github.com/vuepress/vuepress-community/compare/docs@1.0.4...docs@1.0.5) (2019-12-10) 35 | 36 | **Note:** Version bump only for package docs 37 | 38 | ## [1.0.4](https://github.com/vuepress/vuepress-community/compare/docs@1.0.3...docs@1.0.4) (2019-11-29) 39 | 40 | **Note:** Version bump only for package docs 41 | 42 | ## [1.0.3](https://github.com/vuepress/vuepress-community/compare/docs@1.0.2...docs@1.0.3) (2019-11-20) 43 | 44 | **Note:** Version bump only for package docs 45 | 46 | ## [1.0.2](https://github.com/vuepress/vuepress-community/compare/docs@1.0.1...docs@1.0.2) (2019-10-18) 47 | 48 | **Note:** Version bump only for package docs 49 | 50 | ## 1.0.1 (2019-10-12) 51 | 52 | **Note:** Version bump only for package docs 53 | -------------------------------------------------------------------------------- /packages/docs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "docs", 3 | "version": "1.0.12", 4 | "private": true, 5 | "scripts": { 6 | "build": "vuepress build src --temp .temp --dest dist", 7 | "dev": "vuepress dev src --temp .temp", 8 | "lint": "eslint --ext .js,.vue src/.vuepress", 9 | "serve": "vuepress serve src --dest dist" 10 | }, 11 | "eslintConfig": { 12 | "extends": "vuepress", 13 | "root": true 14 | }, 15 | "dependencies": { 16 | "@vuepress/plugin-back-to-top": "^1.3.0", 17 | "vuepress": "^1.3.0", 18 | "vuepress-plugin-clean-urls": "1.1.2", 19 | "vuepress-plugin-container": "2.1.5", 20 | "vuepress-plugin-copyright": "^1.0.2", 21 | "vuepress-plugin-git-log": "^1.0.1", 22 | "vuepress-plugin-mathjax": "^1.2.8", 23 | "vuepress-plugin-medium-zoom": "1.1.9", 24 | "vuepress-plugin-named-chunks": "1.1.4", 25 | "vuepress-plugin-redirect": "1.2.5", 26 | "vuepress-plugin-serve": "2.0.4", 27 | "vuepress-plugin-smooth-scroll": "0.0.10", 28 | "vuepress-plugin-table-of-contents": "1.1.7", 29 | "vuepress-plugin-typescript": "0.3.1", 30 | "vuepress-plugin-zooming": "1.1.8" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /packages/docs/src/.vuepress/components/GitHubLink.vue: -------------------------------------------------------------------------------- 1 | 18 | 19 | 33 | 34 | 50 | -------------------------------------------------------------------------------- /packages/docs/src/.vuepress/components/NpmLink.vue: -------------------------------------------------------------------------------- 1 | 15 | 16 | 30 | -------------------------------------------------------------------------------- /packages/docs/src/.vuepress/config.js: -------------------------------------------------------------------------------- 1 | const ecosystem = require('./ecosystem') 2 | 3 | module.exports = (context) => ({ 4 | head: [ 5 | ['link', { rel: 'icon', href: '/logo/600x600.png' }], 6 | ['meta', { name: 'theme-color', content: '#3eaf7c' }], 7 | ['meta', { name: 'apple-mobile-web-app-capable', content: 'yes' }], 8 | [ 9 | 'meta', 10 | { name: 'apple-mobile-web-app-status-bar-style', content: 'black' }, 11 | ], 12 | ['meta', { name: 'msapplication-TileColor', content: '#000000' }], 13 | ], 14 | 15 | plugins: [ 16 | ['@vuepress/back-to-top'], 17 | [ 18 | 'clean-urls', 19 | { 20 | normalSuffix: '/', 21 | indexSuffix: '/', 22 | notFoundPath: '/404.html', 23 | }, 24 | ], 25 | [ 26 | 'container', 27 | { 28 | type: 'right', 29 | defaultTitle: '', 30 | }, 31 | ], 32 | [ 33 | 'container', 34 | { 35 | type: 'theorem', 36 | before: (info) => `

${info}

`, 37 | after: '
', 38 | }, 39 | ], 40 | [ 41 | 'copyright', 42 | { 43 | disabled: true, 44 | authorName: { 45 | 'zh-CN': ' VuePress Community ', 46 | 'en-US': 'VuePress Community', 47 | }, 48 | }, 49 | ], 50 | ['git-log'], 51 | [ 52 | 'mathjax', 53 | { 54 | macros: { 55 | '\\Z': '\\mathbb{Z}', 56 | }, 57 | }, 58 | ], 59 | [ 60 | 'medium-zoom', 61 | { 62 | selector: '.theme-default-content img:not(.no-medium-zoom)', 63 | }, 64 | ], 65 | ['named-chunks'], 66 | [ 67 | 'redirect', 68 | { 69 | locales: true, 70 | }, 71 | ], 72 | ['serve'], 73 | ['smooth-scroll'], 74 | ['table-of-contents'], 75 | [ 76 | 'typescript', 77 | { 78 | tsLoaderOptions: { 79 | transpileOnly: true, 80 | }, 81 | }, 82 | ], 83 | [ 84 | 'zooming', 85 | { 86 | selector: '.theme-default-content img.zooming', 87 | }, 88 | ], 89 | ], 90 | 91 | locales: { 92 | '/en/': { 93 | lang: 'en-US', 94 | title: 'VuePress Community', 95 | description: 'Community supported ecosystem for VuePress', 96 | }, 97 | '/zh/': { 98 | lang: 'zh-CN', 99 | title: 'VuePress 社区', 100 | description: '社区维护的 VuePress 生态系统', 101 | }, 102 | }, 103 | 104 | themeConfig: { 105 | repo: 'vuepress/vuepress-community', 106 | editLinks: true, 107 | docsDir: 'packages/docs/src', 108 | locales: { 109 | '/en/': { 110 | label: 'English', 111 | selectText: 'Languages', 112 | editLinkText: 'Edit this page on GitHub', 113 | lastUpdated: 'Last Updated', 114 | }, 115 | '/zh/': { 116 | label: '简体中文', 117 | selectText: '选择语言', 118 | editLinkText: '在 GitHub 上编辑此页', 119 | lastUpdated: '上次更新', 120 | }, 121 | }, 122 | sidebar: { 123 | '/en/': getSidebar('Plugins', 'Themes', 'Tools'), 124 | '/zh/': getSidebar('插件', '主题', '工具'), 125 | }, 126 | }, 127 | 128 | evergreen: () => !context.isProd, 129 | }) 130 | 131 | const getSidebar = (plugins, themes, tools) => [ 132 | { 133 | title: plugins, 134 | collapsable: true, 135 | children: ecosystem.plugins.map((name) => `plugins/${name}`), 136 | }, 137 | { 138 | title: tools, 139 | collapsable: true, 140 | children: ecosystem.tools.map((name) => `tools/${name}`), 141 | }, 142 | ] 143 | -------------------------------------------------------------------------------- /packages/docs/src/.vuepress/ecosystem.js: -------------------------------------------------------------------------------- 1 | const ecosystem = { 2 | plugins: [ 3 | 'clean-urls', 4 | 'container', 5 | 'copyright', 6 | 'dehydrate', 7 | 'git-log', 8 | 'mathjax', 9 | 'medium-zoom', 10 | 'migrate', 11 | 'named-chunks', 12 | 'nprogress', 13 | 'redirect', 14 | 'serve', 15 | 'smooth-scroll', 16 | 'table-of-contents', 17 | 'typescript', 18 | 'zooming', 19 | ], 20 | themes: [], 21 | tools: ['mergeable', 'types'], 22 | } 23 | 24 | module.exports = ecosystem 25 | -------------------------------------------------------------------------------- /packages/docs/src/.vuepress/public/logo/600x600.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vuepress/vuepress-community/810f1f1068669b331e547c40205040e8ae4e4372/packages/docs/src/.vuepress/public/logo/600x600.png -------------------------------------------------------------------------------- /packages/docs/src/.vuepress/styles/container.styl: -------------------------------------------------------------------------------- 1 | // index.styl 2 | .theorem 3 | margin 1rem 0 4 | padding .1rem 1.5rem 5 | border-radius 0.4rem 6 | background-color #f0f4f8 7 | .title 8 | font-weight bold 9 | 10 | .custom-block 11 | &.right 12 | color transparentify($textColor, 0.4) 13 | font-size 0.9rem 14 | text-align right 15 | -------------------------------------------------------------------------------- /packages/docs/src/.vuepress/styles/content.styl: -------------------------------------------------------------------------------- 1 | .content 2 | th 3 | text-align center !important 4 | -------------------------------------------------------------------------------- /packages/docs/src/.vuepress/styles/index.styl: -------------------------------------------------------------------------------- 1 | @require './container' 2 | @require './content' 3 | @require './mathjax' 4 | -------------------------------------------------------------------------------- /packages/docs/src/.vuepress/styles/mathjax.styl: -------------------------------------------------------------------------------- 1 | $bdColor = #D6DBDF 2 | 3 | .math-block 4 | font-family inherit 5 | padding .1rem 1.5rem 6 | margin 1rem 0 7 | border-left .5rem solid $bdColor 8 | border-radius 0 !important 9 | background-color rgba(102, 128, 153, .05) !important 10 | color $textColor 11 | 12 | pre.math-block 13 | white-space pre-wrap 14 | 15 | mjx-container[display=true] 16 | &::-webkit-scrollbar 17 | width 1rem 18 | height 0.4rem 19 | 20 | &::-webkit-scrollbar-track 21 | background-color: transparent 22 | -webkit-box-shadow: transparent 23 | border-radius: 0.4rem 24 | 25 | &::-webkit-scrollbar-thumb 26 | background-color: lighten($bdColor, 20%) 27 | border-radius: 0.4rem 28 | 29 | &:hover 30 | &::-webkit-scrollbar-track 31 | background-color: mix($bdColor, transparent, 40%) 32 | -webkit-box-shadow: inset 0 0 0.2rem mix($bdColor, transparent, 80%) 33 | 34 | &::-webkit-scrollbar-thumb 35 | background-color: darken($bdColor, 10%) -------------------------------------------------------------------------------- /packages/docs/src/en/plugins/clean-urls.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebarDepth: 3 3 | --- 4 | 5 | # vuepress-plugin-clean-urls 6 | 7 | Provides support for clean urls in your VuePress site. 8 | 9 | ::: warning 10 | This plugin will always work on your dev server, but VuePress **does not have the right** to modify server identification. If you want your URLs to follow a certain pattern (e.g. `/routing` instead of `/routing.html` or `routing/`), you should make sure that your server would treat it as an HTML. This means that you may need to configure your server specifically. 11 | 12 | **References:** 13 | 14 | - For Netlify users: [https://www.netlify.com/docs/redirects/#trailing-slash](https://www.netlify.com/docs/redirects/#trailing-slash). 15 | - For Surge users: [https://surge.sh/help/using-clean-urls-automatically](https://surge.sh/help/using-clean-urls-automatically). 16 | 17 | ::: 18 | 19 | ## Installation 20 | 21 | ```sh 22 | npm install -D vuepress-plugin-clean-urls 23 | ``` 24 | 25 | ## Usage 26 | 27 | ```js 28 | // .vuepress/config.js 29 | module.exports = { 30 | plugins: [ 31 | [ 32 | 'vuepress-plugin-clean-urls', 33 | { 34 | normalSuffix: '/', 35 | indexSuffix: '/', 36 | notFoundPath: '/404.html', 37 | }, 38 | ], 39 | ], 40 | } 41 | ``` 42 | 43 | ## Configs 44 | 45 | ### normalSuffix 46 | 47 | - **type:** `string` 48 | - **default:** `'/'` 49 | 50 | The suffix for normal pages. For example, `foo/bar.md` will become: 51 | 52 | - `foo/bar.html` by default (without this plugin) 53 | - `foo/bar/` (with `normalSuffix` set to `'/'`) 54 | - `foo/bar` (with `normalSuffix` set to `''`) 55 | 56 | ### indexSuffix 57 | 58 | - **type:** `string` 59 | - **default:** `'/'` 60 | 61 | The suffix for index pages. For example, `foo/index.md` will become: 62 | 63 | - `foo/` by default (without this plugin) 64 | - `foo` (with `indexSuffix` set to `''`) 65 | - `foo/index.html` (with `indexSuffix` set to `'/index.html'`) 66 | 67 | ::: tip 68 | An index page is a page with a file name of `index.md` or `readme.md` (case insensitive). 69 | ::: 70 | 71 | ### notFoundPath 72 | 73 | - **type:** `string` 74 | - **default:** `'/404.html'` 75 | 76 | URL for "404 not found" page. 77 | -------------------------------------------------------------------------------- /packages/docs/src/en/plugins/copyright.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebarDepth: 3 3 | copyright: 4 | minLength: 40 5 | --- 6 | 7 | # vuepress-plugin-copyright 8 | 9 | Handles copy behaviors in your VuePress site. 10 | 11 | ## Installation 12 | 13 | ```sh 14 | npm install -D vuepress-plugin-copyright 15 | ``` 16 | 17 | ## Usage 18 | 19 | ```js 20 | // .vuepress/config.js 21 | module.exports = { 22 | plugins: [ 23 | [ 24 | 'vuepress-plugin-copyright', 25 | { 26 | noCopy: true, // the selected text will be uncopiable 27 | minLength: 100, // if its length is greater than 100 28 | }, 29 | ], 30 | ], 31 | } 32 | ``` 33 | 34 | ### Use Frontmatter 35 | 36 | You can enable or disable this plugin for the current page in frontmatter: 37 | 38 | ```yaml 39 | --- 40 | copyright: false # disable the plugin in this page 41 | --- 42 | 43 | ``` 44 | 45 | You can also do some local configuration: 46 | 47 | ```yaml 48 | --- 49 | # This is the frontmatter of the current page. 50 | copyright: 51 | minLength: 40 # It will override global configuration. 52 | --- 53 | 54 | ``` 55 | 56 | You can see the effect of the plugin in the textarea below: 57 | 58 | 59 | 60 | 66 | 67 | ### Custom Clipboard 68 | 69 | You can customize your clipboard with [`clipboardComponent`](#clipboardcomponent). Here is a simple example: 70 | 71 | ```vue 72 | 81 | 82 | 91 | ``` 92 | 93 | ## Configs 94 | 95 | Options marked with are also allowed in [frontmatter](#frontmatter). Options marked with only take effect when the default clipboard component is used. 96 | 97 | ### disabled 98 | 99 | - **type:** `boolean` 100 | - **default:** `false` 101 | 102 | Whether to disable this plugin by default. 103 | 104 | ### noCopy 105 | 106 | - **type:** `boolean` 107 | - **default:** `false` 108 | 109 | Whether to prohibit copying. 110 | 111 | ### noSelect 112 | 113 | - **type:** `boolean` 114 | - **default:** `false` 115 | 116 | Whether to prohibit selecting. 117 | 118 | ### minLength 119 | 120 | - **type:** `number` 121 | - **default:** `0` 122 | 123 | The minimum text length that triggers the clipboard component or the [`noCopy`](#nocopy) effect. 124 | 125 | ### authorName 126 | 127 | - **type:** `string | Record` 128 | - **default:** `'Author'` 129 | 130 | Author name. You can provide a string or an i18n object, for example: 131 | 132 | ```json 133 | { 134 | "en-US": "Author", 135 | "zh-CN": "作者" 136 | } 137 | ``` 138 | 139 | ### clipboardComponent 140 | 141 | - **type:** `string` 142 | - **default:** `undefined` 143 | 144 | The path to the [custom clipboard](#custom-clipboard) component. If a relative path is specified, it will be resolved based on `sourceDir`. 145 | -------------------------------------------------------------------------------- /packages/docs/src/en/plugins/git-log.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebarDepth: 3 3 | --- 4 | 5 | # vuepress-plugin-git-log 6 | 7 | Integrates git logs into your page of VuePress site. 8 | 9 | ## Installation 10 | 11 | ```sh 12 | npm install -D vuepress-plugin-git-log 13 | ``` 14 | 15 | ## Usage 16 | 17 | ```js 18 | // .vuepress/config.js 19 | module.exports = { 20 | plugins: [ 21 | [ 22 | 'vuepress-plugin-git-log', 23 | { 24 | additionalArgs: '--no-merge', 25 | onlyFirstAndLastCommit: true, 26 | }, 27 | ], 28 | ], 29 | } 30 | ``` 31 | 32 | ## Configs 33 | 34 | ### formatTime 35 | 36 | - **type:** `(timestamp: number, lang: string) => string` 37 | - **default:** `(timestamp, lang) => new Date(timestamp).toLocaleString(lang)` 38 | 39 | A function used to format Unix time. 40 | 41 | ### additionalProps 42 | 43 | - **type:** `{ [prop: string]: string }` 44 | - **default:** `{}` 45 | 46 | An object that represents additional properties. Every key is a property name and value is the corresponding [placeholder](https://git-scm.com/docs/git-log#_pretty_formats). 47 | 48 | ### additionalArgs 49 | 50 | - **type:** `string | string[]` 51 | - **default:** `[]` 52 | 53 | A list of additional parameters to pass in. 54 | 55 | ### extendGitLog 56 | 57 | - **type:** `(git: object) => void` 58 | - **default:** `undefined` 59 | 60 | A function used to extend or modify the [`$page.git`](#api) object. 61 | 62 | ### onlyFirstAndLastCommit 63 | 64 | - **type:** `boolean` 65 | - **default:** `false` 66 | 67 | Whether to search for only the first and last commit. Set this option to `true` for large-scale projects may optimize the initial startup performance. However, you will not be able to use `$page.git.commits` and `$page.git.contributors` as a cost. 68 | 69 | ## API 70 | 71 | This plugin will add a `git` property to `$page`, with the following properties: 72 | 73 | ### git.author 74 | 75 | The author of the article, i.e. the author of the first commit. 76 | 77 | ### git.created 78 | 79 | The time the article was created, i.e. the authoring time of the first commit. 80 | 81 | ### git.updated 82 | 83 | The time the article was updated, i.e. the committing time of the last commit. 84 | 85 | ### git.commits 86 | 87 | A list of all the commits in chronological order. 88 | 89 | ### git.contributors 90 | 91 | A list of contributors to all users who have modified the article. 92 | 93 | ## Demo 94 | 95 | **Input** 96 | 97 | ```md 98 | - Author of this page: {{ $page.git.author }} 99 | - Contributors of this page: {{ $page.git.contributors.join(', ') }} 100 | - Last commit of this page: {{ $page.git.commits[0].fullHash }} 101 | ``` 102 | 103 | **Output** 104 | 105 | - Author of this page: {{ $page.git.author }} 106 | - Contributors of this page: {{ $page.git.contributors.join(', ') }} 107 | - Last commit of this page: {{ $page.git.commits[0].fullHash }} 108 | -------------------------------------------------------------------------------- /packages/docs/src/en/plugins/medium-zoom.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebarDepth: 3 3 | --- 4 | 5 | # vuepress-plugin-medium-zoom 6 | 7 | Use [medium-zoom](https://github.com/francoischalifour/medium-zoom) in your VuePress site. 8 | 9 | This plugin will make your images zoomable. 10 | 11 | ## Installation 12 | 13 | ```sh 14 | npm install -D vuepress-plugin-medium-zoom 15 | ``` 16 | 17 | ## Usage 18 | 19 | ```js 20 | // .vuepress/config.js 21 | module.exports = { 22 | plugins: [ 23 | [ 24 | 'vuepress-plugin-medium-zoom', 25 | { 26 | selector: '.my-wrapper .my-img', 27 | delay: 1000, 28 | options: { 29 | margin: 24, 30 | background: '#BADA55', 31 | scrollOffset: 0, 32 | }, 33 | }, 34 | ], 35 | ], 36 | } 37 | ``` 38 | 39 | Change the default `z-index` of the `medium-zoom-overlay` in `palette.styl`: 40 | 41 | > See [official docs](https://vuepress.vuejs.org/config/#palette-styl) 42 | 43 | ```stylus 44 | // default: 100 45 | $mediumZoomZIndex = 10000 46 | ``` 47 | 48 | ## Configs 49 | 50 | ### selector 51 | 52 | - **type:** `string` 53 | - **default:** `'.theme-default-content img'` 54 | 55 | Selector for zoomable image elements. 56 | 57 | ### delay 58 | 59 | - **type:** `number` 60 | - **default:** `500` 61 | 62 | Make images zoomable with delay after entering a page. 63 | 64 | ### options 65 | 66 | - **type:** `Object` 67 | - **default:** `{}` 68 | 69 | Options of medium-zoom. 70 | 71 | > See the [docs of medium-zoom](https://github.com/francoischalifour/medium-zoom#options) for all available `options`. 72 | 73 | ## Advanced usage 74 | 75 | Update zoomable images manually in your components: 76 | 77 | ```js 78 | // SomeComponent.vue 79 | export default { 80 | methods: { 81 | updateImages() { 82 | // do something to update images in this page 83 | this.$nextTick(() => { 84 | // update mediumZoom immediately 85 | this.$vuepress.mediumZoom.update() // with default selector 86 | this.$vuepress.mediumZoom.update('.new-images') // with custom selector 87 | 88 | // update mediumZoom with delay 89 | this.$vuepress.mediumZoom.updateDelay() // with default selector and delay 90 | this.$vuepress.mediumZoom.updateDelay('.new-images') // with custom selector and default delay 91 | this.$vuepress.mediumZoom.updateDelay('.new-images', 1000) // with custom selector and delay 92 | }) 93 | }, 94 | }, 95 | } 96 | ``` 97 | 98 | Get the `mediumZoom` instance directly in your components: 99 | 100 | > See the [docs of medium-zoom](https://github.com/francoischalifour/medium-zoom#methods) for all available methods. 101 | 102 | ```js 103 | // SomeComponent.vue 104 | export default { 105 | methods: { 106 | openImages() { 107 | // get the mediumZoom instance 108 | const zoom = this.$vuepress.mediumZoom.instance 109 | 110 | // call the instance methods 111 | zoom.open() 112 | }, 113 | }, 114 | } 115 | ``` 116 | 117 | ## Demo 118 | 119 | Click the image: 120 | 121 | demo 122 | -------------------------------------------------------------------------------- /packages/docs/src/en/plugins/migrate.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebarDepth: 3 3 | --- 4 | 5 | # vuepress-plugin-migrate 6 | 7 | Migrate a website to VuePress. 8 | 9 | ## Installation 10 | 11 | ```sh 12 | npm install -D vuepress-plugin-migrate 13 | ``` 14 | 15 | ## Usage 16 | 17 | ```js 18 | // .vuepress/config.js 19 | module.exports = { 20 | plugins: [ 21 | [ 22 | 'vuepress-plugin-migrate', 23 | { 24 | targetDir: '_posts', 25 | downloadDir: '.vuepress/downloads', 26 | }, 27 | ], 28 | ], 29 | } 30 | ``` 31 | 32 | ## Configs 33 | 34 | ### targetDir 35 | 36 | - **type:** `string` 37 | - **default:** `'_posts'` 38 | 39 | The directory for generated markdown files. 40 | 41 | ### downloadDir 42 | 43 | - **type:** `string` 44 | - **default:** `'.vuepress/downloads'` 45 | 46 | The directory for downloaded HTMLs. 47 | 48 | ### maxConcurrentTasks 49 | 50 | - **type:** `number` 51 | - **default:** `10` 52 | 53 | The maximum number of concurrent downloads allowed. 54 | 55 | ### forceDownload 56 | 57 | - **type:** `boolean` 58 | - **default:** `false` 59 | 60 | Whether to force download a `.html` file when it already exists. 61 | 62 | ### forceConvert 63 | 64 | - **type:** `boolean` 65 | - **default:** `false` 66 | 67 | Whether to force overwrite a `.md` when it already exists. 68 | 69 | ### sitemap 70 | 71 | - **type:** `string` 72 | - **default:** `undefined` 73 | 74 | The sitemap URL for the source website. 75 | 76 | ### getFileName 77 | 78 | - **type:** `(url: string) => string` 79 | - **default:** `url => String(++index)` 80 | 81 | The name of the file to save as. If a falsy value is returned, the corresponding file is not downloaded. 82 | 83 | ### parseHTML 84 | 85 | - **type:** `($: CheerioElement, render: ($: CheerioElement) => string) => ParsedResult` 86 | - **default:** `undefined` 87 | 88 | Generates a function corresponding to the `ParsedResult` object from the crawled HTML. A `ParsedResult` is an object with the following properties: 89 | 90 | ```ts 91 | interface ParsedResult { 92 | frontmatter?: any 93 | filename?: string 94 | content?: string 95 | } 96 | ``` 97 | 98 | ## CLI 99 | 100 | ### General options 101 | 102 | These options will take effect in any of the commands. 103 | 104 | ### --detail 105 | 106 | Show detailed informations when an error is encounted. 107 | 108 | ### -f, --forced 109 | 110 | Equivalent to setting [forceDownload](#forceDownload) and [forceConvert](#forceConvert) to `true`. 111 | 112 | ### vuepress download 113 | 114 | Crawl the required pages from the source site and store them in a local folder. 115 | 116 | ### -s, --sitemap `` 117 | 118 | See [sitemap](#sitemap). 119 | 120 | ### vuepress convert 121 | 122 | Convert local HTML files to a markdown files and output them. 123 | 124 | ### -t, --target `` 125 | 126 | See [targetDir](#targetDir). 127 | 128 | ### vuepress migrate 129 | 130 | Execute download and convert command in sequence. Supports parameters of both commands. 131 | -------------------------------------------------------------------------------- /packages/docs/src/en/plugins/named-chunks.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebarDepth: 3 3 | --- 4 | 5 | # vuepress-plugin-named-chunks 6 | 7 | Generate named chunks for your VuePress site. 8 | 9 | VuePress uses [dynamic import](https://webpack.js.org/guides/code-splitting/#dynamic-imports) to load page components and layout components. Each component becomes a separate chunk, but their names are automatically generated, which is not conducive to subsequent tracking. This plugin is for generating named chunks. 10 | 11 | ## Installation 12 | 13 | ```sh 14 | npm install -D vuepress-plugin-named-chunks 15 | ``` 16 | 17 | ## Usage 18 | 19 | ```js 20 | // .vuepress/config.js 21 | module.exports = { 22 | plugins: [ 23 | [ 24 | 'named-chunks', 25 | { 26 | pageChunkName: page => 'page' + page.key.slice(1), 27 | layoutChunkName: layout => 'layout-' + layout.componentName, 28 | }, 29 | ], 30 | ], 31 | } 32 | ``` 33 | 34 | ## Configs 35 | 36 | ### pageChunkName 37 | 38 | - **type:** `((page: Page) => string) | false` 39 | - **default:** `({ key }) => 'page' + key.slice(1)` 40 | 41 | A function that generates chunk name from `Page` object. 42 | 43 | ### layoutChunkName 44 | 45 | - **type:** `((layout: ResolvedComponent) => string) | false` 46 | - **default:** `false` 47 | 48 | A function that generates chunk name from `ResolvedComponent` object. 49 | 50 | ## API 51 | 52 | This plugin will inject some properties into [context API](https://vuepress.vuejs.org/plugin/context-api.html). 53 | 54 | ### chunk name of a page component 55 | 56 | 1. `context.pages` is an array of `Page` objects. 57 | 2. `page._chunkName` is the chunk name of the page component. 58 | 59 | ### chunk name of a layout component 60 | 61 | 1. `context.themeAPI.layoutComponentMap` is a map of `ResolvedComponent` objects. 62 | 2. `layout._chunkName` is the chunk name of the layout component. 63 | -------------------------------------------------------------------------------- /packages/docs/src/en/plugins/nprogress.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebarDepth: 3 3 | --- 4 | 5 | # vuepress-plugin-nprogress 6 | 7 | Use [nprogress](https://github.com/rstacruz/nprogress) in your VuePress site. 8 | 9 | This plugin will show progress bar on the top when navigating to another page. 10 | 11 | ## Installation 12 | 13 | ```sh 14 | npm install -D vuepress-plugin-nprogress 15 | ``` 16 | 17 | ## Usage 18 | 19 | ```js 20 | // .vuepress/config.js 21 | module.exports = { 22 | plugins: ['vuepress-plugin-nprogress'], 23 | } 24 | ``` 25 | 26 | ## Custom color 27 | 28 | Set `$nprogressColor` in `palette.styl` file to change the color of the progress bar. If not set, the color is set to `$accentColor` of VuePress. 29 | 30 | > See [official docs](https://vuepress.vuejs.org/config/#palette-styl) 31 | 32 | ```stylus 33 | $nprogressColor = red 34 | 35 | // by default: 36 | // $nprogressColor ?= $accentColor 37 | ``` 38 | -------------------------------------------------------------------------------- /packages/docs/src/en/plugins/serve.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebarDepth: 3 3 | --- 4 | 5 | # vuepress-plugin-serve 6 | 7 | Serve generated files of your VuePress site locally. 8 | 9 | ## Installation 10 | 11 | ```sh 12 | npm install -D vuepress-plugin-serve 13 | ``` 14 | 15 | ## Usage 16 | 17 | ```js 18 | // .vuepress/config.js 19 | module.exports = { 20 | plugins: [ 21 | [ 22 | 'vuepress-plugin-serve', 23 | { 24 | post: 1234, 25 | staticOptions: { 26 | dotfiles: 'allow', 27 | }, 28 | beforeServer(app, server) { 29 | app.get('/path/to/my/custom', function(req, res) { 30 | res.json({ custom: 'response' }) 31 | }) 32 | }, 33 | }, 34 | ], 35 | ], 36 | } 37 | ``` 38 | 39 | ## Configs 40 | 41 | ### commandName 42 | 43 | - **type:** `string` 44 | - **default:** `'serve'` 45 | 46 | vuepress-plugin-serve will add a vuepress command. This option can be used to specify the command name. 47 | 48 | ### host 49 | 50 | - **type:** `string` 51 | - **default:** `siteConfig.host || 'localhost'` 52 | 53 | Specify the host to use for the server. 54 | 55 | ### port 56 | 57 | - **type:** `number` 58 | - **default:** `siteConfig.port || 8080` 59 | 60 | Specify the port to use for the server. 61 | 62 | ### notFoundPath 63 | 64 | - **type:** `string` 65 | - **default:** `'404.html'` 66 | 67 | Path for "404 not found" page (relative to `dest` path). 68 | 69 | ### staticOptions 70 | 71 | - **type:** `object` 72 | - **default:** `{}` 73 | 74 | Options for [serve-static](https://github.com/expressjs/serve-static#servestaticroot-options). 75 | 76 | ### beforeServer 77 | 78 | - **type:** `(app, server) => void | Promise` 79 | - **default:** `undefined` 80 | 81 | Executed before the server accepts client information. Similar to VuePress's [beforeDevServer](https://vuepress.vuejs.org/en/plugin/option-api.html#beforedevserver) option. 82 | 83 | ### afterServer 84 | 85 | - **type:** `async (app, server) => void | Promise` 86 | - **default:** `undefined` 87 | 88 | Executed after the server accepts client information. Similar to VuePress's [afterDevServer](https://vuepress.vuejs.org/en/plugin/option-api.html#afterdevserver) option. 89 | 90 | ## CLI 91 | 92 | After using this plugin, VuePress will add a `serve` command. This command will created a server based on the generated files. It has the following options: 93 | 94 | ### --build 95 | 96 | Execute `vuepress build` before creating the server. 97 | 98 | ### --open 99 | 100 | Open the browser when the server is ready. 101 | 102 | ### --host `` 103 | 104 | See [host](#host). 105 | 106 | ### --port `` 107 | 108 | See [port](#port). 109 | 110 | ::: tip 111 | VuePress built-in command line options (such as `--dest `, `--cache [cache]`, `--no-cache`) are also supported. 112 | ::: 113 | -------------------------------------------------------------------------------- /packages/docs/src/en/plugins/smooth-scroll.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebarDepth: 3 3 | --- 4 | 5 | # vuepress-plugin-smooth-scroll 6 | 7 | Make scrolling smooth in your VuePress site. 8 | 9 | ## Installation 10 | 11 | ```sh 12 | npm install -D vuepress-plugin-smooth-scroll 13 | ``` 14 | 15 | ## Usage 16 | 17 | ### Use this plugin 18 | 19 | ```js 20 | // .vuepress/config.js 21 | module.exports = { 22 | plugins: ['vuepress-plugin-smooth-scroll'], 23 | } 24 | ``` 25 | 26 | ## Details 27 | 28 | This plugin simply does two things: 29 | 30 | 1. Use `window.scrollTo({ behavior: 'smooth' })` for [scrollBehavior](https://router.vuejs.org/api/#scrollbehavior) 31 | 32 | - [Reference](https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollTo) 33 | - [Browser compatibility](https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollTo#Browser_Compatibility) 34 | - [smoothscroll-polyfill](https://github.com/iamdustan/smoothscroll) 35 | 36 | 2. Add `scroll-behavior: smooth;` to the `` element 37 | 38 | - [Reference](https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-behavior) 39 | - [Browser compatibility](https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-behavior#Browser_compatibility) 40 | 41 | ::: tip 42 | 43 | - The first one only works with `` 44 | - The second one works with both `` and `` 45 | 46 | You may notice that the browser compatibility of this two features are quite different, so we currently use both of them. 47 | 48 | For better browser compatibility, we suggest to use `` in your markdown file if possible. 49 | ::: 50 | 51 | ## Demo 52 | 53 | - Click the links in the sidebar 54 | - Click the header anchors 55 | 56 | ``` 57 | 58 | 59 | This 60 | 61 | 62 | 63 | is 64 | 65 | 66 | 67 | used 68 | 69 | 70 | 71 | to 72 | 73 | 74 | 75 | make 76 | 77 | 78 | 79 | the 80 | 81 | 82 | 83 | page 84 | 85 | 86 | 87 | longer 88 | 89 | 90 | ``` 91 | 92 | ### End of the page 93 | -------------------------------------------------------------------------------- /packages/docs/src/en/plugins/table-of-contents.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebarDepth: 3 3 | --- 4 | 5 | # vuepress-plugin-table-of-contents 6 | 7 | Add table-of-contents component for your VuePress site. 8 | 9 | ## Installation 10 | 11 | ```sh 12 | npm install -D vuepress-plugin-table-of-contents 13 | ``` 14 | 15 | ## Usage 16 | 17 | ```js 18 | // .vuepress/config.js 19 | module.exports = { 20 | plugins: ['vuepress-plugin-table-of-contents'], 21 | } 22 | ``` 23 | 24 | This plugin will register a `` component for you, which will render the table-of-contents of current page. You can use it in your markdown and vue files. 25 | 26 | ```md 27 | 28 | 29 | 30 | ``` 31 | 32 | ## Configs 33 | 34 | ### componentName 35 | 36 | - **type:** `string` 37 | - **default:** `'TOC'` 38 | 39 | Name of the table-of-contents component. 40 | 41 | ## Component Props 42 | 43 | ### includeLevel 44 | 45 | - **type:** `[number, number]` 46 | - **default:** `[2, 3]` 47 | 48 | The level of title to be included in `` component. 49 | 50 | For example, `[2, 4]` means 2 <= x <= 4. 51 | 52 | ## Demo 53 | 54 | **Input** 55 | 56 | ```md 57 | 58 | ``` 59 | 60 | **Output** 61 | 62 | 63 | 64 | **Input** 65 | 66 | ```md 67 | 68 | ``` 69 | 70 | **Output** 71 | 72 | 73 | 74 | ## Differences from VuePress markdown toc syntax 75 | 76 | You may notice that VuePress also provides a [markdown syntax `[[toc]]`](https://vuepress.vuejs.org/guide/markdown.html#table-of-contents) for table-of-contents. 77 | 78 | However, `[[toc]]` can only be used in `.md` files as it's a markdown syntax. But `` can be used in both `.md` files and `.vue` files, as it's a Vue component. 79 | 80 | Thus, `` is more convenient if you need table-of-contents in other part of your VuePress site (e.g. build your own theme with a table-of-contents component). 81 | -------------------------------------------------------------------------------- /packages/docs/src/en/plugins/typescript.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebarDepth: 3 3 | --- 4 | 5 | # vuepress-plugin-typescript 6 | 7 | ## Installation 8 | 9 | ```sh 10 | npm install -D vuepress-plugin-typescript typescript 11 | ``` 12 | 13 | ## Usage 14 | 15 | ```js 16 | // .vuepress/config.js 17 | module.exports = { 18 | plugins: [ 19 | [ 20 | 'vuepress-plugin-typescript', 21 | { 22 | tsLoaderOptions: { 23 | // All options of ts-loader 24 | }, 25 | }, 26 | ], 27 | ], 28 | } 29 | ``` 30 | 31 | ## Configs 32 | 33 | ### tsLoaderOptions 34 | 35 | - **type:** `Object` 36 | - **default:** `{}` 37 | 38 | Loader Options of `ts-loader`. See [docs of ts-loader](https://github.com/TypeStrong/ts-loader#loader-options) 39 | 40 | ## Supported Features 41 | 42 | ### TS in Markdown 43 | 44 | As we know, with the power of VuePress, we can [write Vue in Markdown](https://vuepress.vuejs.org/guide/using-vue.html). 45 | 46 | This plugin allows you to write Vue in TypeScript in Markdown. 47 | 48 | **Input** 49 | 50 | ```md 51 | {{ msg }} 52 | 53 | 62 | ``` 63 | 64 | **Output** 65 | 66 | {{ msg }} 67 | 68 | 77 | 78 | ### TS in Vue SFC 79 | 80 | This plugins allows you to write `.vue` files in TypeScript, including: 81 | 82 | - Auto registered global components: [.vuepress/components/\*.vue](https://vuepress.vuejs.org/guide/directory-structure.html) 83 | - Theme layout components: [theme/layouts/\*.vue](https://vuepress.vuejs.org/theme/writing-a-theme.html#layout-component) 84 | - Other components that you want to use in VuePress 85 | 86 | > See the [source code](https://github.com/vuepress/vuepress-community/tree/main/packages/docs/src/.vuepress/components) of this docs. 87 | 88 | ### enhanceApp.ts 89 | 90 | VuePress supports [App Level Enhancements](https://vuepress.vuejs.org/guide/basic-config.html#app-level-enhancements) by `.vuepress/enhanceApp.js` / `theme/enhanceApp.js`. 91 | 92 | This plugin allows you to use `enhanceApp.ts` instead of `enhanceApp.js`. 93 | 94 | > See the [test cases](https://github.com/vuepress/vuepress-community/blob/main/packages/vuepress-plugin-typescript/test/e2e/docs/.vuepress/theme/enhanceApp.ts) of this plugin. 95 | 96 | ::: warning 97 | Remember to create `.vuepress/shims-vue.d.ts` file if you want to import `.vue` files in your `enhanceApp.ts` or other `.ts` files: 98 | 99 | ```ts 100 | // .vuepress/shims-vue.d.ts 101 | declare module '*.vue' { 102 | import Vue from 'vue' 103 | export default Vue 104 | } 105 | ``` 106 | 107 | ::: 108 | 109 | ## Types Definitions 110 | 111 | You might meet some problems about the types of VuePress, e.g. missing the types definition of `this.$themeConfig`. 112 | 113 | If you want to get the right types definition, you can try to use [vuepress-types](../tools/types.md). 114 | -------------------------------------------------------------------------------- /packages/docs/src/en/plugins/zooming.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebarDepth: 3 3 | --- 4 | 5 | # vuepress-plugin-zooming 6 | 7 | Use [zooming](https://github.com/kingdido999/zooming) in your VuePress site. 8 | 9 | This plugin will make your images zoomable. 10 | 11 | ## Installation 12 | 13 | ```sh 14 | npm install -D vuepress-plugin-zooming 15 | ``` 16 | 17 | ## Usage 18 | 19 | ```js 20 | // .vuepress/config.js 21 | module.exports = { 22 | plugins: [ 23 | [ 24 | 'vuepress-plugin-zooming', 25 | { 26 | selector: '.my-wrapper .my-img', 27 | delay: 1000, 28 | options: { 29 | bgColor: 'black', 30 | zIndex: 10000, 31 | }, 32 | }, 33 | ], 34 | ], 35 | } 36 | ``` 37 | 38 | ## Configs 39 | 40 | ### selector 41 | 42 | - **type:** `string` 43 | - **default:** `'.theme-default-content img'` 44 | 45 | Selector for zoomable image elements. 46 | 47 | ### delay 48 | 49 | - **type:** `number` 50 | - **default:** `500` 51 | 52 | Make imgaes zoomable with delay after entering a page. 53 | 54 | ### options 55 | 56 | - **type:** `Object` 57 | - **default:** `{}` 58 | 59 | Options of zooming. 60 | 61 | > See the [docs of zooming](https://desmonding.me/zooming/docs/#/configuration?id=options) for all available `options`. 62 | 63 | ## Advanced usage 64 | 65 | Update zoomable images manually in your components: 66 | 67 | ```js 68 | // SomeComponent.vue 69 | export default { 70 | methods: { 71 | updateImages() { 72 | // do something to update images in this page 73 | this.$nextTick(() => { 74 | // update zooming immediately 75 | this.$vuepress.zooming.update() // with default selector 76 | this.$vuepress.zooming.update('.new-images') // with custom selector 77 | 78 | // update zooming with delay 79 | this.$vuepress.zooming.updateDelay() // with default selector and delay 80 | this.$vuepress.zooming.updateDelay('.new-images') // with custom selector and default delay 81 | this.$vuepress.zooming.updateDelay('.new-images', 1000) // with custom selector and delay 82 | }) 83 | }, 84 | }, 85 | } 86 | ``` 87 | 88 | Get the `Zooming` instance directly in your components: 89 | 90 | > See the [docs of zooming](https://desmonding.me/zooming/docs/#/api-reference) for all available methods. 91 | 92 | ```js 93 | // SomeComponent.vue 94 | export default { 95 | methods: { 96 | openImages() { 97 | // get the Zooming instance 98 | const zooming = this.$vuepress.zooming.instance 99 | 100 | // call the instance methods 101 | zooming.open(img) 102 | }, 103 | }, 104 | } 105 | ``` 106 | 107 | ## Demo 108 | 109 | Click the image: 110 | 111 | demo 112 | -------------------------------------------------------------------------------- /packages/docs/src/en/tools/types.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebarDepth: 3 3 | --- 4 | 5 | # vuepress-types 6 | 7 | Currently VuePress does not support typescript, and does not provide types definition. 8 | 9 | [vuepress-plugin-typescript](../plugins/typescript.md) provides part of the ability to use typescript in VuePress. If you want to get the correct types definition, you can try to use `vuepress-types` together. 10 | 11 | ::: warning EXPERIMENTAL 12 | `vuepress-types` is an experimental package for VuePress types definition. Feel free to open an issue if you find it does not work as expected. 13 | ::: 14 | 15 | ## Installation 16 | 17 | ```sh 18 | npm install -D vuepress-types 19 | ``` 20 | 21 | ## Usage 22 | 23 | You can choose **ONE OF** the following approaches to use it: 24 | 25 | ### Import it manually 26 | 27 | You can import it manually in your `.vue` files: 28 | 29 | ```vue {2} 30 | 42 | ``` 43 | 44 | ### Add it to tsconfig 45 | 46 | You can add it to the `compilerOptions.types` of your `tsconfig.json`: 47 | 48 | > See [docs of `tsconfig.json`](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html#types-typeroots-and-types) 49 | 50 | ```json {3} 51 | { 52 | "compilerOptions": { 53 | "types": ["vuepress-types"] 54 | } 55 | } 56 | ``` 57 | -------------------------------------------------------------------------------- /packages/docs/src/zh/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar: false 3 | --- 4 | 5 | # VuePress 社区 6 | 7 | 社区维护的 VuePress 生态系统。 8 | 9 | ## 插件 10 | 11 | | 名称 | 版本 | 介绍 | 12 | | :-------------------------------------------------: | :------------------------------------------------: | :------------------------------------------- | 13 | | [clean-urls](./plugins/clean-urls.md) | | :droplet: 在 VuePress 中使用简洁链接 | 14 | | [container](./plugins/container.md) | | :package: 在 VuePress 中使用 markdown 容器 | 15 | | [copyright](./plugins/copyright.md) | | :clipboard: 处理 VuePress 中的复制操作 | 16 | | [dehydrate](./plugins/dehydrate.md) | | :fire: 修改 VuePress 生成的 HTML 文件 | 17 | | [git-log](./plugins/git-log.md) | | :floppy_disk: 在 VuePress 中集成 git 日志 | 18 | | [mathjax](./plugins/mathjax.md) | | :page_with_curl: 在 VuePress 中使用 TeX 语法 | 19 | | [medium-zoom](./plugins/medium-zoom.md) | | :mag: 使 VuePress 中的图片支持缩放 | 20 | | [migrate](./plugins/migrate.md) | | :paw_prints: 从其他网站迁移到 VuePress | 21 | | [named-chunks](./plugins/named-chunks.md) | | :name_badge: 在 VuePress 中使用命名模块 | 22 | | [nprogress](./plugins/nprogress.md) | | :running: 在 VuePress 中显示页面进度条 | 23 | | [redirect](./plugins/redirect.md) | | :traffic_light: 处理 VuePress 中的重定向问题 | 24 | | [serve](./plugins/serve.md) | | :key: 在本地构建静态 VuePress 服务器 | 25 | | [smooth-scroll](./plugins/smooth-scroll.md) | | :roller_coaster: 在 VuePress 中使用平滑滚动 | 26 | | [table-of-contents](./plugins/table-of-contents.md) | | :bookmark: 为 VuePress 提供目录组件 | 27 | | [typescript](./plugins/typescript.md) | | :palm_tree: 在 VuePress 中支持 TypeScript | 28 | | [zooming](./plugins/zooming.md) | | :mag: 使 VuePress 中的图片支持缩放 | 29 | 30 | ## 工具 31 | 32 | | 名称 | 版本 | 介绍 | 33 | | :----------------------------------------: | :---------------------------------: | :------------------------------------------------ | 34 | | [vuepress-mergeable](./tools/mergeable.md) | | :crystal_ball: 定制化 VuePress 插件选项合并的方式 | 35 | | [vuepress-types](./tools/types.md) | | :palm_tree: VuePress 的类型定义 | 36 | -------------------------------------------------------------------------------- /packages/docs/src/zh/plugins/clean-urls.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebarDepth: 3 3 | --- 4 | 5 | # vuepress-plugin-clean-urls 6 | 7 | 使你的 VuePress 站点支持简洁链接。 8 | 9 | ::: warning 10 | 这个插件在 dev 服务器上总是生效的,但 VuePress **并没有能力**去修改服务器识别链接的方式。如果你希望你的网站地址符合某种特殊的模式(比如使用 `/routing` 而不是 `/routing.html` 或者 `routing/`),你需要确保你的服务器会将这些地址认为是 HTML。这可能意味着你需要对你的服务器进行特殊的配置。 11 | 12 | **参考资料:** 13 | 14 | - Netlify 用户: [https://www.netlify.com/docs/redirects/#trailing-slash](https://www.netlify.com/docs/redirects/#trailing-slash). 15 | - Surge 用户: [https://surge.sh/help/using-clean-urls-automatically](https://surge.sh/help/using-clean-urls-automatically). 16 | 17 | ::: 18 | 19 | ## 安装 20 | 21 | ```sh 22 | npm install -D vuepress-plugin-clean-urls 23 | ``` 24 | 25 | ## 使用 26 | 27 | ```js 28 | // .vuepress/config.js 29 | module.exports = { 30 | plugins: [ 31 | [ 32 | 'vuepress-plugin-clean-urls', 33 | { 34 | normalSuffix: '/', 35 | indexSuffix: '/', 36 | notFoundPath: '/404.html', 37 | }, 38 | ], 39 | ], 40 | } 41 | ``` 42 | 43 | ## 配置项 44 | 45 | ### normalSuffix 46 | 47 | - **类型:** `string` 48 | - **默认值:** `'/'` 49 | 50 | 普通页面的链接后缀。举个例子,`foo/bar.md` 会自动变成: 51 | 52 | - `foo/bar.html` 在默认情况下(未安装本插件时) 53 | - `foo/bar/`(当 `normalSuffix` 被设为 `'/'` 时) 54 | - `foo/bar`(当 `normalSuffix` 被设为 `''` 时) 55 | 56 | ### indexSuffix 57 | 58 | - **类型:** `string` 59 | - **默认值:** `'/'` 60 | 61 | 索引页面的链接后缀。举个例子,`foo/index.md` 会自动变成: 62 | 63 | - `foo/` 在默认情况下(未安装本插件时) 64 | - `foo`(当 `indexSuffix` 被设为 `''` 时) 65 | - `foo/index.html`(当 `indexSuffix` 被设为 `'/index.html'` 时) 66 | 67 | ::: tip 68 | 索引页面是指文件名为 `index.md` 或者 `readme.md` 的页面(不区分大小写)。 69 | ::: 70 | 71 | ### notFoundPath 72 | 73 | - **类型:** `string` 74 | - **默认值:** `'/404.html'` 75 | 76 | 用来存放 404 页面的地址。 77 | -------------------------------------------------------------------------------- /packages/docs/src/zh/plugins/copyright.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebarDepth: 3 3 | copyright: 4 | minLength: 40 5 | --- 6 | 7 | # vuepress-plugin-copyright 8 | 9 | 处理你的 VuePress 站点中的复制操作。 10 | 11 | ## 安装 12 | 13 | ```sh 14 | npm install -D vuepress-plugin-copyright 15 | ``` 16 | 17 | ## 使用 18 | 19 | ```js 20 | // .vuepress/config.js 21 | module.exports = { 22 | plugins: [ 23 | [ 24 | 'copyright', 25 | { 26 | noCopy: true, // 选中的文字将无法被复制 27 | minLength: 100, // 如果长度超过 100 个字符 28 | }, 29 | ], 30 | ], 31 | } 32 | ``` 33 | 34 | ### 使用 frontmatter 35 | 36 | 你可以在 frontmatter 中对当前页面启用或者禁用这个插件: 37 | 38 | ```yaml 39 | --- 40 | copyright: false # 在当前页面禁用这个插件 41 | --- 42 | 43 | ``` 44 | 45 | 你也可以进行局部配置: 46 | 47 | ```yaml 48 | --- 49 | # 这是当前页面的 frontmatter 50 | copyright: 51 | minLength: 40 # 这个配置会覆盖全局配置 52 | --- 53 | 54 | ``` 55 | 56 | 你可以在下面的输入框中看看复制的效果: 57 | 58 | 59 | 60 | 68 | 69 | ### 自定义剪贴板 70 | 71 | 你可以使用 [`clipboardComponent`](#clipboardcomponent) 自定义你的剪贴板。下面举出了一个简单的例子: 72 | 73 | ```vue 74 | 84 | 85 | 94 | ``` 95 | 96 | ## 配置项 97 | 98 | 标有 的配置将会允许在 [frontmatter](#frontmatter) 中使用。标有 的配置只在使用默认剪贴板组件时生效。 99 | 100 | ### disabled 101 | 102 | - **类型:** `boolean` 103 | - **默认值:** `false` 104 | 105 | 是否默认禁用这个插件的功能。 106 | 107 | ### noCopy 108 | 109 | - **类型:** `boolean` 110 | - **默认值:** `false` 111 | 112 | 是否禁止复制。 113 | 114 | ### noSelect 115 | 116 | - **类型:** `boolean` 117 | - **默认值:** `false` 118 | 119 | 是否禁止选中。 120 | 121 | ### minLength 122 | 123 | - **类型:** `number` 124 | - **默认值:** `0` 125 | 126 | 触发剪贴板组件或 [`noCopy`](#nocopy) 效果的最小文本长度。 127 | 128 | ### authorName 129 | 130 | - **类型:** `string | Record` 131 | - **默认值:** `'Author'` 132 | 133 | 作者名称。可以提供一个字符串或 i18n 对象,例如: 134 | 135 | ```json 136 | { 137 | "en-US": "Author", 138 | "zh-CN": "作者" 139 | } 140 | ``` 141 | 142 | ### clipboardComponent 143 | 144 | - **类型:** `string` 145 | - **默认值:** `undefined` 146 | 147 | [自定义剪贴板](#自定义剪贴板)组件的路径。如果提供了相对路径,将基于 `sourceDir` 进行解析。 148 | -------------------------------------------------------------------------------- /packages/docs/src/zh/plugins/git-log.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebarDepth: 3 3 | --- 4 | 5 | # vuepress-plugin-git-log 6 | 7 | 在你的 VuePress 页面信息中集成 git 日志。 8 | 9 | ## 安装 10 | 11 | ```sh 12 | npm install -D vuepress-plugin-git-log 13 | ``` 14 | 15 | ## 使用 16 | 17 | ```js 18 | // .vuepress/config.js 19 | module.exports = { 20 | plugins: [ 21 | [ 22 | 'vuepress-plugin-git-log', 23 | { 24 | additionalArgs: '--no-merge', 25 | onlyFirstAndLastCommit: true, 26 | }, 27 | ], 28 | ], 29 | } 30 | ``` 31 | 32 | ## 配置项 33 | 34 | ### formatTime 35 | 36 | - **类型:** `(timestamp: number, lang: string) => string` 37 | - **默认值:** `(timestamp, lang) => new Date(timestamp).toLocaleString(lang)` 38 | 39 | 用于格式化 Unix 时间的函数。 40 | 41 | ### additionalProps 42 | 43 | - **类型:** `{ [prop: string]: string }` 44 | - **默认值:** `{}` 45 | 46 | 一个表示额外属性的对象。键是属性名,值为对应的 [占位符](https://git-scm.com/docs/git-log#_pretty_formats)。 47 | 48 | ### additionalArgs 49 | 50 | - **类型:** `string | string[]` 51 | - **默认值:** `[]` 52 | 53 | 要传入的额外参数列表。 54 | 55 | ### extendGitLog 56 | 57 | - **type:** `(git: object) => void` 58 | - **default:** `undefined` 59 | 60 | 一个函数,用于拓展或者修改 [`$page.git`](#api) 对象。 61 | 62 | ### onlyFirstAndLastCommit 63 | 64 | - **类型:** `boolean` 65 | - **默认值:** `false` 66 | 67 | 是否只搜索第一个和最后一个 commit。对于大规模项目开启这个选项可能会提高初次启动速度,但是作为代价,你将将不能使用 `$page.git.commits` 和 `$page.git.contributors`。 68 | 69 | ## API 70 | 71 | 这个插件会在每个 `$page` 对象中添加 `git` 属性,它将拥有下面的属性: 72 | 73 | ### git.author 74 | 75 | 文章的作者,即第一个提交的作者。 76 | 77 | ### git.created 78 | 79 | 文章的创建日期,即第一个提交的创建时间。 80 | 81 | ### git.updated 82 | 83 | 文章的更新日期,即最后一个提交的提交时间。 84 | 85 | ### git.commits 86 | 87 | 所有提交按时间顺序构成的列表。 88 | 89 | ### git.contributors 90 | 91 | 文章的贡献者列表,即所有修改过文章的用户列表。 92 | 93 | ## 演示 94 | 95 | **输入** 96 | 97 | ```md 98 | - 本页面的作者:{{ $page.git.author }} 99 | - 本页面的贡献者:{{ $page.git.contributors.join(', ') }} 100 | - 本页面的最后一次提交:{{ $page.git.commits[0].fullHash }} 101 | ``` 102 | 103 | **输出** 104 | 105 | - 本页面的作者:{{ $page.git.author }} 106 | - 本页面的贡献者:{{ $page.git.contributors.join(', ') }} 107 | - 本页面的最后一次提交:{{ $page.git.commits[0].fullHash }} 108 | -------------------------------------------------------------------------------- /packages/docs/src/zh/plugins/medium-zoom.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebarDepth: 3 3 | --- 4 | 5 | # vuepress-plugin-medium-zoom 6 | 7 | 在你的 VuePress 站点中使用 [medium-zoom](https://github.com/francoischalifour/medium-zoom)。 8 | 9 | 这个插件将会使你的图片支持点击缩放。 10 | 11 | ## 安装 12 | 13 | ```sh 14 | npm install -D vuepress-plugin-medium-zoom 15 | ``` 16 | 17 | ## 使用 18 | 19 | ```js 20 | // .vuepress/config.js 21 | module.exports = { 22 | plugins: [ 23 | [ 24 | 'vuepress-plugin-medium-zoom', 25 | { 26 | selector: '.my-wrapper .my-img', 27 | delay: 1000, 28 | options: { 29 | margin: 24, 30 | background: '#BADA55', 31 | scrollOffset: 0, 32 | }, 33 | }, 34 | ], 35 | ], 36 | } 37 | ``` 38 | 39 | 在 `palette.styl` 中修改 `medium-zoom-overlay` 的默认 `z-index`: 40 | 41 | > 查看 [官方文档](https://vuepress.vuejs.org/zh/config/#palette-styl) 42 | 43 | ```stylus 44 | // 默认值: 100 45 | $mediumZoomZIndex = 10000 46 | ``` 47 | 48 | ## 配置项 49 | 50 | ### selector 51 | 52 | - **类型:** `string` 53 | - **默认值:** `'.theme-default-content img'` 54 | 55 | 支持点击缩放的图片元素的选择器,只有符合该选择器的图片才能被缩放。 56 | 57 | ### delay 58 | 59 | - **类型:** `number` 60 | - **默认值:** `500` 61 | 62 | 进入一个页面后,经过一定延迟后使页面中的图片支持缩放。 63 | 64 | ### options 65 | 66 | - **类型:** `Object` 67 | - **默认值:** `{}` 68 | 69 | medium-zoom 的 options。 70 | 71 | > 前往 [medium-zoom 的文档](https://github.com/francoischalifour/medium-zoom#options) 查看所有支持的 `options`。 72 | 73 | ## 高级用法 74 | 75 | 在组件中手动更新支持缩放的图片: 76 | 77 | ```js 78 | // SomeComponent.vue 79 | export default { 80 | methods: { 81 | updateImages() { 82 | // 通过某些操作更新当前页面的图片 83 | this.$nextTick(() => { 84 | // 立即更新 mediumZoom 85 | this.$vuepress.mediumZoom.update() // 使用默认的 selector 86 | this.$vuepress.mediumZoom.update('.new-images') // 使用自定义的 selector 87 | 88 | // 在一定延迟后更新 mediumZoom 89 | this.$vuepress.mediumZoom.updateDelay() // 使用默认的 selector 和 delay 90 | this.$vuepress.mediumZoom.updateDelay('.new-images') // 使用自定义的 selector 和默认的 delay 91 | this.$vuepress.mediumZoom.updateDelay('.new-images', 1000) // 使用自定义的 selector 和 delay 92 | }) 93 | }, 94 | }, 95 | } 96 | ``` 97 | 98 | 在你的组件中直接获取 `mediumZoom` 实例: 99 | 100 | > 前往 [medium-zoom 的文档](https://github.com/francoischalifour/medium-zoom#methods) 查看所有支持的方法。 101 | 102 | ```js 103 | // SomeComponent.vue 104 | export default { 105 | methods: { 106 | openImages() { 107 | // 获取 mediumZoom 实例 108 | const zoom = this.$vuepress.mediumZoom.instance 109 | 110 | // 调用实例方法 111 | zoom.open() 112 | }, 113 | }, 114 | } 115 | ``` 116 | 117 | ## 演示 118 | 119 | 点击图片: 120 | 121 | 演示 122 | -------------------------------------------------------------------------------- /packages/docs/src/zh/plugins/migrate.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebarDepth: 3 3 | --- 4 | 5 | # vuepress-plugin-migrate 6 | 7 | 从其他网站迁移到 VuePress。 8 | 9 | ## 安装 10 | 11 | ```sh 12 | npm install -D vuepress-plugin-migrate 13 | ``` 14 | 15 | ## 使用 16 | 17 | ```js 18 | // .vuepress/config.js 19 | module.exports = { 20 | plugins: [ 21 | [ 22 | 'vuepress-plugin-migrate', 23 | { 24 | targetDir: '_posts', 25 | downloadDir: '.vuepress/downloads', 26 | }, 27 | ], 28 | ], 29 | } 30 | ``` 31 | 32 | ## 配置项 33 | 34 | ### targetDir 35 | 36 | - **类型:** `string` 37 | - **默认值:** `'_posts'` 38 | 39 | 要输出 markdown 文件的目录。 40 | 41 | ### downloadDir 42 | 43 | - **类型:** `string` 44 | - **默认值:** `'.vuepress/downloads'` 45 | 46 | 用于存储下载文件的目录。 47 | 48 | ### maxConcurrentTasks 49 | 50 | - **类型:** `number` 51 | - **默认值:** `10` 52 | 53 | 允许的最大下载并发数。 54 | 55 | ### forceDownload 56 | 57 | - **类型:** `boolean` 58 | - **默认值:** `false` 59 | 60 | 当检测到 `.html` 文件已存在时是否强制下载。 61 | 62 | ### forceConvert 63 | 64 | - **类型:** `boolean` 65 | - **默认值:** `false` 66 | 67 | 当检测到 `.md` 文件已存在时是否强制覆盖。 68 | 69 | ### sitemap 70 | 71 | - **类型:** `string` 72 | - **默认值:** `undefined` 73 | 74 | 原网站的 sitemap 链接。 75 | 76 | ### getFileName 77 | 78 | - **类型:** `(url: string) => string` 79 | - **默认值:** `url => String(++index)` 80 | 81 | 要保存为的文件名。如果返回一个 falsy 值,则不下载对应的文件。 82 | 83 | ### parseHTML 84 | 85 | - **类型:** `($: CheerioElement, render: ($: CheerioElement) => string) => ParsedResult` 86 | - **默认值:** `undefined` 87 | 88 | 从爬取的 HTML 生成对应 `ParsedResult` 对象的函数。一个 `ParsedResult` 是一个含有以下属性的对象: 89 | 90 | ```ts 91 | interface ParsedResult { 92 | frontmatter?: any 93 | filename?: string 94 | content?: string 95 | } 96 | ``` 97 | 98 | ## CLI 99 | 100 | ### 通用选项 101 | 102 | 这些选项将在任何一个命令中生效。 103 | 104 | ### --detail 105 | 106 | 在遇到错误时显示详细信息。 107 | 108 | ### -f, --forced 109 | 110 | 相当于将 [forceDownload](#forceDownload) 和 [forceConvert](#forceConvert) 都设置为 `true`。 111 | 112 | ### vuepress download 113 | 114 | 从源网站中爬取所需的页面,并存储到本地文件夹中。 115 | 116 | ### -s, --sitemap `` 117 | 118 | 详见 [sitemap](#sitemap)。 119 | 120 | ### vuepress convert 121 | 122 | 将存储在本地的 HTML 文件转化为 markdown 文件并输出。 123 | 124 | ### -t, --target `` 125 | 126 | 详见 [targetDir](#targetDir)。 127 | 128 | ### vuepress migrate 129 | 130 | 依次完成 download 和 convert 两个命令。支持两个命令的全部参数。 131 | -------------------------------------------------------------------------------- /packages/docs/src/zh/plugins/named-chunks.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebarDepth: 3 3 | --- 4 | 5 | # vuepress-plugin-named-chunks 6 | 7 | 为你的 VuePress 站点生成命名 chunks 。 8 | 9 | VuePress 使用 [dynamic import](https://webpack.js.org/guides/code-splitting/#dynamic-imports) 来加载页面组件和布局组件。每一个组件都会变成一个独立的 chunk ,但它们的名字都是自动生成的,不利于后续追踪。这个插件可以用来生成命名 chunks 。 10 | 11 | ## 安装 12 | 13 | ```sh 14 | npm install -D vuepress-plugin-named-chunks 15 | ``` 16 | 17 | ## 使用 18 | 19 | ```js 20 | // .vuepress/config.js 21 | module.exports = { 22 | plugins: [ 23 | [ 24 | 'named-chunks', 25 | { 26 | pageChunkName: page => 'page' + page.key.slice(1), 27 | layoutChunkName: layout => 'layout-' + layout.componentName, 28 | }, 29 | ], 30 | ], 31 | } 32 | ``` 33 | 34 | ## 配置项 35 | 36 | ### pageChunkName 37 | 38 | - **类型:** `((page: Page) => string) | false` 39 | - **默认值:** `({ key }) => 'page' + key.slice(1)` 40 | 41 | 用于从 `Page` 对象生成模块名称的函数。 42 | 43 | ### layoutChunkName 44 | 45 | - **类型:** `((layout: ResolvedComponent) => string) | false` 46 | - **默认值:** `false` 47 | 48 | 用于从 `ResolvedComponent` 对象生成模块名称的函数。 49 | 50 | ## API 51 | 52 | 这个插件将会植入在 [context API](https://vuepress.vuejs.org/zh/plugin/context-api.html) 中注入一些属性。 53 | 54 | ### 页面组件的模块名称 55 | 56 | 1. `context.pages` 是由 `Page` 对象构成的数组。 57 | 2. `page._chunkName` 是对应的页面组件的模块名称。 58 | 59 | ### 布局组件的模块名称 60 | 61 | 1. `context.themeAPI.layoutComponentMap` 是由 `ResolvedComponent` 对象构成的键值对。 62 | 2. `layout._chunkName` 是对应的布局组件的模块名称。 63 | -------------------------------------------------------------------------------- /packages/docs/src/zh/plugins/nprogress.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebarDepth: 3 3 | --- 4 | 5 | # vuepress-plugin-nprogress 6 | 7 | 在你的 VuePress 站点中使用 [nprogress](https://github.com/rstacruz/nprogress)。 8 | 9 | 这个插件将会在你切换页面的时候,在顶部显示进度条。 10 | 11 | ## 安装 12 | 13 | ```sh 14 | npm install -D vuepress-plugin-nprogress 15 | ``` 16 | 17 | ## 使用 18 | 19 | ```js 20 | // .vuepress/config.js 21 | module.exports = { 22 | plugins: ['vuepress-plugin-nprogress'], 23 | } 24 | ``` 25 | 26 | ## 自定义颜色 27 | 28 | 在 `palette.styl` 文件中设置 `$nprogressColor`,就可以改变进度条的颜色。如果不设置的话,默认使用 VuePress 的 `$accentColor` 作为进度条颜色。 29 | 30 | > 查看 [官方文档](https://vuepress.vuejs.org/zh/config/#palette-styl) 31 | 32 | ```stylus 33 | $nprogressColor = red 34 | 35 | // by default: 36 | // $nprogressColor ?= $accentColor 37 | ``` 38 | -------------------------------------------------------------------------------- /packages/docs/src/zh/plugins/redirect.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebarDepth: 3 3 | --- 4 | 5 | # vuepress-plugin-redirect 6 | 7 | VuePress 内置了[多语言系统](https://vuepress.vuejs.org/zh/guide/i18n.html),但你必须提供一个默认语言,否则直接访问 `/` 将只能得到 404。然而,提供默认语言往往又意味着不那么友好的项目结构(因为默认语言下的文件会比其他语言低一级),我们有时也希望网站保留 `/` 用于更加智能地重定向(比如根据 `navigator.language` 判断用户所使用的语言自动定向到相关页面)。`vuepress-plugin-redirect` 就是这样一个自动重定向的插件。当然,它所能做的事情不止是自动匹配语言,你可以通过定制你的重定向器实现任何页面到子页面的重定向。 8 | 9 | 10 |

比如,当你在浏览器地址栏中键入 {{ location }} 时,页面将自动重定向到这里。

11 | 12 | 13 | 26 | 27 | ## 安装 28 | 29 | ```sh 30 | npm install -D vuepress-plugin-redirect 31 | ``` 32 | 33 | ## 使用 34 | 35 | ```js 36 | // .vuepress/config.js 37 | module.exports = { 38 | plugins: [ 39 | [ 40 | 'redirect', 41 | { 42 | // 提供多语言重定向功能 43 | // 它会自动从 `/foo/bar/` 定向到 `/:locale/foo/bar/`,如果对应的页面存在 44 | locales: true, 45 | }, 46 | ], 47 | ], 48 | } 49 | ``` 50 | 51 | 或者 52 | 53 | ```js 54 | // .vuepress/config.js 55 | module.exports = { 56 | plugins: { 57 | redirect: { 58 | redirectors: [ 59 | // 定制化重定向 60 | { 61 | base: '/plugins/', // 将 `/my-plugins/` 自动重定向到某个子页面 62 | storage: true, // 保存最后一次访问的结果到 `localStorage`,供下次重定向使用 63 | alternative: [ 64 | // 提供一个备选列表,如果都找不到就只能 404 Not Found 喽 65 | 'mathjax', // 相当于 `/my-plugins/mathjax/` 66 | 'migrate', 67 | 'redirect', 68 | 'serve', 69 | ], 70 | }, 71 | ], 72 | }, 73 | }, 74 | } 75 | ``` 76 | 77 | ## 配置项 78 | 79 | ### locales 80 | 81 | - **类型:** `boolean` 82 | - **默认值:** `false` 83 | 84 | 是否提供多语言重定向功能。 85 | 86 | ### redirectors 87 | 88 | - **类型:** `Redirector[]` 89 | - **默认值:** `[]` 90 | 91 | 自定义的重定向器列表。 92 | 93 | ### redirector.base 94 | 95 | - **类型:** `string` 96 | - **默认值:** `'/'` 97 | 98 | 要进行重定向的根地址。 99 | 100 | ### redirector.storage 101 | 102 | - **类型:** `boolean | string | Storage` 103 | - **默认值:** `false` 104 | 105 | 决定重定向的结果被以何种方式存储。如果设为 `string`,则对应 `localStorage` 的键值。如果是对象,则必须包含下面两个方法: 106 | 107 | - `get(redirector: Redirector): string` 108 | - `set(value: string, redirector: Redirector): void` 109 | 110 | 下面提供一个简单的 `storage` 对象以供大家参考: 111 | 112 | ```js 113 | const storage = { 114 | get({ base }) { 115 | if (typeof localStorage === 'undefined') return null 116 | return localStorage.getItem('redirect:' + base) 117 | }, 118 | set(value, { base }) { 119 | if (typeof localStorage === 'undefined') return 120 | localStorage.setItem('redirect:' + base, value) 121 | }, 122 | } 123 | ``` 124 | 125 | ### redirector.alternative 126 | 127 | - **类型:** `string | string[] | ((rel: string) => string | string[])` 128 | - **默认值:** `undefined` 129 | 130 | 重定向的备选列表。被请求的网址将被分为 `base` 和 `rel` 两个部分,`alternative` 将插入它们之间。如果是一个函数,将传入 `rel` 作为参数。得到的所有结果将被一一尝试,取第一个存在的页面进行重定向。 131 | -------------------------------------------------------------------------------- /packages/docs/src/zh/plugins/serve.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebarDepth: 3 3 | --- 4 | 5 | # vuepress-plugin-serve 6 | 7 | 在本地使用静态服务器,测试 VuePress 的 build 结果。 8 | 9 | ## 安装 10 | 11 | ```sh 12 | npm install -D vuepress-plugin-serve 13 | ``` 14 | 15 | ## 使用 16 | 17 | ```js 18 | // .vuepress/config.js 19 | module.exports = { 20 | plugins: [ 21 | [ 22 | 'vuepress-plugin-serve', 23 | { 24 | post: 1234, 25 | staticOptions: { 26 | dotfiles: 'allow', 27 | }, 28 | beforeServer(app, server) { 29 | app.get('/path/to/my/custom', function(req, res) { 30 | res.json({ custom: 'response' }) 31 | }) 32 | }, 33 | }, 34 | ], 35 | ], 36 | } 37 | ``` 38 | 39 | ## 配置项 40 | 41 | ### commandName 42 | 43 | - **类型:** `string` 44 | - **默认值:** `'serve'` 45 | 46 | vuepress-plugin-serve 会增加一个 vuepress 命令,这个选项可用于自定义命令名称。 47 | 48 | ### host 49 | 50 | - **类型:** `string` 51 | - **默认值:** `siteConfig.host || 'localhost'` 52 | 53 | 指定服务器的主机名。 54 | 55 | ### port 56 | 57 | - **类型:** `number` 58 | - **默认值:** `siteConfig.port || 8080` 59 | 60 | 指定服务器监听的端口。 61 | 62 | ### notFoundPath 63 | 64 | - **类型:** `string` 65 | - **默认值:** `'404.html'` 66 | 67 | 404 页面的路径(相对于 `dest` 目录)。 68 | 69 | ### staticOptions 70 | 71 | - **类型:** `object` 72 | - **默认值:** `{}` 73 | 74 | 提供给 [serve-static](https://github.com/expressjs/serve-static#servestaticroot-options) 的选项。 75 | 76 | ### beforeServer 77 | 78 | - **类型:** `(app, server) => void | Promise` 79 | - **默认值:** `undefined` 80 | 81 | 在服务器接受客户端信息之前执行。类似于 VuePress 的 [beforeDevServer](https://vuepress.vuejs.org/zh/plugin/option-api.html#beforedevserver) 选项。 82 | 83 | ### afterServer 84 | 85 | - **类型:** `async (app, server) => void | Promise` 86 | - **默认值:** `undefined` 87 | 88 | 在服务器接受客户端信息之后执行。类似于 VuePress 的 [afterDevServer](https://vuepress.vuejs.org/zh/plugin/option-api.html#afterdevserver) 选项。 89 | 90 | ## CLI 91 | 92 | 使用了这个插件以后,VuePress 会新增一个 `serve` 命令。这个命令会使用已经生成的文件来构建服务器。它拥有以下的选项: 93 | 94 | ### --build 95 | 96 | 在构建服务器前先执行一轮 `vuepress build`。 97 | 98 | ### --open 99 | 100 | 当服务端准备就绪时自动打开浏览器。 101 | 102 | ### --host `` 103 | 104 | 参见 [host](#host)。 105 | 106 | ### --port `` 107 | 108 | 参见 [port](#port)。 109 | 110 | ::: tip 111 | VuePress 内置的命令行选项,如 `--dest `, `--cache [cache]`, `--no-cache`,也都是支持的。 112 | ::: 113 | -------------------------------------------------------------------------------- /packages/docs/src/zh/plugins/smooth-scroll.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebarDepth: 3 3 | --- 4 | 5 | # vuepress-plugin-smooth-scroll 6 | 7 | 在你的 VuePress 站点中使用平滑滚动。 8 | 9 | 这个插件简单做了两件事: 10 | 11 | 1. 在 [scrollBehavior](https://router.vuejs.org/api/#scrollbehavior) 中使用 `window.scrollTo({ behavior: 'smooth' })` 12 | - [参考](https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollTo) 13 | - [浏览器兼容性](https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollTo#Browser_Compatibility) 14 | - [smoothscroll-polyfill](https://github.com/iamdustan/smoothscroll) 15 | 2. 将样式 `scroll-behavior: smooth;` 加入 `` 元素 16 | - [参考](https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-behavior) 17 | - [浏览器兼容性](https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-behavior#Browser_compatibility) 18 | 19 | ::: tip 20 | 21 | - 第一个仅对 `` 生效 22 | - 第二个则对 `` 和 `` 都生效 23 | 24 | 这两种特性的浏览器兼容性并不一样,所以目前我们同时使用了这两种特性。 25 | 26 | 为了更好的浏览器兼容性,我们建议你尽量在你的 markdown 文件中使用 ``。 27 | ::: 28 | 29 | ## 安装 30 | 31 | ```sh 32 | npm install -D vuepress-plugin-smooth-scroll 33 | ``` 34 | 35 | ## 使用 36 | 37 | ```js 38 | // .vuepress/config.js 39 | module.exports = { 40 | plugins: ['vuepress-plugin-smooth-scroll'], 41 | } 42 | ``` 43 | 44 | ## 演示 45 | 46 | - 点击侧边栏中的链接 47 | - 点击文章标题前的锚点 48 | 49 | ``` 50 | 51 | 52 | 只 53 | 54 | 55 | 是 56 | 57 | 58 | 为 59 | 60 | 61 | 了 62 | 63 | 64 | 让 65 | 66 | 67 | 页 68 | 69 | 70 | 面 71 | 72 | 73 | 更 74 | 75 | 76 | 长 77 | 78 | 79 | 80 | ``` 81 | 82 | ### 页面底部 83 | -------------------------------------------------------------------------------- /packages/docs/src/zh/plugins/table-of-contents.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebarDepth: 3 3 | --- 4 | 5 | # vuepress-plugin-table-of-contents 6 | 7 | 为你的 VuePress 站点增加目录组件。 8 | 9 | ## 安装 10 | 11 | ```sh 12 | npm install -D vuepress-plugin-table-of-contents 13 | ``` 14 | 15 | ## 使用 16 | 17 | ```js 18 | // .vuepress/config.js 19 | module.exports = { 20 | plugins: ['vuepress-plugin-table-of-contents'], 21 | } 22 | ``` 23 | 24 | 该组件会为你注册一个 `` 组件,该组件展示你当前页面文章的目录,你可以在 Markdown 文件和 Vue 文件中使用它。 25 | 26 | ```md 27 | 28 | 29 | 30 | ``` 31 | 32 | ## 配置项 33 | 34 | ### componentName 35 | 36 | - **类型:** `string` 37 | - **默认值:** `'TOC'` 38 | 39 | 组件的名称。 40 | 41 | ## 组件 Props 42 | 43 | ### includeLevel 44 | 45 | - **类型:** `[number, number]` 46 | - **默认值:** `[2, 3]` 47 | 48 | `` 组件包含的标题范围。 49 | 50 | 例如,`[2, 4]` 代表 2 <= x <= 4 。 51 | 52 | ## 演示 53 | 54 | **输入** 55 | 56 | ```md 57 | 58 | ``` 59 | 60 | **输出** 61 | 62 | 63 | 64 | **输入** 65 | 66 | ```md 67 | 68 | ``` 69 | 70 | **输出** 71 | 72 | 73 | 74 | ## 与 VuePress markdown 目录语法的区别 75 | 76 | 你可能注意到 VuePress 也提供了一种 [markdown 语法 `[[toc]]`](https://vuepress.vuejs.org/zh/guide/markdown.html#table-of-contents) 来生成目录。 77 | 78 | 但是, `[[toc]]` 只是 markdown 语法,所以只能用于 `.md` 文件。而 `` 是 Vue 组件,所以可以用于 `.md` 文件和 `.vue` 文件。 79 | 80 | 因此,当你需要在页面的其他部分使用目录时, `` 可以满足你的需要(例如:在你自己的主题中使用目录组件) 81 | -------------------------------------------------------------------------------- /packages/docs/src/zh/plugins/typescript.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebarDepth: 3 3 | --- 4 | 5 | # vuepress-plugin-typescript 6 | 7 | ## 安装 8 | 9 | ```sh 10 | npm install -D vuepress-plugin-typescript typescript 11 | ``` 12 | 13 | ## 使用 14 | 15 | ```js 16 | // .vuepress/config.js 17 | module.exports = { 18 | plugins: [ 19 | [ 20 | 'vuepress-plugin-typescript', 21 | { 22 | tsLoaderOptions: { 23 | // ts-loader 的所有配置项 24 | }, 25 | }, 26 | ], 27 | ], 28 | } 29 | ``` 30 | 31 | ## 配置项 32 | 33 | ### tsLoaderOptions 34 | 35 | - **类型:** `Object` 36 | - **默认值:** `{}` 37 | 38 | `ts-loader` 的 Loader Options。参考 [ts-loader 文档](https://github.com/TypeStrong/ts-loader#loader-options)。 39 | 40 | ## 支持的特性 41 | 42 | ### 在 Markdown 中使用 TS 43 | 44 | 我们知道, VuePress 允许我们 [在 Markdown 中使用 Vue](https://vuepress.vuejs.org/zh/guide/using-vue.html)。 45 | 46 | 这个插件可以允许你在 Markdown 中通过 TypeScript 使用 Vue 。 47 | 48 | **输入** 49 | 50 | ```md 51 | {{ msg }} 52 | 53 | 62 | ``` 63 | 64 | **输出** 65 | 66 | {{ msg }} 67 | 68 | 77 | 78 | ### 在 Vue SFC 中使用 TS 79 | 80 | 这个插件允许你使用 TypeScript 来写 `.vue` 文件,包括: 81 | 82 | - 自动注册的全局组件: [.vuepress/components/\*.vue](https://vuepress.vuejs.org/zh/guide/directory-structure.html) 83 | - 主题布局组件: [theme/layouts/\*.vue](https://vuepress.vuejs.org/theme/writing-a-theme.html#layout-component) 84 | - 其他你想要在 VuePress 中使用的组件 85 | 86 | > 参考当前文档的 [源代码](https://github.com/vuepress/vuepress-community/tree/main/packages/docs/src/.vuepress/components)。 87 | 88 | ### enhanceApp.ts 89 | 90 | VuePress 支持 [应用级别的配置](https://vuepress.vuejs.org/zh/guide/basic-config.html#app-level-enhancements),即 `.vuepress/enhanceApp.js` / `theme/enhanceApp.js`. 91 | 92 | 这个插件允许你使用 `enhanceApp.ts` 来代替 `enhanceApp.js` 。 93 | 94 | > 参考这个插件的 [测试用例](https://github.com/vuepress/vuepress-community/blob/main/packages/vuepress-plugin-typescript/test/e2e/docs/.vuepress/theme/enhanceApp.ts)。 95 | 96 | ::: warning 97 | 如果你想在 `enhanceApp.ts` 或其他 `.ts` 文件中引入 `.vue` 文件,记得创建 `.vuepress/shims-vue.d.ts`: 98 | 99 | ```ts 100 | // .vuepress/shims-vue.d.ts 101 | declare module '*.vue' { 102 | import Vue from 'vue' 103 | export default Vue 104 | } 105 | ``` 106 | 107 | ::: 108 | 109 | ## 类型定义 110 | 111 | 你可能会遇到 VuePress 的类型检查问题,比如无法找到 `this.$themeConfig` 的类型定义。 112 | 113 | 如果你想获取到正确的类型定义,你可以尝试使用 [vuepress-types](../tools/types.md) 。 114 | -------------------------------------------------------------------------------- /packages/docs/src/zh/plugins/zooming.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebarDepth: 3 3 | --- 4 | 5 | # vuepress-plugin-zooming 6 | 7 | 在你的 VuePress 站点中使用 [zooming](https://github.com/kingdido999/zooming)。 8 | 9 | 这个插件将会使你的图片支持点击缩放。 10 | 11 | ## 安装 12 | 13 | ```sh 14 | npm install -D vuepress-plugin-zooming 15 | ``` 16 | 17 | ## 使用 18 | 19 | ```js 20 | // .vuepress/config.js 21 | module.exports = { 22 | plugins: [ 23 | [ 24 | 'vuepress-plugin-zooming', 25 | { 26 | selector: '.my-wrapper .my-img', 27 | delay: 1000, 28 | options: { 29 | bgColor: 'black', 30 | zIndex: 10000, 31 | }, 32 | }, 33 | ], 34 | ], 35 | } 36 | ``` 37 | 38 | ## 配置项 39 | 40 | ### selector 41 | 42 | - **类型:** `string` 43 | - **默认值:** `'.theme-default-content img'` 44 | 45 | 支持点击缩放的图片元素的选择器,只有符合该选择器的图片才能被缩放。 46 | 47 | ### delay 48 | 49 | - **类型:** `number` 50 | - **默认值:** `500` 51 | 52 | 进入一个页面后,经过一定延迟后使页面中的图片支持缩放。 53 | 54 | ### options 55 | 56 | - **类型:** `Object` 57 | - **默认值:** `{}` 58 | 59 | zooming 的 options。 60 | 61 | > 前往 [zooming 的文档](https://desmonding.me/zooming/docs/#/configuration?id=options) 查看所有支持的 `options`。 62 | 63 | ## 高级用法 64 | 65 | 在组件中手动更新支持缩放的图片: 66 | 67 | ```js 68 | // SomeComponent.vue 69 | export default { 70 | methods: { 71 | updateImages() { 72 | // 通过某些操作更新当前页面的图片 73 | this.$nextTick(() => { 74 | // 立即更新 zooming 75 | this.$vuepress.zooming.update() // 使用默认的 selector 76 | this.$vuepress.zooming.update('.new-images') // 使用自定义的 selector 77 | 78 | // 在一定延迟后更新 zooming 79 | this.$vuepress.zooming.updateDelay() // 使用默认的 selector 和 delay 80 | this.$vuepress.zooming.updateDelay('.new-images') // 使用自定义的 selector 和默认的 delay 81 | this.$vuepress.zooming.updateDelay('.new-images', 1000) // 使用自定义的 selector 和 delay 82 | }) 83 | }, 84 | }, 85 | } 86 | ``` 87 | 88 | 在你的组件中直接获取 `Zooming` 实例: 89 | 90 | > 前往 [zooming 的文档](https://desmonding.me/zooming/docs/#/api-reference) 查看所有支持的方法。 91 | 92 | ```js 93 | // SomeComponent.vue 94 | export default { 95 | methods: { 96 | openImages() { 97 | // 获取 Zooming 实例 98 | const zooming = this.$vuepress.zooming.instance 99 | 100 | // 调用实例方法 101 | zooming.open() 102 | }, 103 | }, 104 | } 105 | ``` 106 | 107 | ## 演示 108 | 109 | 点击图片: 110 | 111 | 演示 112 | -------------------------------------------------------------------------------- /packages/docs/src/zh/tools/mergeable.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebarDepth: 3 3 | --- 4 | 5 | # vuepress-mergeable 6 | 7 | `vuepress-mergeable` 基于 [deconstruct-merge](https://github.com/Shigma/deconstruct-merge),可以用于定制化 VuePress 插件选项合并的方式。 8 | 9 | ## 为什么我需要这个? 10 | 11 | 在 VuePress 中,一个插件可以被多次使用但仅会保留一个 `options`。如果你的插件被多处使用(比如既在 `config.js` 中被直接引用,又被插件和主题间接地使用),它们的 `options` 将会互相覆盖,从而导致各种未知的负面影响。这个工具可以帮助你创造一个可以按照你的喜好自动合并选项的插件。 12 | 13 | ## 解构合并 14 | 15 | 合并两个选项的方式有很多种: 16 | 17 | - `override`:后面传入选项覆盖前面的 18 | - `assign`:使用 `Object.assign` 进行合并 19 | - `array`:将全部传入的选项依次放入一个数组 20 | - `flat`:将传入的选项放入一个数组并压平 21 | 22 | ### 定义对象中不同属性的合并方式 23 | 24 | 如果某个选项是一个对象,其中不同的属性要使用不同的合并方式,你可以将选项本身也写成对象式: 25 | 26 | ```js 27 | mergeOptions = { 28 | foo: 'array', 29 | bar: 'flat', 30 | } 31 | ``` 32 | 33 | 此时,`foo` 选项将采用数组进行合并,而 `bar` 选项则采用压平的数组。 34 | 35 | ### 定义数组中不同元素的合并方式 36 | 37 | 如果某个选项是一个数组,其中不同的元素要使用不同的合并方式,你可以将选项本身也写成数组式: 38 | 39 | ```js 40 | mergeOptions = ['override', 'assign'] 41 | ``` 42 | 43 | 此时,数组的第一个元素将使用覆盖的合并方式,而第二个元素则采用 `Object.assign` 进行合并。 44 | 45 | ### 使用函数定义合并方式 46 | 47 | 如果上面的 4 种合并策略都不满足你的需求,则你可以自己写一个函数来定义合并方式: 48 | 49 | ```js 50 | mergeOptions = function(value, oldValue) { 51 | return value + oldValue 52 | } 53 | ``` 54 | 55 | 当然,如果有好的想法,我们也欢迎你向我们提出 PR。 56 | 57 | ### 解构你的选项 58 | 59 | 上面的语法可以被递归地应用在你的选项中,这使得你可以精细地定义每一个细节的合并逻辑。下面是一个案例: 60 | 61 | ```js 62 | mergeOptions = { 63 | foo: [ 64 | 'override', 65 | { 66 | bar: (value, oldValue) => value + oldValue, 67 | baz: 'flat', 68 | }, 69 | 'assign', 70 | ], 71 | } 72 | ``` 73 | 74 | ::: tip 提示 75 | `override` 是我们的默认合并策略。因此任何没有在 `mergeOptions` 中定义的对象属性或数组元素都将自动采取覆盖策略。 76 | ::: 77 | 78 | ## 使用方法 79 | 80 | ### mergeable(plugin, mergeOptions?, defaultOptions?): plugin 81 | 82 | - **plugin:** 任何 VuePress 插件 83 | - **mergeOptions:** 解构合并的选项 84 | - **defaultOptions:** 插件的默认选项 85 | 86 | ```js 87 | // vuepress-plugin-my-plugin/index.js 88 | const mergeable = require('vuepress-mergeable') 89 | 90 | module.exports = mergeable( 91 | options => ({ 92 | ready() { 93 | console.log(options) 94 | }, 95 | }), 96 | { 97 | // 解构合并的选项 98 | foo: 'assign', 99 | bar: 'flat', 100 | }, 101 | { 102 | // 插件的默认选项 103 | foo: { a: 1 }, 104 | } 105 | ) 106 | ``` 107 | 108 | ```js 109 | // .vuepress/config.js 110 | module.exports = { 111 | plugins: [ 112 | // 多次使用的你的插件 113 | [ 114 | 'my-plugin', 115 | { 116 | foo: { b: 2, c: 4 }, 117 | baz: 'Hello', 118 | }, 119 | ], 120 | [ 121 | 'my-plugin', 122 | { 123 | foo: { b: 3 }, 124 | bar: 'Hello', 125 | baz: 'World', 126 | }, 127 | ], 128 | ], 129 | } 130 | ``` 131 | 132 | 这会是得到的结果: 133 | 134 | ```js 135 | { foo: { a: 1, b: 3, c: 4 }, 136 | bar: ['Hello'], 137 | baz: 'World' } 138 | ``` 139 | -------------------------------------------------------------------------------- /packages/docs/src/zh/tools/types.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebarDepth: 3 3 | --- 4 | 5 | # vuepress-types 6 | 7 | 目前 VuePress 并没有支持 typescript ,并且没有提供类型定义。 8 | 9 | [vuepress-plugin-typescript](../plugins/typescript.md) 提供了在 VuePress 中使用 typescript 的部分能力。如果你想获取到正确的类型定义,你可以配合 `vuepress-types` 一起使用。 10 | 11 | ::: warning 实验中 12 | `vuepress-types` 作为 VuePress 的类型定义包,还处于实验阶段。如果你在使用时发现任何问题,欢迎提出 Issue 。 13 | ::: 14 | 15 | ## 安装 16 | 17 | ```sh 18 | npm install -D vuepress-types 19 | ``` 20 | 21 | ## 使用 22 | 23 | 你可以选择下列 **一种** 方式使用它: 24 | 25 | ### 手动引入 26 | 27 | 你可以手动在 `.vue` 文件中引入: 28 | 29 | ```vue {2} 30 | 42 | ``` 43 | 44 | ### 添加到 tsconfig 45 | 46 | 你可以把它添加到 `tsconfig.json` 的 `compilerOptions.types` 中: 47 | 48 | > 参考 [`tsconfig.json` 文档](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html#types-typeroots-and-types) 49 | 50 | ```json {3} 51 | { 52 | "compilerOptions": { 53 | "types": ["vuepress-types"] 54 | } 55 | } 56 | ``` 57 | -------------------------------------------------------------------------------- /packages/docs/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "allowJs": true 5 | }, 6 | "include": ["./src/.vuepress/config.js"] 7 | } 8 | -------------------------------------------------------------------------------- /packages/vuepress-mergeable/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [1.1.4](https://github.com/vuepress/vuepress-community/compare/vuepress-mergeable@1.1.3...vuepress-mergeable@1.1.4) (2020-09-01) 7 | 8 | **Note:** Version bump only for package vuepress-mergeable 9 | 10 | ## [1.1.3](https://github.com/vuepress/vuepress-community/compare/vuepress-mergeable@1.1.2...vuepress-mergeable@1.1.3) (2019-12-27) 11 | 12 | ### Bug Fixes 13 | 14 | - **mergeable:** add plugin-api param ([a96ef12](https://github.com/vuepress/vuepress-community/commit/a96ef12a69d48412c6adf624b86f615e954707fb)) 15 | 16 | ## [1.1.2](https://github.com/vuepress/vuepress-community/compare/vuepress-mergeable@1.1.1...vuepress-mergeable@1.1.2) (2019-11-29) 17 | 18 | **Note:** Version bump only for package vuepress-mergeable 19 | 20 | ## [1.1.1](https://github.com/vuepress/vuepress-community/compare/vuepress-mergeable@1.1.0...vuepress-mergeable@1.1.1) (2019-11-20) 21 | 22 | **Note:** Version bump only for package vuepress-mergeable 23 | 24 | # 1.1.0 (2019-10-18) 25 | 26 | ### Features 27 | 28 | - **vuepress-mergeable:** migrate with types ([6e3f980](https://github.com/vuepress/vuepress-community/commit/6e3f980ae01653534c6fe6c25e72f7be6dc3b161)) 29 | -------------------------------------------------------------------------------- /packages/vuepress-mergeable/README.md: -------------------------------------------------------------------------------- 1 | # vuepress-mergeable 2 | 3 | > VuePress tool to customize how a plugin merges its options 4 | 5 | ## Documentation 6 | 7 | [vuepress-community.netlify.app](https://vuepress-community.netlify.app) 8 | 9 | ## License 10 | 11 | [MIT](https://github.com/vuepress/vuepress-community/blob/main/LICENSE) © [VuePress Community](https://github.com/vuepress) 12 | -------------------------------------------------------------------------------- /packages/vuepress-mergeable/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vuepress-mergeable", 3 | "version": "1.1.4", 4 | "description": "VuePress tool to customize how a plugin merges its options", 5 | "keywords": [ 6 | "plugin", 7 | "tool", 8 | "vuepress" 9 | ], 10 | "homepage": "https://github.com/vuepress", 11 | "bugs": { 12 | "url": "https://github.com/vuepress/vuepress-community/issues" 13 | }, 14 | "repository": { 15 | "type": "git", 16 | "url": "git+https://github.com/vuepress/vuepress-community.git" 17 | }, 18 | "license": "MIT", 19 | "author": "Shigma <1700011071@pku.edu.cn>", 20 | "contributors": [ 21 | "meteorlxy " 22 | ], 23 | "main": "lib/index.js", 24 | "types": "lib/index.d.ts", 25 | "files": [ 26 | "lib" 27 | ], 28 | "scripts": { 29 | "build": "rimraf lib && tsc -p tsconfig.build.json", 30 | "lint": "eslint --ext .ts src" 31 | }, 32 | "dependencies": { 33 | "deconstruct-merge": "^1.1.0" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /packages/vuepress-mergeable/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Plugin, PluginOptionAPI, PluginFunction } from 'vuepress-types' 2 | 3 | // eslint-disable-next-line @typescript-eslint/no-var-requires 4 | const Mergeable = require('deconstruct-merge') 5 | 6 | export type MergeType = 'array' | 'assign' | 'flat' | 'override' 7 | 8 | export interface MergeOptions { 9 | [key: string]: MergeType | MergeType[] | MergeOptions 10 | } 11 | 12 | function vuepressMergeable( 13 | plugin: Plugin, 14 | mergeOptions: MergeOptions, 15 | defaultOptions: T 16 | ): Plugin { 17 | let pluginFunction: PluginFunction 18 | if (typeof plugin !== 'function') { 19 | pluginFunction = (): PluginOptionAPI => plugin 20 | } else { 21 | pluginFunction = plugin 22 | } 23 | 24 | const config = new Mergeable(mergeOptions).merge(defaultOptions) 25 | 26 | return (options, context, pluginApi): PluginOptionAPI => { 27 | return pluginFunction(config.merge(options).value(), context, pluginApi) 28 | } 29 | } 30 | 31 | module.exports = vuepressMergeable 32 | -------------------------------------------------------------------------------- /packages/vuepress-mergeable/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "./src", 5 | "outDir": "./lib" 6 | }, 7 | "include": ["./src"] 8 | } 9 | -------------------------------------------------------------------------------- /packages/vuepress-mergeable/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": ["./src", "./test"] 4 | } 5 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-clean-urls/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [1.1.2](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-clean-urls@1.1.1...vuepress-plugin-clean-urls@1.1.2) (2020-09-01) 7 | 8 | **Note:** Version bump only for package vuepress-plugin-clean-urls 9 | 10 | ## [1.1.1](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-clean-urls@1.1.0...vuepress-plugin-clean-urls@1.1.1) (2019-11-29) 11 | 12 | **Note:** Version bump only for package vuepress-plugin-clean-urls 13 | 14 | # 1.1.0 (2019-11-20) 15 | 16 | ### Features 17 | 18 | - **vuepress-plugin-clean-urls:** migrate with types ([dcae684](https://github.com/vuepress/vuepress-community/commit/dcae6848542dcd002ba0cdf6099fbbc3cb771c52)) 19 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-clean-urls/README.md: -------------------------------------------------------------------------------- 1 | # vuepress-plugin-clean-urls 2 | 3 | > VuePress plugin for clean URLs 4 | 5 | ## Documentation 6 | 7 | [vuepress-community.netlify.app](https://vuepress-community.netlify.app) 8 | 9 | ## License 10 | 11 | [MIT](https://github.com/vuepress/vuepress-community/blob/main/LICENSE) © [VuePress Community](https://github.com/vuepress) 12 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-clean-urls/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vuepress-plugin-clean-urls", 3 | "version": "1.1.2", 4 | "description": "VuePress plugin for clean URLs", 5 | "keywords": [ 6 | "clean-url", 7 | "plugin", 8 | "url", 9 | "vuepress" 10 | ], 11 | "homepage": "https://github.com/vuepress", 12 | "bugs": { 13 | "url": "https://github.com/vuepress/vuepress-community/issues" 14 | }, 15 | "repository": { 16 | "type": "git", 17 | "url": "git+https://github.com/vuepress/vuepress-community.git" 18 | }, 19 | "license": "MIT", 20 | "author": "Shigma <1700011071@pku.edu.cn>", 21 | "contributors": [ 22 | "meteorlxy " 23 | ], 24 | "main": "lib/index.js", 25 | "types": "lib/index.d.ts", 26 | "files": [ 27 | "lib" 28 | ], 29 | "scripts": { 30 | "build": "rimraf lib && tsc -p tsconfig.build.json", 31 | "lint": "eslint --ext .ts src" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-clean-urls/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Plugin } from 'vuepress-types' 2 | 3 | export interface CleanUrlsPluginOptions { 4 | normalSuffix: string 5 | indexSuffix: string 6 | notFoundPath: string 7 | } 8 | 9 | const CleanUrlsPlugin: Plugin = ({ 10 | normalSuffix = '', 11 | indexSuffix = '/', 12 | notFoundPath = '/404.html', 13 | }) => ({ 14 | name: 'vuepress-plugin-clean-urls', 15 | 16 | extendPageData(page): void { 17 | const { regularPath, frontmatter = {} } = page 18 | if (frontmatter.permalink) return 19 | if (regularPath === '/404.html') { 20 | // path for 404 page 21 | page.path = notFoundPath 22 | } else if (regularPath.endsWith('.html')) { 23 | // normal path 24 | // e.g. foo/bar.md -> foo/bar.html 25 | page.path = regularPath.slice(0, -5) + normalSuffix 26 | } else if (regularPath.endsWith('/')) { 27 | // index path 28 | // e.g. foo/index.md -> foo/ 29 | page.path = regularPath.slice(0, -1) + indexSuffix 30 | } 31 | }, 32 | }) 33 | 34 | module.exports = CleanUrlsPlugin 35 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-clean-urls/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "./src", 5 | "outDir": "./lib" 6 | }, 7 | "include": ["./src"] 8 | } 9 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-clean-urls/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": ["./src", "./test"] 4 | } 5 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-container/.gitignore: -------------------------------------------------------------------------------- 1 | test/e2e/.temp 2 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-container/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [2.1.5](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-container@2.1.4...vuepress-plugin-container@2.1.5) (2020-09-01) 7 | 8 | ### Bug Fixes 9 | 10 | - dependency issues in typescript and container plugin ([#52](https://github.com/vuepress/vuepress-community/issues/52)) ([8a4c390](https://github.com/vuepress/vuepress-community/commit/8a4c39089e48ab9319ba15853a4a4782812af03f)) 11 | 12 | ## [2.1.4](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-container@2.1.3...vuepress-plugin-container@2.1.4) (2020-05-21) 13 | 14 | **Note:** Version bump only for package vuepress-plugin-container 15 | 16 | ## [2.1.3](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-container@2.1.2...vuepress-plugin-container@2.1.3) (2020-04-08) 17 | 18 | ### Bug Fixes 19 | 20 | - **plugin-container:** make title available in after option (close [#24](https://github.com/vuepress/vuepress-community/issues/24)) ([14a9009](https://github.com/vuepress/vuepress-community/commit/14a90092ac2053370b9d317e81ce231c226e18a8)) 21 | 22 | ## [2.1.2](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-container@2.1.1...vuepress-plugin-container@2.1.2) (2019-11-29) 23 | 24 | **Note:** Version bump only for package vuepress-plugin-container 25 | 26 | ## [2.1.1](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-container@2.1.0...vuepress-plugin-container@2.1.1) (2019-11-20) 27 | 28 | **Note:** Version bump only for package vuepress-plugin-container 29 | 30 | # 2.1.0 (2019-10-18) 31 | 32 | ### Features 33 | 34 | - **vuepress-plugin-container:** migrate with types ([76bdeac](https://github.com/vuepress/vuepress-community/commit/76bdeac3ae635a02840ddd3ec4efbd25dc596cab)) 35 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-container/README.md: -------------------------------------------------------------------------------- 1 | # vuepress-plugin-container 2 | 3 | > VuePress plugin for markdown container 4 | 5 | ## Documentation 6 | 7 | [vuepress-community.netlify.app](https://vuepress-community.netlify.app) 8 | 9 | ## License 10 | 11 | [MIT](https://github.com/vuepress/vuepress-community/blob/main/LICENSE) © [VuePress Community](https://github.com/vuepress) 12 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-container/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vuepress-plugin-container", 3 | "version": "2.1.5", 4 | "description": "VuePress plugin for markdown container", 5 | "keywords": [ 6 | "container", 7 | "markdown", 8 | "plugin", 9 | "vuepress" 10 | ], 11 | "homepage": "https://github.com/vuepress", 12 | "bugs": { 13 | "url": "https://github.com/vuepress/vuepress-community/issues" 14 | }, 15 | "repository": { 16 | "type": "git", 17 | "url": "git+https://github.com/vuepress/vuepress-community.git" 18 | }, 19 | "license": "MIT", 20 | "author": "Shigma <1700011071@pku.edu.cn>", 21 | "contributors": [ 22 | "meteorlxy " 23 | ], 24 | "main": "lib/index.js", 25 | "types": "lib/index.d.ts", 26 | "files": [ 27 | "lib" 28 | ], 29 | "scripts": { 30 | "build": "rimraf lib && tsc -p tsconfig.build.json", 31 | "lint": "eslint --ext .ts src test" 32 | }, 33 | "dependencies": { 34 | "@vuepress/shared-utils": "^1.2.0", 35 | "markdown-it-container": "^2.0.0" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-container/src/markdown-it-container.ts: -------------------------------------------------------------------------------- 1 | import Renderer from 'markdown-it/lib/renderer' 2 | import Token from 'markdown-it/lib/token' 3 | 4 | export type ContainerRenderFunction = ( 5 | tokens: Token[], 6 | index: number, 7 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 8 | options: any, 9 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 10 | env: any, 11 | self: Renderer 12 | ) => string 13 | 14 | export interface ContainerOptions { 15 | marker?: string 16 | validate?: (params: string) => boolean 17 | render?: ContainerRenderFunction 18 | } 19 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-container/test/e2e/__fragments__/hint-default.md: -------------------------------------------------------------------------------- 1 | ::: hint 2 | This is a hint. 3 | ::: 4 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-container/test/e2e/__fragments__/hint-locale-jp.md: -------------------------------------------------------------------------------- 1 | --- 2 | ENV: 3 | relativePath: jp/index.md 4 | --- 5 | 6 | ::: hint 7 | これはヒントです。 8 | ::: 9 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-container/test/e2e/__fragments__/hint-override.md: -------------------------------------------------------------------------------- 1 | ::: hint 提示 2 | 这是一句提示。 3 | ::: 4 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-container/test/e2e/__fragments__/theorem.md: -------------------------------------------------------------------------------- 1 | ::: theorem Newton's First Law 2 | In an inertial frame of reference, an object either remains at rest or continues to move at a constant velocity, unless acted upon by a force. 3 | ::: 4 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-container/test/e2e/__snapshots__/index.spec.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`vuepress-plugin-container hint-default.md 1`] = ` 4 |
5 |

💡 HINT

6 |

This is a hint.

7 |
8 | `; 9 | 10 | exports[`vuepress-plugin-container hint-locale-jp.md 1`] = ` 11 |
12 |

ヒント

13 |

これはヒントです。

14 |
15 | `; 16 | 17 | exports[`vuepress-plugin-container hint-override.md 1`] = ` 18 |
19 |

提示

20 |

这是一句提示。

21 |
22 | `; 23 | 24 | exports[`vuepress-plugin-container theorem.md 1`] = ` 25 |
26 |

Newton's First Law

27 |

In an inertial frame of reference, an object either remains at rest or continues to move at a constant velocity, unless acted upon by a force.

28 |
29 | `; 30 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-container/test/e2e/index.spec.ts: -------------------------------------------------------------------------------- 1 | import { App } from 'vuepress-types' 2 | import { fs, path, parseFrontmatter } from '@vuepress/shared-utils' 3 | import { createApp } from '@vuepress/core' 4 | 5 | const fragmentDir = path.join(__dirname, '__fragments__') 6 | 7 | describe('vuepress-plugin-container', () => { 8 | let app: App 9 | 10 | beforeAll(async () => { 11 | app = createApp({ 12 | temp: path.resolve(__dirname, '.temp'), 13 | plugins: [ 14 | [ 15 | 'vuepress-plugin-container', 16 | { 17 | type: 'hint', 18 | defaultTitle: { 19 | '/': '💡 HINT', 20 | '/jp/': 'ヒント', 21 | }, 22 | }, 23 | ], 24 | [ 25 | 'vuepress-plugin-container', 26 | { 27 | type: 'theorem', 28 | before: (info: string): string => 29 | `

${info}

`, 30 | after: '
', 31 | }, 32 | ], 33 | ], 34 | }) 35 | return app.process() 36 | }) 37 | 38 | fs.readdirSync(fragmentDir).forEach((name: string) => { 39 | const filePath = path.join(fragmentDir, name) 40 | const rawFile = fs.readFileSync(filePath, 'utf8') 41 | const { data, content } = parseFrontmatter(rawFile) 42 | test(name, () => { 43 | const { html } = app.markdown.render(content, { 44 | ...(data.ENV || {}), 45 | frontmatter: data, 46 | }) 47 | expect(html).toMatchSnapshot() 48 | }) 49 | }) 50 | }) 51 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-container/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "./src", 5 | "outDir": "./lib" 6 | }, 7 | "include": ["./src"] 8 | } 9 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-container/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": ["./src", "./test"] 4 | } 5 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-dehydrate/.gitignore: -------------------------------------------------------------------------------- 1 | test/e2e/dist 2 | test/e2e/.temp 3 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-dehydrate/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [1.1.5](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-dehydrate@1.1.4...vuepress-plugin-dehydrate@1.1.5) (2020-09-01) 7 | 8 | ### Bug Fixes 9 | 10 | - **plugin-dehydrate:** find string in a right way ([#53](https://github.com/vuepress/vuepress-community/issues/53)) ([549c900](https://github.com/vuepress/vuepress-community/commit/549c90022fad38f25c8aa264238d5c57ecc1811e)) 11 | 12 | ## [1.1.4](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-dehydrate@1.1.3...vuepress-plugin-dehydrate@1.1.4) (2020-05-21) 13 | 14 | **Note:** Version bump only for package vuepress-plugin-dehydrate 15 | 16 | ## [1.1.3](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-dehydrate@1.1.2...vuepress-plugin-dehydrate@1.1.3) (2020-02-03) 17 | 18 | **Note:** Version bump only for package vuepress-plugin-dehydrate 19 | 20 | ## [1.1.2](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-dehydrate@1.1.1...vuepress-plugin-dehydrate@1.1.2) (2020-01-03) 21 | 22 | **Note:** Version bump only for package vuepress-plugin-dehydrate 23 | 24 | ## [1.1.1](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-dehydrate@1.1.0...vuepress-plugin-dehydrate@1.1.1) (2019-11-29) 25 | 26 | **Note:** Version bump only for package vuepress-plugin-dehydrate 27 | 28 | # 1.1.0 (2019-11-20) 29 | 30 | ### Features 31 | 32 | - **vuepress-plugin-dehydrate:** migrate with types ([748872b](https://github.com/vuepress/vuepress-community/commit/748872bafaadad941798412665d0e20d077999fb)) 33 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-dehydrate/README.md: -------------------------------------------------------------------------------- 1 | # vuepress-plugin-dehydrate 2 | 3 | > VuePress plugin to dehydrate generated HTML files 4 | 5 | ## Documentation 6 | 7 | [vuepress-community.netlify.app](https://vuepress-community.netlify.app) 8 | 9 | ## License 10 | 11 | [MIT](https://github.com/vuepress/vuepress-community/blob/main/LICENSE) © [VuePress Community](https://github.com/vuepress) 12 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-dehydrate/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vuepress-plugin-dehydrate", 3 | "version": "1.1.5", 4 | "description": "VuePress plugin to dehydrate generated HTML files", 5 | "keywords": [ 6 | "build", 7 | "dehydrate", 8 | "plugin", 9 | "server", 10 | "ssr", 11 | "vuepress" 12 | ], 13 | "homepage": "https://github.com/vuepress", 14 | "bugs": { 15 | "url": "https://github.com/vuepress/vuepress-community/issues" 16 | }, 17 | "repository": { 18 | "type": "git", 19 | "url": "git+https://github.com/vuepress/vuepress-community.git" 20 | }, 21 | "license": "MIT", 22 | "author": "Shigma <1700011071@pku.edu.cn>", 23 | "contributors": [ 24 | "meteorlxy " 25 | ], 26 | "main": "lib/index.js", 27 | "types": "lib/index.d.ts", 28 | "files": [ 29 | "lib" 30 | ], 31 | "scripts": { 32 | "build": "rimraf lib && tsc -p tsconfig.build.json", 33 | "lint": "eslint --ext .ts,.vue src test" 34 | }, 35 | "dependencies": { 36 | "@vuepress/shared-utils": "^1.2.0" 37 | }, 38 | "devDependencies": { 39 | "@vuepress/core": "^1.2.0" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-dehydrate/test/e2e/__snapshots__/index.spec.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`vuepress-plugin-dehydrate 404.html 1`] = ` 4 | 5 | 6 | 7 | 8 | 9 | 10 | VuePress 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 | 32 | `; 33 | 34 | exports[`vuepress-plugin-dehydrate index.html 1`] = ` 35 | 36 | 37 | 38 | 39 | 40 | 41 | VuePress 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 |
57 |
58 |

readme

59 |
60 |
61 |
62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | `; 70 | 71 | exports[`vuepress-plugin-dehydrate noscript.html 1`] = ` 72 | 73 | 74 | 75 | 76 | 77 | 78 | VuePress 79 | 80 | 81 | 82 | 83 | 84 | 85 |
86 |
87 |

noscript

88 |
89 |
90 |
91 | 92 | 93 | 94 | `; 95 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-dehydrate/test/e2e/docs/.vuepress/config.js: -------------------------------------------------------------------------------- 1 | const CSSExtractPlugin = require('mini-css-extract-plugin') 2 | 3 | module.exports = { 4 | plugins: [ 5 | [ 6 | 'vuepress-plugin-dehydrate', 7 | { 8 | noScript: 'noscript.html', 9 | }, 10 | ], 11 | ], 12 | 13 | evergreen: false, 14 | 15 | chainWebpack(config) { 16 | // do not use chunk hash in js 17 | config.output.filename('assets/js/[name].js') 18 | 19 | // do not use chunk hash in css 20 | config.plugin('extract-css').use(CSSExtractPlugin, [ 21 | { 22 | filename: 'assets/css/styles.css', 23 | }, 24 | ]) 25 | }, 26 | } 27 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-dehydrate/test/e2e/docs/.vuepress/theme/layouts/Layout.vue: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-dehydrate/test/e2e/docs/README.md: -------------------------------------------------------------------------------- 1 | readme 2 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-dehydrate/test/e2e/docs/noscript.md: -------------------------------------------------------------------------------- 1 | noscript 2 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-dehydrate/test/e2e/index.spec.ts: -------------------------------------------------------------------------------- 1 | import { resolve } from 'path' 2 | import { readFileSync } from 'fs' 3 | import { createApp } from '@vuepress/core' 4 | 5 | describe('vuepress-plugin-dehydrate', () => { 6 | process.env.NODE_ENV = 'production' 7 | 8 | const app = createApp({ 9 | sourceDir: resolve(__dirname, 'docs'), 10 | dest: resolve(__dirname, 'dist'), 11 | temp: resolve(__dirname, '.temp'), 12 | }) 13 | 14 | beforeAll(async () => { 15 | await app.process() 16 | await app.build() 17 | }, 60000) 18 | 19 | function testForFile(name: string, file = name) { 20 | test(name, () => { 21 | const html = readFileSync(resolve(app.outDir, file), 'utf8') 22 | expect(html).toMatchSnapshot() 23 | }) 24 | } 25 | 26 | testForFile('404.html') 27 | testForFile('index.html') 28 | testForFile('noscript.html') 29 | }) 30 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-dehydrate/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "./src", 5 | "outDir": "./lib" 6 | }, 7 | "include": ["./src"] 8 | } 9 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-dehydrate/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": ["./src", "./test"] 4 | } 5 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-medium-zoom/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [1.1.9](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-medium-zoom@1.1.8...vuepress-plugin-medium-zoom@1.1.9) (2020-09-01) 7 | 8 | **Note:** Version bump only for package vuepress-plugin-medium-zoom 9 | 10 | ## [1.1.8](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-medium-zoom@1.1.7...vuepress-plugin-medium-zoom@1.1.8) (2019-11-29) 11 | 12 | **Note:** Version bump only for package vuepress-plugin-medium-zoom 13 | 14 | ## [1.1.7](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-medium-zoom@1.1.6...vuepress-plugin-medium-zoom@1.1.7) (2019-11-20) 15 | 16 | **Note:** Version bump only for package vuepress-plugin-medium-zoom 17 | 18 | ## [1.1.6](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-medium-zoom@1.1.4...vuepress-plugin-medium-zoom@1.1.6) (2019-10-18) 19 | 20 | ### Bug Fixes 21 | 22 | - **vuepress-plugin-medium-zoom:** add options type ([e196a0b](https://github.com/vuepress/vuepress-community/commit/e196a0ba2716b287699c91bab488e6ac77356646)) 23 | 24 | ## 1.1.4 (2019-10-12) 25 | 26 | ### Bug Fixes 27 | 28 | - **vuepress-plugin-medium-zoom:** update types ([e068456](https://github.com/vuepress/vuepress-community/commit/e068456)) 29 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-medium-zoom/README.md: -------------------------------------------------------------------------------- 1 | # vuepress-plugin-medium-zoom 2 | 3 | > VuePress plugin for medium-zoom 4 | 5 | ## Documentation 6 | 7 | [vuepress-community.netlify.app](https://vuepress-community.netlify.app) 8 | 9 | ## License 10 | 11 | [MIT](https://github.com/vuepress/vuepress-community/blob/main/LICENSE) © [VuePress Community](https://github.com/vuepress) 12 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-medium-zoom/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vuepress-plugin-medium-zoom", 3 | "version": "1.1.9", 4 | "description": "VuePress plugin for medium-zoom", 5 | "keywords": [ 6 | "image", 7 | "medium-zoom", 8 | "plugin", 9 | "vuepress", 10 | "zoom" 11 | ], 12 | "homepage": "https://github.com/vuepress", 13 | "bugs": { 14 | "url": "https://github.com/vuepress/vuepress-community/issues" 15 | }, 16 | "repository": { 17 | "type": "git", 18 | "url": "git+https://github.com/vuepress/vuepress-community.git" 19 | }, 20 | "license": "MIT", 21 | "author": "meteorlxy ", 22 | "main": "lib/index.js", 23 | "types": "lib/index.d.ts", 24 | "files": [ 25 | "lib", 26 | "styles" 27 | ], 28 | "scripts": { 29 | "build": "rimraf lib && tsc -p tsconfig.build.json", 30 | "lint": "eslint --ext .ts src" 31 | }, 32 | "dependencies": { 33 | "medium-zoom": "^1.0.4" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-medium-zoom/src/VuepressMediumZoom.ts: -------------------------------------------------------------------------------- 1 | import mediumZoom, { Zoom } from 'medium-zoom' 2 | 3 | declare const MZ_SELECTOR: string 4 | declare const MZ_OPTIONS: string 5 | declare const MZ_DELAY: string 6 | 7 | const mzSelector = MZ_SELECTOR 8 | const mzOptions = JSON.parse(MZ_OPTIONS) 9 | const mzDelay = Number(MZ_DELAY) 10 | 11 | export class VuepressMediumZoom { 12 | instance: Zoom | null = null 13 | 14 | update(selector = mzSelector): void { 15 | if (typeof window === 'undefined') return 16 | if (this.instance === null) { 17 | this.instance = mediumZoom(selector, mzOptions) 18 | } else { 19 | this.instance.detach() 20 | this.instance.attach(selector) 21 | } 22 | } 23 | 24 | updateDelay(selector = mzSelector, delay = mzDelay): void { 25 | setTimeout(() => this.update(selector), delay) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-medium-zoom/src/clientRootMixin.ts: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import { VuepressMediumZoom } from './VuepressMediumZoom' 3 | import '../styles/index.styl' 4 | 5 | declare module 'vuepress-types/types/store' { 6 | interface VuePressStore { 7 | mediumZoom: VuepressMediumZoom 8 | } 9 | } 10 | 11 | export default { 12 | watch: { 13 | '$page.path'(this: Vue): void { 14 | if (typeof this.$vuepress.mediumZoom === 'undefined') return 15 | this.$vuepress.mediumZoom.updateDelay() 16 | }, 17 | }, 18 | 19 | mounted(this: Vue): void { 20 | this.$vuepress.mediumZoom = new VuepressMediumZoom() 21 | this.$vuepress.mediumZoom.updateDelay() 22 | }, 23 | } 24 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-medium-zoom/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Plugin } from 'vuepress-types' 2 | import { ZoomOptions } from 'medium-zoom' 3 | 4 | // eslint-disable-next-line @typescript-eslint/no-var-requires 5 | const path = require('path') 6 | 7 | export interface MediumZoomPluginOptions { 8 | selector: string 9 | options: ZoomOptions 10 | delay: number 11 | } 12 | 13 | const MediumZoomPlugin: Plugin = ({ 14 | selector = '.theme-default-content img', 15 | options = {}, 16 | delay = 500, 17 | }) => ({ 18 | name: 'vuepress-plugin-medium-zoom', 19 | 20 | clientRootMixin: path.resolve(__dirname, 'clientRootMixin.js'), 21 | 22 | define: { 23 | MZ_SELECTOR: selector, 24 | MZ_OPTIONS: JSON.stringify(options), 25 | MZ_DELAY: delay.toString(), 26 | }, 27 | }) 28 | 29 | module.exports = MediumZoomPlugin 30 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-medium-zoom/styles/index.styl: -------------------------------------------------------------------------------- 1 | $mediumZoomZIndex ?= 100 2 | 3 | .medium-zoom-overlay 4 | z-index $mediumZoomZIndex 5 | 6 | .medium-zoom-overlay ~ img 7 | z-index $mediumZoomZIndex + 1 8 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-medium-zoom/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "./src", 5 | "outDir": "./lib" 6 | }, 7 | "include": ["./src"] 8 | } 9 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-medium-zoom/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": ["./src", "./test"] 4 | } 5 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-named-chunks/.gitignore: -------------------------------------------------------------------------------- 1 | test/e2e/dist 2 | test/e2e/.temp 3 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-named-chunks/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [1.1.4](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-named-chunks@1.1.3...vuepress-plugin-named-chunks@1.1.4) (2020-09-01) 7 | 8 | **Note:** Version bump only for package vuepress-plugin-named-chunks 9 | 10 | ## [1.1.3](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-named-chunks@1.1.2...vuepress-plugin-named-chunks@1.1.3) (2020-05-21) 11 | 12 | **Note:** Version bump only for package vuepress-plugin-named-chunks 13 | 14 | ## [1.1.2](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-named-chunks@1.1.1...vuepress-plugin-named-chunks@1.1.2) (2020-02-03) 15 | 16 | **Note:** Version bump only for package vuepress-plugin-named-chunks 17 | 18 | ## [1.1.1](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-named-chunks@1.1.0...vuepress-plugin-named-chunks@1.1.1) (2020-01-03) 19 | 20 | **Note:** Version bump only for package vuepress-plugin-named-chunks 21 | 22 | # 1.1.0 (2019-12-27) 23 | 24 | ### Features 25 | 26 | - **plugin-named-chunks:** migrate with types ([e39fe0f](https://github.com/vuepress/vuepress-community/commit/e39fe0f1cc6badfa54540300718d688222bf168b)) 27 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-named-chunks/README.md: -------------------------------------------------------------------------------- 1 | # vuepress-plugin-named-chunks 2 | 3 | > VuePress plugin to track chunks 4 | 5 | ## Documentation 6 | 7 | [vuepress-community.netlify.app](https://vuepress-community.netlify.app) 8 | 9 | ## License 10 | 11 | [MIT](https://github.com/vuepress/vuepress-community/blob/main/LICENSE) © [VuePress Community](https://github.com/vuepress) 12 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-named-chunks/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vuepress-plugin-named-chunks", 3 | "version": "1.1.4", 4 | "description": "VuePress plugin to track chunks", 5 | "keywords": [ 6 | "chunks", 7 | "plugin", 8 | "vuepress", 9 | "webpack" 10 | ], 11 | "homepage": "https://github.com/vuepress", 12 | "bugs": { 13 | "url": "https://github.com/vuepress/vuepress-community/issues" 14 | }, 15 | "repository": { 16 | "type": "git", 17 | "url": "git+https://github.com/vuepress/vuepress-community.git" 18 | }, 19 | "license": "MIT", 20 | "author": "Shigma <1700011071@pku.edu.cn>", 21 | "contributors": [ 22 | "meteorlxy " 23 | ], 24 | "main": "lib/index.js", 25 | "types": "lib/index.d.ts", 26 | "files": [ 27 | "lib" 28 | ], 29 | "scripts": { 30 | "build": "rimraf lib && tsc -p tsconfig.build.json", 31 | "lint": "eslint --ext .ts src" 32 | }, 33 | "devDependencies": { 34 | "@vuepress/core": "^1.2.0" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-named-chunks/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Plugin, Page, ResolvedComponent } from 'vuepress-types' 2 | 3 | export interface NamedChunksPluginOptions { 4 | pageChunkName: ((page: Page) => string) | false 5 | layoutChunkName: ((layout: ResolvedComponent) => string) | false 6 | } 7 | 8 | declare module 'vuepress-types/types/page' { 9 | interface Page { 10 | _chunkName?: string 11 | } 12 | } 13 | 14 | declare module 'vuepress-types/types/theme-api' { 15 | interface ResolvedComponent { 16 | _chunkName?: string 17 | } 18 | } 19 | 20 | const NamedChunksPlugin: Plugin = ( 21 | { 22 | pageChunkName = ({ key }): string => 'page' + key.slice(1), 23 | layoutChunkName, 24 | }, 25 | context 26 | ) => { 27 | // override internal plugins 28 | const plugins: Plugin[] = [] 29 | 30 | if (pageChunkName) { 31 | plugins.push({ 32 | name: '@vuepress/internal-page-components', 33 | 34 | extendPageData(page) { 35 | page._chunkName = pageChunkName(page) 36 | }, 37 | 38 | async clientDynamicModules() { 39 | const content = `export default {\n${context.pages 40 | .filter(({ _filePath }) => _filePath) 41 | .map((page) => { 42 | const key = JSON.stringify(page.key) 43 | const filePath = JSON.stringify(page._filePath) 44 | const comment = page._chunkName 45 | ? `/* webpackChunkName: ${JSON.stringify(page._chunkName)} */` 46 | : '' 47 | return ` ${key}: () => import(${comment}${filePath})` 48 | }) 49 | .join(',\n')} \n}` 50 | 51 | return { 52 | dirname: 'internal', 53 | name: 'page-components.js', 54 | content, 55 | } 56 | }, 57 | }) 58 | } 59 | 60 | if (layoutChunkName) { 61 | const { layoutComponentMap } = context.themeAPI 62 | for (const key in layoutComponentMap) { 63 | const component = layoutComponentMap[key] 64 | component._chunkName = layoutChunkName(component) 65 | } 66 | 67 | plugins.push({ 68 | name: '@vuepress/internal-layout-components', 69 | 70 | async clientDynamicModules() { 71 | const { layoutComponentMap } = context.themeAPI 72 | const content = `export default {\n${Object.keys(layoutComponentMap) 73 | .map((name) => { 74 | const component = layoutComponentMap[name] 75 | const key = JSON.stringify(name) 76 | const filePath = JSON.stringify(component.path) 77 | const comment = component._chunkName 78 | ? `/* webpackChunkName: ${JSON.stringify( 79 | component._chunkName 80 | )} */` 81 | : '' 82 | return ` ${key}: () => import(${comment}${filePath})` 83 | }) 84 | .join(',\n')} \n}` 85 | 86 | return { 87 | dirname: 'internal', 88 | name: 'layout-components.js', 89 | content, 90 | } 91 | }, 92 | }) 93 | } 94 | 95 | return { 96 | name: 'vuepress-plugin-named-chunks', 97 | 98 | plugins, 99 | } 100 | } 101 | 102 | module.exports = NamedChunksPlugin 103 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-named-chunks/test/e2e/__snapshots__/index.spec.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`vuepress-plugin-named-chunks custom.html 1`] = ` 4 | 5 | 6 | 7 | 8 | 9 | 10 | VuePress 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |

Custom

30 |
31 |
32 |
33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | `; 41 | 42 | exports[`vuepress-plugin-named-chunks index.html 1`] = ` 43 | 44 | 45 | 46 | 47 | 48 | 49 | VuePress 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 |
67 |
68 |

readme

69 |
70 |
71 |
72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | `; 80 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-named-chunks/test/e2e/docs/.vuepress/config.js: -------------------------------------------------------------------------------- 1 | const { hash } = require('@vuepress/shared-utils') 2 | const CSSExtractPlugin = require('mini-css-extract-plugin') 3 | 4 | module.exports = { 5 | plugins: [ 6 | [ 7 | 'vuepress-plugin-named-chunks', 8 | { 9 | pageChunkName({ key, frontmatter }) { 10 | const name = frontmatter.layout || key.slice(2) 11 | return `page-${name}` 12 | }, 13 | layoutChunkName({ componentName: name }) { 14 | return `layout-${name}` 15 | }, 16 | }, 17 | ], 18 | ], 19 | 20 | extendPageData(page) { 21 | // generate page keys depending on relative path 22 | page.key = 'v-' + hash(page.path) 23 | }, 24 | 25 | evergreen: false, 26 | 27 | chainWebpack(config) { 28 | // do not use chunk hash in js 29 | config.output.filename('assets/js/[name].js') 30 | 31 | // do not use chunk hash in css 32 | config.plugin('extract-css').use(CSSExtractPlugin, [ 33 | { 34 | filename: 'assets/css/styles.css', 35 | }, 36 | ]) 37 | }, 38 | } 39 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-named-chunks/test/e2e/docs/.vuepress/theme/layouts/Custom.vue: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-named-chunks/test/e2e/docs/.vuepress/theme/layouts/Layout.vue: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-named-chunks/test/e2e/docs/README.md: -------------------------------------------------------------------------------- 1 | readme 2 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-named-chunks/test/e2e/docs/custom.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: Custom 3 | --- 4 | 5 | Custom 6 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-named-chunks/test/e2e/index.spec.ts: -------------------------------------------------------------------------------- 1 | import { resolve } from 'path' 2 | import { readFileSync } from 'fs' 3 | import { createApp } from '@vuepress/core' 4 | 5 | describe('vuepress-plugin-named-chunks', () => { 6 | process.env.NODE_ENV = 'production' 7 | 8 | const app = createApp({ 9 | sourceDir: resolve(__dirname, 'docs'), 10 | dest: resolve(__dirname, 'dist'), 11 | temp: resolve(__dirname, '.temp'), 12 | }) 13 | 14 | beforeAll(async () => { 15 | await app.process() 16 | await app.build() 17 | }, 60000) 18 | 19 | function testForFile(name: string, file = name) { 20 | test(name, () => { 21 | const html = readFileSync(resolve(app.outDir, file), 'utf8') 22 | expect(html).toMatchSnapshot() 23 | }) 24 | } 25 | 26 | testForFile('index.html') 27 | testForFile('custom.html') 28 | }) 29 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-named-chunks/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "./src", 5 | "outDir": "./lib" 6 | }, 7 | "include": ["./src"] 8 | } 9 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-named-chunks/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": ["./src", "./test"] 4 | } 5 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-nprogress/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [1.1.8](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-nprogress@1.1.7...vuepress-plugin-nprogress@1.1.8) (2020-09-01) 7 | 8 | **Note:** Version bump only for package vuepress-plugin-nprogress 9 | 10 | ## [1.1.7](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-nprogress@1.1.6...vuepress-plugin-nprogress@1.1.7) (2020-05-21) 11 | 12 | **Note:** Version bump only for package vuepress-plugin-nprogress 13 | 14 | ## [1.1.6](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-nprogress@1.1.5...vuepress-plugin-nprogress@1.1.6) (2019-11-29) 15 | 16 | **Note:** Version bump only for package vuepress-plugin-nprogress 17 | 18 | ## [1.1.5](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-nprogress@1.1.4...vuepress-plugin-nprogress@1.1.5) (2019-11-20) 19 | 20 | **Note:** Version bump only for package vuepress-plugin-nprogress 21 | 22 | ## [1.1.4](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-nprogress@1.1.2...vuepress-plugin-nprogress@1.1.4) (2019-10-18) 23 | 24 | **Note:** Version bump only for package vuepress-plugin-nprogress 25 | 26 | ## 1.1.2 (2019-10-12) 27 | 28 | **Note:** Version bump only for package vuepress-plugin-nprogress 29 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-nprogress/README.md: -------------------------------------------------------------------------------- 1 | # vuepress-plugin-nprogress 2 | 3 | > VuePress plugin for nprogress 4 | 5 | ## Documentation 6 | 7 | [vuepress-community.netlify.app](https://vuepress-community.netlify.app) 8 | 9 | ## License 10 | 11 | [MIT](https://github.com/vuepress/vuepress-community/blob/main/LICENSE) © [VuePress Community](https://github.com/vuepress) 12 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-nprogress/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vuepress-plugin-nprogress", 3 | "version": "1.1.8", 4 | "description": "VuePress plugin for nprogress", 5 | "keywords": [ 6 | "nprogress", 7 | "plugin", 8 | "vuepress" 9 | ], 10 | "homepage": "https://github.com/vuepress", 11 | "bugs": { 12 | "url": "https://github.com/vuepress/vuepress-community/issues" 13 | }, 14 | "repository": { 15 | "type": "git", 16 | "url": "git+https://github.com/vuepress/vuepress-community.git" 17 | }, 18 | "license": "MIT", 19 | "author": "meteorlxy ", 20 | "main": "lib/index.js", 21 | "types": "lib/index.d.ts", 22 | "files": [ 23 | "lib", 24 | "styles" 25 | ], 26 | "scripts": { 27 | "build": "rimraf lib && tsc -p tsconfig.build.json", 28 | "lint": "eslint --ext .ts src" 29 | }, 30 | "dependencies": { 31 | "nprogress": "^0.2.0" 32 | }, 33 | "devDependencies": { 34 | "@types/nprogress": "^0.2.0" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-nprogress/src/clientRootMixin.ts: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import nprogress from 'nprogress' 3 | import '../styles/index.styl' 4 | 5 | export default { 6 | mounted(this: Vue): void { 7 | const loadedPages = Object.create(null) 8 | nprogress.configure({ showSpinner: false }) 9 | 10 | this.$router.beforeEach((to, from, next) => { 11 | if (!loadedPages[to.path]) { 12 | nprogress.start() 13 | } 14 | next() 15 | }) 16 | 17 | this.$router.afterEach((to) => { 18 | loadedPages[to.path] = true 19 | nprogress.done() 20 | }) 21 | }, 22 | } 23 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-nprogress/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Plugin } from 'vuepress-types' 2 | 3 | // eslint-disable-next-line @typescript-eslint/no-var-requires 4 | const path = require('path') 5 | 6 | const NprogressPlugin: Plugin = { 7 | name: 'vuepress-plugin-nprogress', 8 | 9 | clientRootMixin: path.resolve(__dirname, 'clientRootMixin.js'), 10 | } 11 | 12 | module.exports = NprogressPlugin 13 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-nprogress/styles/index.styl: -------------------------------------------------------------------------------- 1 | $nprogressColor ?= $accentColor 2 | 3 | #nprogress 4 | pointer-events none 5 | .bar 6 | background $nprogressColor 7 | position fixed 8 | z-index 1031 9 | top 0 10 | left 0 11 | width 100% 12 | height 2px 13 | .peg 14 | display block 15 | position absolute 16 | right 0px 17 | width 100px 18 | height 100% 19 | box-shadow 0 0 10px $nprogressColor, 0 0 5px $nprogressColor 20 | opacity 1.0 21 | transform rotate(3deg) translate(0px, -4px) 22 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-nprogress/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "./src", 5 | "outDir": "./lib" 6 | }, 7 | "include": ["./src"] 8 | } 9 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-nprogress/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": ["./src", "./test"] 4 | } 5 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-redirect/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [1.2.5](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-redirect@1.2.4...vuepress-plugin-redirect@1.2.5) (2020-09-01) 7 | 8 | **Note:** Version bump only for package vuepress-plugin-redirect 9 | 10 | ## [1.2.4](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-redirect@1.2.3...vuepress-plugin-redirect@1.2.4) (2020-05-21) 11 | 12 | **Note:** Version bump only for package vuepress-plugin-redirect 13 | 14 | ## [1.2.3](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-redirect@1.2.2...vuepress-plugin-redirect@1.2.3) (2020-02-03) 15 | 16 | **Note:** Version bump only for package vuepress-plugin-redirect 17 | 18 | ## [1.2.2](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-redirect@1.2.1...vuepress-plugin-redirect@1.2.2) (2020-01-03) 19 | 20 | **Note:** Version bump only for package vuepress-plugin-redirect 21 | 22 | ## [1.2.1](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-redirect@1.2.0...vuepress-plugin-redirect@1.2.1) (2019-11-29) 23 | 24 | ### Bug Fixes 25 | 26 | - **plugin-redirect:** window is undefined error in build mode ([5388fc7](https://github.com/vuepress/vuepress-community/commit/5388fc7e115d2f8935cd696ce9c864f086b8d379)) 27 | 28 | # 1.2.0 (2019-11-20) 29 | 30 | ### Features 31 | 32 | - **vuepress-plugin-redirect:** migrate with types ([54990e1](https://github.com/vuepress/vuepress-community/commit/54990e1e47e642ce3db304a2eb1d6cb4aab44cf7)) 33 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-redirect/README.md: -------------------------------------------------------------------------------- 1 | # vuepress-plugin-redirect 2 | 3 | > VuePress plugin to handle redirection 4 | 5 | ## Documentation 6 | 7 | [vuepress-community.netlify.app](https://vuepress-community.netlify.app) 8 | 9 | ## License 10 | 11 | [MIT](https://github.com/vuepress/vuepress-community/blob/main/LICENSE) © [VuePress Community](https://github.com/vuepress) 12 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-redirect/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vuepress-plugin-redirect", 3 | "version": "1.2.5", 4 | "description": "VuePress plugin to handle redirection", 5 | "keywords": [ 6 | "i18n", 7 | "plugin", 8 | "redirect", 9 | "router", 10 | "vuepress" 11 | ], 12 | "homepage": "https://github.com/vuepress", 13 | "bugs": { 14 | "url": "https://github.com/vuepress/vuepress-community/issues" 15 | }, 16 | "repository": { 17 | "type": "git", 18 | "url": "git+https://github.com/vuepress/vuepress-community.git" 19 | }, 20 | "license": "MIT", 21 | "author": "Shigma <1700011071@pku.edu.cn>", 22 | "contributors": [ 23 | "meteorlxy " 24 | ], 25 | "main": "lib/index.js", 26 | "types": "lib/index.d.ts", 27 | "files": [ 28 | "lib" 29 | ], 30 | "scripts": { 31 | "build": "rimraf lib && tsc -p tsconfig.build.json", 32 | "lint": "eslint --ext .ts src" 33 | }, 34 | "dependencies": { 35 | "@shigma/stringify-object": "^3.3.0", 36 | "vuepress-plugin-dehydrate": "1.1.5" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-redirect/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Plugin, PluginGeneratedFile } from 'vuepress-types' 2 | 3 | /* eslint-disable @typescript-eslint/no-var-requires */ 4 | const path = require('path') 5 | const stringify = require('@shigma/stringify-object') 6 | /* eslint-enable @typescript-eslint/no-var-requires */ 7 | 8 | export interface RedirectorStorage { 9 | get(redirector: Redirector): string | null 10 | set(value: string, redirector: Redirector): void 11 | } 12 | 13 | export interface Redirector { 14 | base?: string 15 | storage?: boolean | string | RedirectorStorage 16 | alternative?: string | string[] | ((rel: string) => string | string[]) 17 | } 18 | 19 | export interface LocalesRedirector { 20 | fallback?: string 21 | storage?: boolean | string | RedirectorStorage 22 | } 23 | 24 | export interface RedirectPluginOptions { 25 | locales?: true | LocalesRedirector 26 | redirectors?: Redirector[] 27 | } 28 | 29 | const RedirectPlugin: Plugin = (options) => ({ 30 | name: 'vuepress-plugin-redirect', 31 | 32 | // workaround SSR mismatch in 404.html 33 | plugins: ['dehydrate'], 34 | 35 | enhanceAppFiles: path.resolve(__dirname, 'enhanceApp.js'), 36 | 37 | clientDynamicModules(): PluginGeneratedFile { 38 | return { 39 | name: 'plugin-redirect-options.js', 40 | content: `export default ${stringify(options)}`, 41 | } 42 | }, 43 | }) 44 | 45 | module.exports = RedirectPlugin 46 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-redirect/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "./src", 5 | "outDir": "./lib" 6 | }, 7 | "include": ["./src"] 8 | } 9 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-redirect/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": ["./src", "./test"] 4 | } 5 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-serve/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [2.0.4](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-serve@2.0.3...vuepress-plugin-serve@2.0.4) (2020-09-01) 7 | 8 | **Note:** Version bump only for package vuepress-plugin-serve 9 | 10 | ## [2.0.3](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-serve@2.0.2...vuepress-plugin-serve@2.0.3) (2020-05-21) 11 | 12 | **Note:** Version bump only for package vuepress-plugin-serve 13 | 14 | ## [2.0.2](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-serve@2.0.1...vuepress-plugin-serve@2.0.2) (2020-04-08) 15 | 16 | **Note:** Version bump only for package vuepress-plugin-serve 17 | 18 | ## [2.0.1](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-serve@2.0.0...vuepress-plugin-serve@2.0.1) (2020-02-20) 19 | 20 | **Note:** Version bump only for package vuepress-plugin-serve 21 | 22 | # 2.0.0 (2020-02-03) 23 | 24 | ### Features 25 | 26 | - **plugin-serve:** migrate with types ([c73bb8d](https://github.com/vuepress/vuepress-community/commit/c73bb8da38fec18ddf771cb7d85c4fa10a494319)) 27 | 28 | ### BREAKING CHANGES 29 | 30 | - **plugin-serve:** remove `chainWebpack`, `alias`, `define` options 31 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-serve/README.md: -------------------------------------------------------------------------------- 1 | # vuepress-plugin-serve 2 | 3 | > VuePress plugin for serving generated files 4 | 5 | ## Documentation 6 | 7 | [vuepress-community.netlify.app](https://vuepress-community.netlify.app) 8 | 9 | ## License 10 | 11 | [MIT](https://github.com/vuepress/vuepress-community/blob/main/LICENSE) © [VuePress Community](https://github.com/vuepress) 12 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-serve/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vuepress-plugin-serve", 3 | "version": "2.0.4", 4 | "description": "VuePress plugin to serve generated files", 5 | "keywords": [ 6 | "server", 7 | "plugin", 8 | "static", 9 | "build", 10 | "vuepress" 11 | ], 12 | "homepage": "https://github.com/vuepress", 13 | "bugs": { 14 | "url": "https://github.com/vuepress/vuepress-community/issues" 15 | }, 16 | "repository": { 17 | "type": "git", 18 | "url": "git+https://github.com/vuepress/vuepress-community.git" 19 | }, 20 | "license": "MIT", 21 | "author": "Shigma <1700011071@pku.edu.cn>", 22 | "contributors": [ 23 | "meteorlxy " 24 | ], 25 | "main": "lib/index.js", 26 | "types": "lib/index.d.ts", 27 | "files": [ 28 | "lib" 29 | ], 30 | "scripts": { 31 | "build": "rimraf lib && tsc -p tsconfig.build.json", 32 | "lint": "eslint --ext .ts src" 33 | }, 34 | "dependencies": { 35 | "chalk": "^2.4.2", 36 | "express": "^4.16.4", 37 | "opn": "^5.4.0" 38 | }, 39 | "devDependencies": { 40 | "@types/express": "^4.17.2", 41 | "@types/serve-static": "^1.13.3" 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-serve/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "./src", 5 | "outDir": "./lib" 6 | }, 7 | "include": ["./src"] 8 | } 9 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-serve/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": ["./src", "./test"] 4 | } 5 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-smooth-scroll/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [0.0.10](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-smooth-scroll@0.0.9...vuepress-plugin-smooth-scroll@0.0.10) (2020-09-01) 7 | 8 | ### Bug Fixes 9 | 10 | - **plugin-smooth-scroll:** get target element by id or name ([#58](https://github.com/vuepress/vuepress-community/issues/58)) ([6ce05cf](https://github.com/vuepress/vuepress-community/commit/6ce05cf3c9eb3f29236e327edaf09a24b3fdc0e6)) 11 | 12 | ## [0.0.9](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-smooth-scroll@0.0.8...vuepress-plugin-smooth-scroll@0.0.9) (2019-11-29) 13 | 14 | **Note:** Version bump only for package vuepress-plugin-smooth-scroll 15 | 16 | ## [0.0.8](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-smooth-scroll@0.0.7...vuepress-plugin-smooth-scroll@0.0.8) (2019-11-20) 17 | 18 | **Note:** Version bump only for package vuepress-plugin-smooth-scroll 19 | 20 | ## [0.0.7](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-smooth-scroll@0.0.5...vuepress-plugin-smooth-scroll@0.0.7) (2019-10-18) 21 | 22 | **Note:** Version bump only for package vuepress-plugin-smooth-scroll 23 | 24 | ## [0.0.5](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-smooth-scroll@0.0.4...vuepress-plugin-smooth-scroll@0.0.5) (2019-10-12) 25 | 26 | **Note:** Version bump only for package vuepress-plugin-smooth-scroll 27 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-smooth-scroll/README.md: -------------------------------------------------------------------------------- 1 | # vuepress-plugin-smooth-scroll 2 | 3 | > VuePress plugin for smooth scrolling 4 | 5 | ## Documentation 6 | 7 | [vuepress-community.netlify.app](https://vuepress-community.netlify.app) 8 | 9 | ## License 10 | 11 | [MIT](https://github.com/vuepress/vuepress-community/blob/main/LICENSE) © [VuePress Community](https://github.com/vuepress) 12 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-smooth-scroll/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vuepress-plugin-smooth-scroll", 3 | "version": "0.0.10", 4 | "description": "VuePress plugin for smooth scrolling", 5 | "keywords": [ 6 | "plugin", 7 | "scroll", 8 | "smooth", 9 | "vuepress" 10 | ], 11 | "homepage": "https://github.com/vuepress", 12 | "bugs": { 13 | "url": "https://github.com/vuepress/vuepress-community/issues" 14 | }, 15 | "repository": { 16 | "type": "git", 17 | "url": "git+https://github.com/vuepress/vuepress-community.git" 18 | }, 19 | "license": "MIT", 20 | "author": "meteorlxy ", 21 | "main": "lib/index.js", 22 | "types": "lib/index.d.ts", 23 | "files": [ 24 | "lib", 25 | "styles" 26 | ], 27 | "scripts": { 28 | "build": "rimraf lib && tsc -p tsconfig.build.json", 29 | "lint": "eslint --ext .ts src" 30 | }, 31 | "dependencies": { 32 | "smoothscroll-polyfill": "^0.4.4" 33 | }, 34 | "devDependencies": { 35 | "@types/smoothscroll-polyfill": "^0.3.1" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-smooth-scroll/src/clientRootMixin.ts: -------------------------------------------------------------------------------- 1 | import smoothscroll from 'smoothscroll-polyfill' 2 | import '../styles/index.styl' 3 | 4 | export default { 5 | mounted(): void { 6 | smoothscroll.polyfill() 7 | }, 8 | } 9 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-smooth-scroll/src/enhanceApp.ts: -------------------------------------------------------------------------------- 1 | import { EnhanceApp } from 'vuepress-types' 2 | import { Route } from 'vue-router' 3 | 4 | // fork from vue-router@3.0.2 5 | // src/util/scroll.js 6 | function getElementPosition( 7 | el: Element 8 | ): { 9 | x: number 10 | y: number 11 | } { 12 | const docEl = document.documentElement 13 | const docRect = docEl.getBoundingClientRect() 14 | const elRect = el.getBoundingClientRect() 15 | return { 16 | x: elRect.left - docRect.left, 17 | y: elRect.top - docRect.top, 18 | } 19 | } 20 | 21 | const enhanceApp: EnhanceApp = ({ Vue, router }): void => { 22 | router.options.scrollBehavior = ( 23 | to: Route, 24 | from: Route, 25 | savedPosition: void | { x: number; y: number } 26 | ): void => { 27 | if (savedPosition) { 28 | return window.scrollTo({ 29 | top: savedPosition.y, 30 | behavior: 'smooth', 31 | }) 32 | } else if (to.hash) { 33 | if (Vue.$vuepress.$get('disableScrollBehavior')) { 34 | return 35 | } 36 | 37 | const targetAnchor = to.hash.slice(1) 38 | const targetElement = 39 | document.getElementById(targetAnchor) || 40 | document.querySelector(`[name='${targetAnchor}']`) 41 | 42 | if (targetElement) { 43 | return window.scrollTo({ 44 | top: getElementPosition(targetElement).y, 45 | behavior: 'smooth', 46 | }) 47 | } 48 | } else { 49 | return window.scrollTo({ 50 | top: 0, 51 | behavior: 'smooth', 52 | }) 53 | } 54 | } 55 | } 56 | 57 | export default enhanceApp 58 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-smooth-scroll/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Plugin } from 'vuepress-types' 2 | 3 | // eslint-disable-next-line @typescript-eslint/no-var-requires 4 | const path = require('path') 5 | 6 | const SmoothScrollPlugin: Plugin = { 7 | name: 'vuepress-plugin-smooth-scroll', 8 | 9 | enhanceAppFiles: path.resolve(__dirname, 'enhanceApp.js'), 10 | 11 | clientRootMixin: path.resolve(__dirname, 'clientRootMixin.js'), 12 | } 13 | 14 | module.exports = SmoothScrollPlugin 15 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-smooth-scroll/styles/index.styl: -------------------------------------------------------------------------------- 1 | html 2 | scroll-behavior smooth 3 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-smooth-scroll/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "./src", 5 | "outDir": "./lib" 6 | }, 7 | "include": ["./src"] 8 | } 9 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-smooth-scroll/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": ["./src", "./test"] 4 | } 5 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-table-of-contents/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [1.1.7](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-table-of-contents@1.1.6...vuepress-plugin-table-of-contents@1.1.7) (2020-09-01) 7 | 8 | **Note:** Version bump only for package vuepress-plugin-table-of-contents 9 | 10 | ## [1.1.6](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-table-of-contents@1.1.5...vuepress-plugin-table-of-contents@1.1.6) (2020-05-21) 11 | 12 | **Note:** Version bump only for package vuepress-plugin-table-of-contents 13 | 14 | ## [1.1.5](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-table-of-contents@1.1.4...vuepress-plugin-table-of-contents@1.1.5) (2019-12-27) 15 | 16 | ### Bug Fixes 17 | 18 | - **plugin-table-of-contents:** update types ([684c1c9](https://github.com/vuepress/vuepress-community/commit/684c1c960130496d791478a6b8590674f182c689)) 19 | 20 | ## [1.1.4](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-table-of-contents@1.1.3...vuepress-plugin-table-of-contents@1.1.4) (2019-11-29) 21 | 22 | **Note:** Version bump only for package vuepress-plugin-table-of-contents 23 | 24 | ## [1.1.3](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-table-of-contents@1.1.2...vuepress-plugin-table-of-contents@1.1.3) (2019-11-20) 25 | 26 | **Note:** Version bump only for package vuepress-plugin-table-of-contents 27 | 28 | ## [1.1.2](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-table-of-contents@1.1.0...vuepress-plugin-table-of-contents@1.1.2) (2019-10-18) 29 | 30 | ### Bug Fixes 31 | 32 | - **vuepress-plugin-table-of-contents:** add options type ([8a5799d](https://github.com/vuepress/vuepress-community/commit/8a5799d8e40d4d7d15c6dbe4c9c3998ee45dc347)) 33 | - **vuepress-plugin-table-of-contents:** remove define option ([d52bd8a](https://github.com/vuepress/vuepress-community/commit/d52bd8a777e7539677450c1e48a0ccc9ef8dca98)) 34 | 35 | # 1.1.0 (2019-10-12) 36 | 37 | ### Features 38 | 39 | - **vuepress-plugin-table-of-contents:** migrate with custom name option ([32119b4](https://github.com/vuepress/vuepress-community/commit/32119b4)) 40 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-table-of-contents/README.md: -------------------------------------------------------------------------------- 1 | # vuepress-plugin-table-of-contents 2 | 3 | > VuePress plugin for table of contents 4 | 5 | ## Documentation 6 | 7 | [vuepress-community.netlify.app](https://vuepress-community.netlify.app) 8 | 9 | ## License 10 | 11 | [MIT](https://github.com/vuepress/vuepress-community/blob/main/LICENSE) © [VuePress Community](https://github.com/vuepress) 12 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-table-of-contents/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vuepress-plugin-table-of-contents", 3 | "version": "1.1.7", 4 | "description": "VuePress plugin for table of contents", 5 | "keywords": [ 6 | "plugin", 7 | "table-of-contents", 8 | "tof", 9 | "vuepress" 10 | ], 11 | "homepage": "https://github.com/vuepress", 12 | "bugs": { 13 | "url": "https://github.com/vuepress/vuepress-community/issues" 14 | }, 15 | "repository": { 16 | "type": "git", 17 | "url": "git+https://github.com/vuepress/vuepress-community.git" 18 | }, 19 | "license": "MIT", 20 | "author": "meteorlxy ", 21 | "main": "lib/index.js", 22 | "types": "lib/index.d.ts", 23 | "files": [ 24 | "lib" 25 | ], 26 | "scripts": { 27 | "build": "rimraf lib && tsc -p tsconfig.build.json", 28 | "lint": "eslint --ext .ts src" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-table-of-contents/src/components/TableOfContents.ts: -------------------------------------------------------------------------------- 1 | import Vue, { ComponentOptions, VNode } from 'vue' 2 | import { PageHeader } from 'vuepress-types' 3 | 4 | interface TableOfContentsComponent extends Vue { 5 | includeLevel: number[] 6 | headers: TOFHeader[] | null 7 | } 8 | 9 | interface TOFHeader extends PageHeader { 10 | children: TOFHeader[] | null 11 | } 12 | 13 | const TableOfContents: ComponentOptions = { 14 | name: 'TableOfContents', 15 | 16 | props: { 17 | includeLevel: { 18 | type: Array, 19 | required: false, 20 | default: (): number[] => [2, 3], 21 | }, 22 | }, 23 | 24 | computed: { 25 | headers(this: TableOfContentsComponent): TOFHeader[] | null { 26 | if (this.$page && this.$page.headers) { 27 | const minLevel: number = this.includeLevel[0] 28 | const maxLevel: number = this.includeLevel[1] 29 | 30 | const processHeaders = ( 31 | headers: PageHeader[], 32 | rootLevel = minLevel 33 | ): TOFHeader[] => { 34 | const result: TOFHeader[] = [] 35 | for (let i = 0; i !== headers.length; ) { 36 | const nextRootOffset = headers 37 | .slice(i + 1) 38 | .findIndex((h) => h.level === rootLevel) 39 | const nextRootIndex = 40 | nextRootOffset === -1 ? headers.length : nextRootOffset + i + 1 41 | const thisHeader = headers[i] 42 | 43 | if (thisHeader.level >= rootLevel && thisHeader.level <= maxLevel) { 44 | const childHeaders = headers.slice(i + 1, nextRootIndex) 45 | const children = 46 | rootLevel < maxLevel && childHeaders.length > 0 47 | ? processHeaders(childHeaders, rootLevel + 1) 48 | : null 49 | result.push({ 50 | ...thisHeader, 51 | children, 52 | }) 53 | } 54 | i = nextRootIndex 55 | } 56 | return result 57 | } 58 | return processHeaders(this.$page.headers) 59 | } 60 | 61 | return null 62 | }, 63 | }, 64 | 65 | render(this: TableOfContentsComponent, h) { 66 | if (!this.headers) { 67 | return (null as unknown) as VNode 68 | } 69 | 70 | const renderHeaders = (items: TOFHeader[]): VNode => { 71 | return h( 72 | 'ul', 73 | items.map((item) => 74 | h('li', [ 75 | h( 76 | 'RouterLink', 77 | { 78 | props: { to: `#${item.slug}` }, 79 | }, 80 | item.title 81 | ), 82 | item.children ? renderHeaders(item.children) : null, 83 | ]) 84 | ) 85 | ) 86 | } 87 | return h('div', [renderHeaders(this.headers)]) 88 | }, 89 | } 90 | 91 | export default TableOfContents 92 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-table-of-contents/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Plugin, PluginGeneratedFile } from 'vuepress-types' 2 | 3 | // eslint-disable-next-line @typescript-eslint/no-var-requires 4 | const path = require('path') 5 | 6 | export interface TableOfContentsPluginOptions { 7 | componentName: string 8 | } 9 | 10 | const TableOfContentsPlugin: Plugin = ({ 11 | componentName = 'TOC', 12 | }) => ({ 13 | name: 'vuepress-plugin-table-of-contents', 14 | 15 | enhanceAppFiles(): PluginGeneratedFile { 16 | return { 17 | name: `plugin-table-of-contents.js`, 18 | content: `export default ({ Vue }) => Vue.component(${JSON.stringify( 19 | componentName 20 | )}, () => import(${JSON.stringify( 21 | path.resolve(__dirname, 'components/TableOfContents') 22 | )}))`, 23 | } 24 | }, 25 | }) 26 | 27 | module.exports = TableOfContentsPlugin 28 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-table-of-contents/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "./src", 5 | "outDir": "./lib" 6 | }, 7 | "include": ["./src"] 8 | } 9 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-table-of-contents/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": ["./src", "./test"] 4 | } 5 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-typescript/.gitignore: -------------------------------------------------------------------------------- 1 | test/e2e/dist 2 | test/e2e/.temp 3 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-typescript/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [0.3.1](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-typescript@0.3.0...vuepress-plugin-typescript@0.3.1) (2020-09-01) 7 | 8 | ### Bug Fixes 9 | 10 | - **plugin-typescript:** use partial ts-loader optiions ([ef560d4](https://github.com/vuepress/vuepress-community/commit/ef560d4de9dfa9941b04cdfdc1a9351ab3fb449a)) 11 | - dependency issues in typescript and container plugin ([#52](https://github.com/vuepress/vuepress-community/issues/52)) ([8a4c390](https://github.com/vuepress/vuepress-community/commit/8a4c39089e48ab9319ba15853a4a4782812af03f)) 12 | 13 | # [0.3.0](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-typescript@0.2.0...vuepress-plugin-typescript@0.3.0) (2020-05-21) 14 | 15 | ### Features 16 | 17 | - **plugin-typescript:** upgrade to ts-loader 7 ([2d6e17b](https://github.com/vuepress/vuepress-community/commit/2d6e17b3d661aa535a4487528d92df00cf96d5ef)) 18 | 19 | # [0.2.0](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-typescript@0.1.2...vuepress-plugin-typescript@0.2.0) (2020-02-20) 20 | 21 | ### Features 22 | 23 | - **plugin-typescript:** prepend cache-loader before ts-loader ([00d32f2](https://github.com/vuepress/vuepress-community/commit/00d32f2efcc515ad4ee265648f8ede8af537ba4a)) 24 | 25 | ## [0.1.2](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-typescript@0.1.1...vuepress-plugin-typescript@0.1.2) (2020-02-03) 26 | 27 | **Note:** Version bump only for package vuepress-plugin-typescript 28 | 29 | ## [0.1.1](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-typescript@0.1.0...vuepress-plugin-typescript@0.1.1) (2019-12-10) 30 | 31 | ### Bug Fixes 32 | 33 | - **plugin-typescript:** resolve ts extensions (close [#3](https://github.com/vuepress/vuepress-community/issues/3)) ([6748a01](https://github.com/vuepress/vuepress-community/commit/6748a0166efa8a8a7e4588ca2bd55ccfb8c1457b)) 34 | 35 | # 0.1.0 (2019-11-29) 36 | 37 | ### Features 38 | 39 | - **plugin-typescript:** support typescript ([d62fe1c](https://github.com/vuepress/vuepress-community/commit/d62fe1ca665d7c79d884c0dfacba5ed3ee31fb07)) 40 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-typescript/README.md: -------------------------------------------------------------------------------- 1 | # vuepress-plugin-typescript 2 | 3 | > VuePress plugin for typescript 4 | 5 | ## Documentation 6 | 7 | [vuepress-community.netlify.app](https://vuepress-community.netlify.app) 8 | 9 | ## License 10 | 11 | [MIT](https://github.com/vuepress/vuepress-community/blob/main/LICENSE) © [VuePress Community](https://github.com/vuepress) 12 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-typescript/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vuepress-plugin-typescript", 3 | "version": "0.3.1", 4 | "description": "VuePress plugin for typescript", 5 | "keywords": [ 6 | "plugin", 7 | "typescript", 8 | "vuepress" 9 | ], 10 | "homepage": "https://github.com/vuepress", 11 | "bugs": { 12 | "url": "https://github.com/vuepress/vuepress-community/issues" 13 | }, 14 | "repository": { 15 | "type": "git", 16 | "url": "git+https://github.com/vuepress/vuepress-community.git" 17 | }, 18 | "license": "MIT", 19 | "author": "meteorlxy ", 20 | "main": "lib/index.js", 21 | "types": "lib/index.d.ts", 22 | "files": [ 23 | "lib" 24 | ], 25 | "scripts": { 26 | "build": "rimraf lib && tsc -p tsconfig.build.json", 27 | "lint": "eslint --ext .ts,.vue src test" 28 | }, 29 | "dependencies": { 30 | "cache-loader": "^3.0.0", 31 | "ts-loader": "^7.0.3" 32 | }, 33 | "devDependencies": { 34 | "vue-class-component": "^7.1.0", 35 | "vue-property-decorator": "^8.3.0" 36 | }, 37 | "peerDependencies": { 38 | "typescript": "*" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-typescript/src/index.ts: -------------------------------------------------------------------------------- 1 | import TsLoader from 'ts-loader' 2 | import { Plugin } from 'vuepress-types' 3 | 4 | const path = require('path') 5 | 6 | export interface TypescriptPluginOptions { 7 | tsLoaderOptions: Partial 8 | } 9 | 10 | const TypescriptPlugin: Plugin = ( 11 | { tsLoaderOptions }, 12 | context 13 | ) => ({ 14 | name: 'vuepress-plugin-typescript', 15 | 16 | /** 17 | * Detect enhanceApp.ts 18 | */ 19 | enhanceAppFiles(): string[] { 20 | const { sourceDir, themeAPI } = context 21 | const enhanceAppPath = path.resolve(sourceDir, '.vuepress/enhanceApp.ts') 22 | const files = [enhanceAppPath] 23 | if (themeAPI.existsParentTheme) { 24 | files.push(path.resolve(themeAPI.parentTheme.path, 'enhanceApp.ts')) 25 | } 26 | const themeEnhanceAppPath = path.resolve( 27 | themeAPI.theme.path, 28 | 'enhanceApp.ts' 29 | ) 30 | files.push(themeEnhanceAppPath) 31 | return files 32 | }, 33 | 34 | /** 35 | * Allow following files support typescript: 36 | * - .ts 37 | * - .vue 38 | * - .md 39 | */ 40 | chainWebpack(config, isServer): void { 41 | const { cacheDirectory, cacheIdentifier } = context 42 | const finalCacheIdentifier = cacheIdentifier + `isServer:${isServer}` 43 | 44 | config.resolve.extensions.add('.ts') 45 | 46 | config.module 47 | .rule('ts') 48 | .test(/\.ts$/) 49 | .use('cache-loader') 50 | .loader(require.resolve('cache-loader')) 51 | .options({ 52 | cacheDirectory, 53 | cacheIdentifier: finalCacheIdentifier, 54 | }) 55 | .end() 56 | .use('ts-loader') 57 | .loader(require.resolve('ts-loader')) 58 | .options({ 59 | appendTsSuffixTo: [/\.vue$/, /\.md$/], 60 | compilerOptions: { 61 | declaration: false, 62 | }, 63 | ...tsLoaderOptions, 64 | }) 65 | .end() 66 | }, 67 | }) 68 | 69 | module.exports = TypescriptPlugin 70 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-typescript/test/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | overrides: [ 3 | { 4 | files: ['./**/*.vue'], 5 | extends: 'vuepress-typescript', 6 | }, 7 | ], 8 | } 9 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-typescript/test/e2e/docs/.vuepress/config.js: -------------------------------------------------------------------------------- 1 | const CSSExtractPlugin = require('mini-css-extract-plugin') 2 | 3 | module.exports = { 4 | plugins: ['vuepress-plugin-typescript'], 5 | 6 | chainWebpack(config) { 7 | // do not use chunk hash in js 8 | config.output.filename('assets/js/[name].js') 9 | 10 | // do not use chunk hash in css 11 | config.plugin('extract-css').use(CSSExtractPlugin, [ 12 | { 13 | filename: 'assets/css/styles.css', 14 | }, 15 | ]) 16 | }, 17 | } 18 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-typescript/test/e2e/docs/.vuepress/shims-vue.d.ts: -------------------------------------------------------------------------------- 1 | declare module '*.vue' { 2 | import Vue from 'vue' 3 | export default Vue 4 | } 5 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-typescript/test/e2e/docs/.vuepress/theme/components/Test.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 15 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-typescript/test/e2e/docs/.vuepress/theme/components/TestIndexTsFile/index.ts: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | 3 | export default Vue.extend({ 4 | // eslint-disable-next-line vue/match-component-file-name 5 | name: 'TestIndexTsFile', 6 | 7 | render(h) { 8 | return h('span', 'test index.ts file') 9 | }, 10 | }) 11 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-typescript/test/e2e/docs/.vuepress/theme/components/TestTsFile.ts: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | 3 | export default Vue.extend({ 4 | name: 'TestTsFile', 5 | 6 | render(h) { 7 | return h('span', 'test .ts file') 8 | }, 9 | }) 10 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-typescript/test/e2e/docs/.vuepress/theme/enhanceApp.ts: -------------------------------------------------------------------------------- 1 | import { EnhanceApp } from 'vuepress-types' 2 | import Test from './components/Test.vue' 3 | import TestTsFile from './components/TestTsFile' 4 | import TestIndexTsFile from './components/TestIndexTsFile' 5 | 6 | const enhanceApp: EnhanceApp = ({ Vue }) => { 7 | /* eslint-disable vue/match-component-file-name */ 8 | Vue.component('Test', Test) 9 | Vue.component('TestTsFile', TestTsFile) 10 | Vue.component('TestIndexTsFile', TestIndexTsFile) 11 | /* eslint-enable vue/match-component-file-name */ 12 | } 13 | 14 | export default enhanceApp 15 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-typescript/test/e2e/docs/.vuepress/theme/layouts/Layout.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 16 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-typescript/test/e2e/docs/README.md: -------------------------------------------------------------------------------- 1 | readme 2 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-typescript/test/e2e/docs/enhance-app-ts.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-typescript/test/e2e/docs/ts-in-md.md: -------------------------------------------------------------------------------- 1 | {{ message }} 2 | 3 | 11 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-typescript/test/e2e/index.spec.ts: -------------------------------------------------------------------------------- 1 | import { resolve } from 'path' 2 | import { readFileSync } from 'fs' 3 | import { createApp } from '@vuepress/core' 4 | 5 | describe('vuepress-plugin-typescript', () => { 6 | process.env.NODE_ENV = 'production' 7 | 8 | const app = createApp({ 9 | sourceDir: resolve(__dirname, 'docs'), 10 | dest: resolve(__dirname, 'dist'), 11 | temp: resolve(__dirname, '.temp'), 12 | }) 13 | 14 | beforeAll(async () => { 15 | await app.process() 16 | await app.build() 17 | }, 60000) 18 | 19 | test('should allow typescript in Layout.vue', () => { 20 | const html = readFileSync(resolve(app.outDir, 'index.html'), 'utf8') 21 | expect(html).toMatchSnapshot() 22 | }) 23 | 24 | test('should allow typescript in markdown files', () => { 25 | const html = readFileSync(resolve(app.outDir, 'ts-in-md.html'), 'utf8') 26 | expect(html).toMatchSnapshot() 27 | }) 28 | 29 | test('should allow typescript in enhanceApp & enhanceAppFiles', () => { 30 | const html = readFileSync( 31 | resolve(app.outDir, 'enhance-app-ts.html'), 32 | 'utf8' 33 | ) 34 | expect(html).toMatchSnapshot() 35 | }) 36 | }) 37 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-typescript/test/e2e/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../../tsconfig.json", 3 | "compilerOptions": { 4 | "experimentalDecorators": true 5 | }, 6 | "include": ["docs/.vuepress/**/*.ts", "docs/.vuepress/**/*.vue"] 7 | } 8 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-typescript/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "./src", 5 | "outDir": "./lib" 6 | }, 7 | "include": ["./src"] 8 | } 9 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-typescript/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": ["./src", "./test"] 4 | } 5 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-zooming/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [1.1.8](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-zooming@1.1.7...vuepress-plugin-zooming@1.1.8) (2020-09-01) 7 | 8 | **Note:** Version bump only for package vuepress-plugin-zooming 9 | 10 | ## [1.1.7](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-zooming@1.1.6...vuepress-plugin-zooming@1.1.7) (2019-11-29) 11 | 12 | **Note:** Version bump only for package vuepress-plugin-zooming 13 | 14 | ## [1.1.6](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-zooming@1.1.5...vuepress-plugin-zooming@1.1.6) (2019-11-20) 15 | 16 | **Note:** Version bump only for package vuepress-plugin-zooming 17 | 18 | ## [1.1.5](https://github.com/vuepress/vuepress-community/compare/vuepress-plugin-zooming@1.1.3...vuepress-plugin-zooming@1.1.5) (2019-10-18) 19 | 20 | ### Bug Fixes 21 | 22 | - **vuepress-plugin-zooming:** add options type ([01e0c2b](https://github.com/vuepress/vuepress-community/commit/01e0c2bcfffe8f0832611df3f154868fa1655611)) 23 | 24 | ## 1.1.3 (2019-10-12) 25 | 26 | ### Bug Fixes 27 | 28 | - **vuepress-plugin-zooming:** update types ([9ec57c5](https://github.com/vuepress/vuepress-community/commit/9ec57c5)) 29 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-zooming/README.md: -------------------------------------------------------------------------------- 1 | # vuepress-plugin-zooming 2 | 3 | > VuePress plugin for zooming 4 | 5 | ## Documentation 6 | 7 | [vuepress-community.netlify.app](https://vuepress-community.netlify.app) 8 | 9 | ## License 10 | 11 | [MIT](https://github.com/vuepress/vuepress-community/blob/main/LICENSE) © [VuePress Community](https://github.com/vuepress) 12 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-zooming/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vuepress-plugin-zooming", 3 | "version": "1.1.8", 4 | "description": "VuePress plugin for zooming", 5 | "keywords": [ 6 | "image", 7 | "plugin", 8 | "vuepress", 9 | "zoom", 10 | "zooming" 11 | ], 12 | "homepage": "https://github.com/vuepress", 13 | "bugs": { 14 | "url": "https://github.com/vuepress/vuepress-community/issues" 15 | }, 16 | "repository": { 17 | "type": "git", 18 | "url": "git+https://github.com/vuepress/vuepress-community.git" 19 | }, 20 | "license": "MIT", 21 | "author": "meteorlxy ", 22 | "main": "lib/index.js", 23 | "types": "lib/index.d.ts", 24 | "files": [ 25 | "lib" 26 | ], 27 | "scripts": { 28 | "build": "rimraf lib && tsc -p tsconfig.build.json", 29 | "lint": "eslint --ext .ts src" 30 | }, 31 | "dependencies": { 32 | "zooming": "^2.1.1" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-zooming/src/VuepressZooming.ts: -------------------------------------------------------------------------------- 1 | import Zooming from 'zooming' 2 | 3 | declare const ZOOMING_SELECTOR: string 4 | declare const ZOOMING_OPTIONS: string 5 | declare const ZOOMING_DELAY: string 6 | 7 | const zoomingSelector = ZOOMING_SELECTOR 8 | const zoomingOptions = JSON.parse(ZOOMING_OPTIONS) 9 | const zoomingDelay = Number(ZOOMING_DELAY) 10 | 11 | export class VuepressZooming { 12 | instance: Zooming 13 | 14 | constructor() { 15 | this.instance = new Zooming(zoomingOptions) 16 | } 17 | 18 | update(selector = zoomingSelector): void { 19 | if (typeof window === 'undefined') return 20 | this.instance.listen(selector) 21 | } 22 | 23 | updateDelay(selector = zoomingSelector, delay = zoomingDelay): void { 24 | setTimeout(() => this.update(selector), delay) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-zooming/src/clientRootMixin.ts: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import { VuepressZooming } from './VuepressZooming' 3 | 4 | declare module 'vuepress-types/types/store' { 5 | interface VuePressStore { 6 | zooming: VuepressZooming 7 | } 8 | } 9 | 10 | export default { 11 | watch: { 12 | '$page.path'(this: Vue): void { 13 | if (typeof this.$vuepress.zooming === 'undefined') return 14 | this.$vuepress.zooming.updateDelay() 15 | }, 16 | }, 17 | 18 | mounted(this: Vue): void { 19 | this.$vuepress.zooming = new VuepressZooming() 20 | this.$vuepress.zooming.updateDelay() 21 | }, 22 | } 23 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-zooming/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Plugin } from 'vuepress-types' 2 | 3 | // eslint-disable-next-line @typescript-eslint/no-var-requires 4 | const path = require('path') 5 | 6 | export interface ZoomingPluginOptions { 7 | selector: string 8 | options: { 9 | bgColor?: string 10 | bgOpacity?: number 11 | closeOnWindowResize?: boolean 12 | customSize?: 13 | | string 14 | | { 15 | width: number 16 | height: number 17 | } 18 | enableGrab?: boolean 19 | preloadImage?: boolean 20 | scaleBase?: number 21 | scaleExtra?: number 22 | scrollThreshold?: number 23 | transitionDuration?: number 24 | transitionTimingFunction?: string 25 | zIndex?: number 26 | } 27 | delay: number 28 | } 29 | 30 | const ZoomingPlugin: Plugin = ({ 31 | selector = '.theme-default-content img', 32 | options = {}, 33 | delay = 500, 34 | }) => ({ 35 | name: 'vuepress-plugin-zooming', 36 | 37 | clientRootMixin: path.resolve(__dirname, 'clientRootMixin.js'), 38 | 39 | define: { 40 | ZOOMING_SELECTOR: selector, 41 | ZOOMING_OPTIONS: JSON.stringify(options), 42 | ZOOMING_DELAY: delay.toString(), 43 | }, 44 | }) 45 | 46 | module.exports = ZoomingPlugin 47 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-zooming/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "./src", 5 | "outDir": "./lib" 6 | }, 7 | "include": ["./src"] 8 | } 9 | -------------------------------------------------------------------------------- /packages/vuepress-plugin-zooming/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": ["./src", "./test"] 4 | } 5 | -------------------------------------------------------------------------------- /packages/vuepress-types/README.md: -------------------------------------------------------------------------------- 1 | # vuepress-types 2 | 3 | > VuePress TypeScript helpers 4 | 5 | ## Documentation 6 | 7 | [vuepress-community.netlify.app](https://vuepress-community.netlify.app) 8 | 9 | ## License 10 | 11 | [MIT](https://github.com/vuepress/vuepress-community/blob/main/LICENSE) © [VuePress Community](https://github.com/vuepress) 12 | -------------------------------------------------------------------------------- /packages/vuepress-types/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vuepress-types", 3 | "version": "0.9.4", 4 | "description": "VuePress TypeScript helpers", 5 | "keywords": [ 6 | "types", 7 | "vuepress" 8 | ], 9 | "homepage": "https://github.com/vuepress", 10 | "bugs": { 11 | "url": "https://github.com/vuepress/vuepress-community/issues" 12 | }, 13 | "repository": { 14 | "type": "git", 15 | "url": "git+https://github.com/vuepress/vuepress-community.git" 16 | }, 17 | "license": "MIT", 18 | "author": "meteorlxy ", 19 | "types": "types/index.d.ts", 20 | "files": [ 21 | "types" 22 | ], 23 | "scripts": { 24 | "lint": "eslint --ext .ts types" 25 | }, 26 | "dependencies": { 27 | "@types/express": "^4.17.1", 28 | "@types/markdown-it": "^0.0.8", 29 | "@types/webpack-dev-server": "^3.1.7", 30 | "cac": "^6.5.10", 31 | "markdown-it": "^8.4.1", 32 | "vue": "^2.6.10", 33 | "vue-loader": "^15.7.1", 34 | "webpack": "^4.8.1", 35 | "webpack-chain": "^6.0.0", 36 | "webpack-dev-server": "^3.5.1" 37 | }, 38 | "peerDependencies": { 39 | "vuepress": "^1.3.0" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /packages/vuepress-types/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "include": ["./types"] 4 | } 5 | -------------------------------------------------------------------------------- /packages/vuepress-types/types/computed.d.ts: -------------------------------------------------------------------------------- 1 | import { LocaleConfig, ThemeConfig } from './config' 2 | import { SiteData } from './context' 3 | import { Page, PageComputed, PageFrontmatter } from './page' 4 | 5 | declare module 'vue/types/vue' { 6 | export interface Vue { 7 | $description: string 8 | $frontmatter: PageFrontmatter 9 | $lang: string 10 | $localeConfig: LocaleConfig 11 | $localePath: string 12 | $page: PageComputed 13 | 14 | // context.getSiteData() 15 | $site: SiteData 16 | $siteTitle: string 17 | $themeConfig: ThemeConfig 18 | $themeLocaleConfig: LocaleConfig 19 | $title: string 20 | 21 | // injected in client/app.js 22 | $withBase: (path: string) => string 23 | } 24 | } 25 | 26 | export interface ClientComputedMixin { 27 | readonly $site: SiteData 28 | readonly $themeConfig: ThemeConfig 29 | readonly $frontmatter: PageFrontmatter 30 | readonly $localeConfig: LocaleConfig 31 | readonly $siteTitle: string 32 | readonly $title: string 33 | readonly $description: string 34 | readonly $lang: string 35 | readonly $localePath: string 36 | readonly $themeLocaleConfig: string 37 | readonly $page: Page 38 | 39 | __page: Page 40 | 41 | setPage: (page: Page) => void 42 | } 43 | -------------------------------------------------------------------------------- /packages/vuepress-types/types/config.d.ts: -------------------------------------------------------------------------------- 1 | import { Configuration } from 'webpack' 2 | import { Configuration as WebpackDevServerConfiguration } from 'webpack-dev-server' 3 | import { Markdown } from './markdown' 4 | import { PluginOptionAPI } from './plugin' 5 | 6 | export interface LocaleConfig extends Omit { 7 | path?: string 8 | } 9 | 10 | /** 11 | * @see https://vuepress.vuejs.org/config/#markdown 12 | */ 13 | export interface MarkdownConfig { 14 | lineNumbers?: boolean 15 | slugify?: (...args: any[]) => any 16 | anchor?: { 17 | permalink?: boolean 18 | permalinkBefore?: boolean 19 | permalinkSymbol?: string 20 | } 21 | externalLinks?: Record 22 | // TODO 23 | toc?: Record 24 | plugins?: Exclude 25 | extendMarkdown?: (md: Markdown) => void 26 | extractHeaders?: string[] 27 | } 28 | 29 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 30 | export type PluginConfig = 31 | | string 32 | | [string] 33 | | [string, T] 34 | | Record 35 | | PluginOptionAPI 36 | 37 | export interface ThemeConfig { 38 | locales?: LocaleConfig 39 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 40 | [key: string]: any 41 | } 42 | 43 | /** 44 | * @see https://vuepress.vuejs.org/config 45 | */ 46 | export interface SiteConfig { 47 | // Basic Config 48 | base?: string 49 | title?: string 50 | description?: string 51 | head?: Array<[string, Record]> 52 | 53 | host?: string 54 | port?: number 55 | 56 | temp?: string 57 | dest?: string 58 | 59 | locales?: LocaleConfig 60 | shouldPrefetch?: (file: string, type: string) => boolean 61 | cache?: boolean | string 62 | extraWatchFiles?: string[] 63 | patterns?: string[] 64 | 65 | // Theme 66 | theme?: string 67 | themeConfig?: ThemeConfig 68 | 69 | // Plugin 70 | plugins?: PluginConfig[] 71 | 72 | // Markdown 73 | markdown?: MarkdownConfig 74 | 75 | // Build Pipeline 76 | // https://github.com/postcss/postcss-loader#options 77 | postcss?: { 78 | exec?: boolean 79 | parser?: string | Record | ((...args: any[]) => any) 80 | syntax?: string | Record 81 | stringifier?: string | Record 82 | config?: { 83 | path?: string 84 | context?: Record 85 | ctx?: Record 86 | } 87 | ident?: string 88 | plugins?: any[] | ((...args: any[]) => any) 89 | sourceMap?: 'inline' | boolean 90 | } 91 | // https://github.com/shama/stylus-loader#readme 92 | stylus?: { 93 | use?: any[] 94 | import?: string[] 95 | preferPathResolver?: 'webpack' | string 96 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 97 | [key: string]: any 98 | } 99 | scss?: any 100 | sass?: any 101 | less?: any 102 | configureWebpack?: 103 | | Configuration 104 | | ((config: Configuration, isServer: boolean) => Configuration) 105 | // TODO: ask vuepress to upgrade webpack-chain to >=5.2.0 106 | // https://github.com/neutrinojs/webpack-chain/blob/master/CHANGELOG.md#v520 107 | chainWebpack?: (config: any, isServer: boolean) => void 108 | 109 | // Browser Compatibility 110 | evergreen?: boolean 111 | 112 | // Undocumented 113 | name?: string 114 | devServer?: WebpackDevServerConfiguration 115 | devTemplate?: string 116 | permalink?: string 117 | 118 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 119 | [key: string]: any 120 | } 121 | -------------------------------------------------------------------------------- /packages/vuepress-types/types/context.d.ts: -------------------------------------------------------------------------------- 1 | import { ClientComputedMixin } from './computed' 2 | import { PluginConfig, SiteConfig, ThemeConfig } from './config' 3 | import { Markdown } from './markdown' 4 | import { Page, PageOptions, PageComputed } from './page' 5 | import { PluginAPI } from './plugin-api' 6 | import { ThemeAPI } from './theme-api' 7 | 8 | /** 9 | * @see https://github.com/vuejs/vuepress/blob/master/packages/%40vuepress/core/lib/node/App.js 10 | * @see https://vuepress.vuejs.org/plugin/context-api.html 11 | */ 12 | 13 | export interface ContextConstructor { 14 | new (options: ContextOptions): Context 15 | } 16 | 17 | export type App = Context 18 | 19 | export interface Context { 20 | /** 21 | * Docs 22 | */ 23 | isProd: boolean 24 | pages: Page[] 25 | sourceDir: string 26 | tempPath: string 27 | outDir: string 28 | base: string 29 | writeTemp: (file: string, content: string) => void 30 | 31 | /** 32 | * Other 33 | */ 34 | options: ContextOptions 35 | vuepressDir: string 36 | libDir: string 37 | cwd: string 38 | siteConfig: SiteConfig 39 | themeConfig: ThemeConfig 40 | markdown: Markdown 41 | pluginAPI: PluginAPI 42 | themeAPI: ThemeAPI 43 | ClientComputedMixinConstructor: new () => ClientComputedMixin 44 | ssrTemplate: string 45 | devTemplate: string 46 | globalLayout: string 47 | // cache related properties, added in resolveCacheLoaderOptions() 48 | cacheDirectory: string 49 | cacheIdentifier: string 50 | 51 | // private 52 | resolveConfigAndInitialize: () => void 53 | process: () => Promise 54 | applyInternalPlugins: () => void 55 | applyUserPlugins: () => void 56 | normalizeHeadTagUrls: () => void 57 | resolveCacheLoaderOptions: () => void 58 | resolveTemplates: () => void 59 | resolveGlobalLayout: () => void 60 | resolveCommonAgreementFilePath: () => void | string 61 | resolvePages: () => Promise 62 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 63 | getThemeConfigValue: (key: string) => any 64 | resolveThemeAgreementFile: (filepath: string) => string | void 65 | resolveSiteAgreementFile: (filepath: string) => string | void 66 | 67 | // public 68 | addPage: (options: PageOptions) => Promise 69 | getSiteData: () => SiteData 70 | getLibFilePath: (relative: string) => string 71 | dev: () => Promise 72 | build: () => Promise 73 | } 74 | 75 | export interface ContextOptions { 76 | // =========== 77 | // cli options 78 | // =========== 79 | 80 | // dirs 81 | sourceDir?: string 82 | dest?: string 83 | temp?: string 84 | 85 | // listen 86 | host?: string 87 | port?: number 88 | 89 | // other 90 | clearScreen?: string 91 | open?: boolean 92 | cache?: boolean 93 | 94 | // =========== 95 | // api options 96 | // =========== 97 | 98 | theme?: string 99 | plugins?: PluginConfig[] 100 | siteConfig?: SiteConfig 101 | } 102 | 103 | /** 104 | * Context.getSiteData() 105 | */ 106 | export type SiteData = 107 | // `locales` directly comes from SiteConfig 108 | Pick & 109 | // `title`, `description`, `base`, `themeConfig` are always defined 110 | Required< 111 | Pick 112 | > & { 113 | // page.toJson() 114 | pages: PageComputed[] 115 | } 116 | -------------------------------------------------------------------------------- /packages/vuepress-types/types/core.d.ts: -------------------------------------------------------------------------------- 1 | declare module '@vuepress/core' { 2 | import { Context, ContextOptions } from 'vuepress-types/types/context' 3 | 4 | export const version: string 5 | 6 | export function createApp(options: ContextOptions): Context 7 | 8 | export function dev(options: ContextOptions): Promise 9 | 10 | export function build(options: ContextOptions): Promise 11 | 12 | export function eject(dir: string): Promise 13 | } 14 | -------------------------------------------------------------------------------- /packages/vuepress-types/types/enhance-app.d.ts: -------------------------------------------------------------------------------- 1 | import { VueConstructor } from 'vue' 2 | import VueRouter, { RouterOptions } from 'vue-router' 3 | import { SiteData } from './context' 4 | 5 | export type EnhanceApp = (options: { 6 | Vue: VueConstructor 7 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 8 | options: Record 9 | router: VueRouter & { options: RouterOptions } 10 | siteData: SiteData 11 | isServer: boolean 12 | }) => void 13 | -------------------------------------------------------------------------------- /packages/vuepress-types/types/index.d.ts: -------------------------------------------------------------------------------- 1 | import './core' 2 | export * from './computed' 3 | export * from './config' 4 | export * from './context' 5 | export * from './enhance-app' 6 | export * from './markdown' 7 | export * from './page' 8 | export * from './plugin' 9 | export * from './plugin-api' 10 | export * from './store' 11 | export * from './theme' 12 | export * from './theme-api' 13 | -------------------------------------------------------------------------------- /packages/vuepress-types/types/markdown.d.ts: -------------------------------------------------------------------------------- 1 | import MarkdownIt from 'markdown-it' 2 | 3 | export interface Markdown extends Omit { 4 | render( 5 | md: string, 6 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 7 | env?: any 8 | ): { 9 | html: string 10 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 11 | data: any 12 | dataBlockString: string 13 | } 14 | x: number 15 | } 16 | -------------------------------------------------------------------------------- /packages/vuepress-types/types/page.d.ts: -------------------------------------------------------------------------------- 1 | import { ClientComputedMixin } from './computed' 2 | import { Context } from './context' 3 | import { Markdown } from './markdown' 4 | import { OptionItem } from './plugin-api' 5 | 6 | /** 7 | * @see https://github.com/vuejs/vuepress/blob/master/packages/%40vuepress/core/lib/node/Page.js 8 | */ 9 | 10 | // ================== 11 | // Page basic properties 12 | // ================== 13 | 14 | export interface BasePage { 15 | title: string 16 | frontmatter: PageFrontmatter 17 | key: string 18 | path: string 19 | regularPath: string 20 | relativePath: string 21 | headers?: PageHeader[] 22 | excerpt?: string 23 | } 24 | 25 | export interface PageFrontmatter { 26 | permalink?: string 27 | title?: string 28 | description?: string 29 | lang?: string 30 | layout?: string 31 | metaTitle?: string 32 | meta?: Record<'charset' | 'content' | 'http-equiv' | 'name', string>[] 33 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 34 | [key: string]: any 35 | } 36 | 37 | // ================== 38 | // Page in context 39 | // ================== 40 | 41 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 42 | export type PageEnhancer = OptionItem[] 43 | 44 | export interface PageProcessOptions { 45 | computed: ClientComputedMixin 46 | markdown: Markdown 47 | enhancers: PageEnhancer[] 48 | preRender: Record 49 | } 50 | 51 | export interface PageHeader { 52 | level: number 53 | title: string 54 | slug: string 55 | } 56 | 57 | export interface Page extends BasePage { 58 | readonly dirname: string 59 | readonly filename: string 60 | readonly slug: string 61 | readonly strippedFilename: string 62 | readonly date: string 63 | 64 | _context: Context 65 | _content: string 66 | _computed: ClientComputedMixin 67 | _extractHeaders: string[] 68 | _filePath: string 69 | _localePath: string 70 | _meta: Record[] 71 | _permalink: string 72 | _permalinkPattern: string 73 | _strippedContent: string 74 | 75 | process: (options: PageProcessOptions) => Promise 76 | stripFilename: (fileName: string) => string 77 | toJson: () => PageComputed 78 | buildPermalink: () => void 79 | enhance: (enhancers: PageEnhancer[]) => Promise 80 | } 81 | 82 | export interface PageOptions { 83 | path: string 84 | meta: Record[] 85 | title: string 86 | content: string 87 | filePath: string 88 | relative: string 89 | permalink: string 90 | frontmatter: PageFrontmatter 91 | permalinkPattern: string 92 | } 93 | 94 | export interface PageConstructor { 95 | new (options: PageOptions, context: Context): Page 96 | } 97 | 98 | // ================== 99 | // Page in computed 100 | // ================== 101 | 102 | export interface PageComputed extends BasePage { 103 | // default theme 104 | lastUpdated?: string 105 | } 106 | -------------------------------------------------------------------------------- /packages/vuepress-types/types/plugin-api.d.ts: -------------------------------------------------------------------------------- 1 | import { Plugin, PluginOptionAPI } from './plugin' 2 | 3 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 4 | export interface OptionItem { 5 | value: Value 6 | name: string 7 | } 8 | 9 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 10 | export interface Option { 11 | key: string 12 | items: OptionItem[] 13 | readonly values: Value[] 14 | appliedItems: OptionItem[] 15 | readonly appliedValues: Value[] 16 | readonly entries: [string, Value][] 17 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 18 | apply: (...args: any[]) => void 19 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 20 | syncApply: (...args: any[]) => void 21 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 22 | pipeline: (input: any) => T 23 | } 24 | 25 | export interface AsyncOption extends Option { 26 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 27 | apply: (...args: any[]) => Promise 28 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 29 | asyncApply: (...args: any[]) => Promise 30 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 31 | parallelApply: (...args: any[]) => Promise 32 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 33 | pipeline: >(input: any) => T 34 | } 35 | 36 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 37 | export interface NormalizedPlugin extends PluginOptionAPI { 38 | name: string 39 | shortcut: string | null 40 | enabled: boolean 41 | $$options: PluginOptions 42 | $$normalized: true 43 | } 44 | 45 | export interface PluginAPI { 46 | options: Record 47 | readonly enabledPlugins: (NormalizedPlugin & { enabled: true })[] 48 | readonly disabledPlugins: (NormalizedPlugin & { enabled: false })[] 49 | initialize: () => void 50 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 51 | use: ( 52 | pluginRaw: Plugin, 53 | pluginOptions: PluginOptions 54 | ) => PluginAPI 55 | normalizePlugin: ( 56 | type: 'plugin' | 'theme', 57 | pluginRaw: Plugin, 58 | pluginOptions: PluginOptions 59 | ) => NormalizedPlugin 60 | useByPluginsConfig: (pluginConfig: PluginOptionAPI) => PluginAPI 61 | initializeOptions: () => void 62 | registerOption: (key: string, value: Option, pluginName: string) => PluginAPI 63 | applyPlugin: (plugin: NormalizedPlugin) => void 64 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 65 | applySyncOption: (name: string, ...args: any[]) => PluginAPI 66 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 67 | applyAsyncOption: (name: string, ...args: any[]) => Promise 68 | getOption: (name: string) => Option 69 | } 70 | -------------------------------------------------------------------------------- /packages/vuepress-types/types/plugin.d.ts: -------------------------------------------------------------------------------- 1 | import { CAC } from 'cac' 2 | import { Application } from 'express' 3 | import WebpackDevServer from 'webpack-dev-server' 4 | import Config from 'webpack-chain' 5 | import { PluginConfig } from './config' 6 | import { Context } from './context' 7 | import { Markdown } from './markdown' 8 | import { Page, PageOptions } from './page' 9 | import { PluginAPI } from './plugin-api' 10 | 11 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 12 | export type Plugin = PluginOptionAPI | PluginFunction 13 | 14 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 15 | export type PluginFunction = ( 16 | pluginOptions: Options, 17 | context: Context, 18 | pluginApi: PluginAPI 19 | ) => PluginOptionAPI 20 | 21 | export interface PluginGeneratedFile { 22 | name: string 23 | content: string 24 | } 25 | 26 | export type EnhanceAppFilesGeneratedFile = PluginGeneratedFile 27 | 28 | export type ClientDynamicModulesGeneratedFile = PluginGeneratedFile & { 29 | dirname?: string 30 | } 31 | 32 | export type PluginGeneratedFileTypes = 33 | | T 34 | | T[] 35 | | Promise 36 | | Promise 37 | 38 | export interface PluginOptionAPI { 39 | name?: string 40 | plugins?: PluginConfig[] 41 | chainWebpack?: (config: Config, isServer: boolean) => void 42 | define?: Record | (() => Record) 43 | alias?: Record 44 | beforeDevServer?: (app: Application, server: WebpackDevServer) => void 45 | afterDevServer?: (app: Application, server: WebpackDevServer) => void 46 | extendMarkdown?: (md: Markdown) => void 47 | // TODO: ask markdown-it-chain to add types definitions 48 | chainMarkdown?: (config: any) => void 49 | enhanceAppFiles?: 50 | | string 51 | | string[] 52 | | (() => 53 | | PluginGeneratedFileTypes 54 | | string 55 | | string[]) 56 | clientDynamicModules?: () => PluginGeneratedFileTypes< 57 | ClientDynamicModulesGeneratedFile 58 | > 59 | extendPageData?: (page: Page) => void | Promise 60 | clientRootMixin?: string 61 | additionalPages?: 62 | | Partial[] 63 | | (() => Promise[]>) 64 | globalUIComponents?: string | string[] 65 | extendCli?: (cli: CAC) => void 66 | multiple?: boolean 67 | // Life Cycle 68 | // https://vuepress.vuejs.org/plugin/life-cycle.html 69 | ready?: () => void | Promise 70 | updated?: () => void | Promise 71 | generated?: (pagePaths: string[]) => void | Promise 72 | } 73 | -------------------------------------------------------------------------------- /packages/vuepress-types/types/store.d.ts: -------------------------------------------------------------------------------- 1 | import Vue, { AsyncComponent } from 'vue' 2 | 3 | export declare class Store { 4 | store: Vue 5 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 6 | $get(key: string): any 7 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 8 | $set(key: string, value: any): void 9 | $emit: typeof Vue.prototype.$emit 10 | $on: typeof Vue.prototype.$on 11 | } 12 | 13 | export declare class VuePressStore extends Store { 14 | isPageExists(pageKey: string): boolean 15 | 16 | isPageLoaded(pageKey: string): boolean 17 | 18 | getPageAsyncComponent(pageKey: string): () => Promise 19 | 20 | loadPageAsyncComponent(pageKey: string): Promise 21 | 22 | registerPageAsyncComponent(pageKey: string): void 23 | } 24 | 25 | declare module 'vue/types/vue' { 26 | export interface Vue { 27 | $vuepress: VuePressStore 28 | } 29 | export interface VueConstructor { 30 | $vuepress: VuePressStore 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /packages/vuepress-types/types/theme-api.d.ts: -------------------------------------------------------------------------------- 1 | import { PluginOptionAPI } from './plugin' 2 | import { NormalizedPlugin } from './plugin-api' 3 | 4 | export interface ResolvedComponent { 5 | filename: string 6 | componentName: string 7 | isInternal: boolean 8 | path: string 9 | } 10 | 11 | export interface ResolvedTheme { 12 | path?: string 13 | name?: string 14 | shortcut?: string 15 | entry: Record | NormalizedPlugin 16 | } 17 | 18 | export interface ThemeAPI { 19 | theme: ResolvedTheme 20 | parentTheme: ResolvedTheme 21 | existsParentTheme: boolean 22 | vuepressPlugin: PluginOptionAPI 23 | componentMap: Record 24 | layoutComponentMap: Record 25 | setAlias: (alias: Record) => void 26 | init: () => void 27 | getComponents: () => Record 28 | getLayoutComponentMap: () => Record 29 | } 30 | -------------------------------------------------------------------------------- /packages/vuepress-types/types/theme.d.ts: -------------------------------------------------------------------------------- 1 | import { PluginOptionAPI } from './plugin' 2 | 3 | export interface ThemeOptionAPI extends PluginOptionAPI { 4 | extend?: string 5 | } 6 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "allowSyntheticDefaultImports": true, 4 | "declaration": true, 5 | "module": "es2015", 6 | "newLine": "lf", 7 | "noEmitOnError": true, 8 | "noImplicitAny": false, 9 | "moduleResolution": "node", 10 | "resolveJsonModule": true, 11 | "sourceMap": true, 12 | "strict": true, 13 | "strictNullChecks": true, 14 | "target": "es2015" 15 | } 16 | } 17 | --------------------------------------------------------------------------------