diff --git a/CHANGELOG.md b/CHANGELOG.md index cd87c3a2..4702da1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# [1.0.0-alpha.1](https://github.com/vuejs/vitepress/compare/v0.22.4...v1.0.0-alpha.1) (2022-06-01) + +Complete rewrite on default theme, with bunch of features added. Please refer to the docs for the new feature and changes. + ## [0.22.4](https://github.com/vuejs/vitepress/compare/v0.22.3...v0.22.4) (2022-05-06) ### Bug Fixes diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index f3581977..23eeac47 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -16,9 +16,7 @@ export default defineConfig({ }, editLink: { - repo: 'vuejs/vitepress', - branch: 'next', - dir: 'docs', + pattern: 'https://github.com/vuejs/vitepress/edit/main/docs/:path', text: 'Edit this page on GitHub' }, diff --git a/docs/config/frontmatter-configs.md b/docs/config/frontmatter-configs.md index d57e6cba..25dd222c 100644 --- a/docs/config/frontmatter-configs.md +++ b/docs/config/frontmatter-configs.md @@ -76,6 +76,19 @@ type Head = | [string, Record, string] ``` +## lastUpdated + +- Type: `boolean` +- Default: `true` + +Whether to display [Last Updated](../guide/theme-last-updated) text in the current page. + +```yaml +--- +lastUpdated: false +--- +``` + ## layout - Type: `doc | home | page` diff --git a/docs/config/theme-configs.md b/docs/config/theme-configs.md index 17c24708..37564b78 100644 --- a/docs/config/theme-configs.md +++ b/docs/config/theme-configs.md @@ -188,6 +188,30 @@ export interface Footer { } ``` +## editLink + +- Type: `EditLink` + +Edit Link lets you display a link to edit the page on Git management services such as GitHub, or GitLab. See [Theme: Edit Link](../guide/theme-edit-link) for more details. + +```js +export default { + themeConfig: { + editLink: { + pattern: 'https://github.com/vuejs/vitepress/edit/main/docs/:path', + text: 'Edit this page on GitHub' + } + } +} +``` + +```ts +export interface EditLink { + pattern: string + text?: string +} +``` + ## lastUpdatedText - Type: `string` diff --git a/docs/guide/asset-handling.md b/docs/guide/asset-handling.md index 20969f9c..dd6105a4 100644 --- a/docs/guide/asset-handling.md +++ b/docs/guide/asset-handling.md @@ -16,7 +16,7 @@ All **static** path references, including absolute paths, should be based on you ## Public Files -Sometimes you may need to provide static assets that are not directly referenced in any of your Markdown or theme components (for example, favicons and PWA icons). The `public` directory under project root can be used as an escape hatch to provide static assets that either are never referenced in source code (e.g. `robots.txt`), or must retain the exact same file name (without hashing). +Sometimes you may need to provide static assets that are not directly referenced in any of your Markdown or theme components (for example, favicons and PWA icons). The `public` directory under project root (`docs` folder if you're running `vitepress build docs`) can be used as an escape hatch to provide static assets that either are never referenced in source code (e.g. `robots.txt`), or must retain the exact same file name (without hashing). Assets placed in `public` will be copied to the root of the dist directory as-is. diff --git a/docs/guide/configuration.md b/docs/guide/configuration.md index 852a36bf..077d31b6 100644 --- a/docs/guide/configuration.md +++ b/docs/guide/configuration.md @@ -15,13 +15,13 @@ The essential file for configuring a VitePress site is `.vitepress/config.js`, w ```js export default { - title: 'Hello VitePress', + title: 'VitePress', description: 'Just playing around.' } ``` -In the above example, the site will have the title of `VitePress`, and `Just playing around` as description meta tag. +In the above example, the site will have the title of `VitePress`, and `Just playing around.` as the description meta tag. -Learn everything about VitePress features at [Theme: Introduction](./theme-introduction) to find how to configure specific features with in this config file. +Learn everything about VitePress features at [Theme: Introduction](./theme-introduction) to find how to configure specific features within this config file. You may also find all configuration references at [Configs](../config/introduction). diff --git a/docs/guide/deploying.md b/docs/guide/deploying.md index 5e9d53f6..4b7c4c33 100644 --- a/docs/guide/deploying.md +++ b/docs/guide/deploying.md @@ -34,7 +34,7 @@ $ yarn docs:serve The `serve` command will boot up local static web server that serves the files from `.vitepress/dist` at `http://localhost:5000`. It's an easy way to check if the production build looks OK in your local environment. -You may configure the port of the server py passing `--port` flag as an argument. +You may configure the port of the server by passing `--port` flag as an argument. ```json { @@ -135,7 +135,7 @@ deploy: 3. Create a file called `.gitlab-ci.yml` in the root of your project with the content below. This will build and deploy your site whenever you make changes to your content: ```yaml -image: node:10.22.0 +image: node:16 pages: cache: paths: diff --git a/docs/guide/markdown.md b/docs/guide/markdown.md index 846b867f..39716fef 100644 --- a/docs/guide/markdown.md +++ b/docs/guide/markdown.md @@ -364,12 +364,12 @@ It also supports [line highlighting](#line-highlighting-in-code-blocks): The value of `@` corresponds to the source root. By default it's the VitePress project root, unless `srcDir` is configured. ::: -You can also use a [VS Code region](https://code.visualstudio.com/docs/editor/codebasics#_folding) to only include the corresponding part of the code file. You can provide a custom region name after a `#` following the filepath (`snippet` by default): +You can also use a [VS Code region](https://code.visualstudio.com/docs/editor/codebasics#_folding) to only include the corresponding part of the code file. You can provide a custom region name after a `#` following the filepath: **Input** ```md -<<< @/snippets/snippet-with-region.js{1} +<<< @/snippets/snippet-with-region.js#snippet{1} ``` **Code file** diff --git a/docs/guide/theme-edit-link.md b/docs/guide/theme-edit-link.md index 39eba214..64e74b31 100644 --- a/docs/guide/theme-edit-link.md +++ b/docs/guide/theme-edit-link.md @@ -1,3 +1,28 @@ # Edit Link -Documentation coming soon... +Edit Link lets you display a link to edit the page on Git management services such as GitHub, or GitLab. To enable it, add `themeConfig.editLink` options to your config. + +```js +export default { + themeConfig: { + editLink: { + pattern: 'https://github.com/vuejs/vitepress/edit/main/docs/:path' + } + } +} +``` + +The `pattern` option defines the URL structure for the link, and `:path` is going to be replaced with the page path. + +By default, this will add the link text "Edit this page" at the bottom of the doc page. You may customize this text by defining the `text` option. + +```js +export default { + themeConfig: { + editLink: { + pattern: 'https://github.com/vuejs/vitepress/edit/main/docs/:path', + text: 'Edit this page on GitHub' + } + } +} +``` diff --git a/docs/guide/theme-sidebar.md b/docs/guide/theme-sidebar.md index 3a2c853d..1433c05d 100644 --- a/docs/guide/theme-sidebar.md +++ b/docs/guide/theme-sidebar.md @@ -68,7 +68,7 @@ export default { ## Multiple Sidebars -You may show different sidebar depending on the page path. For example, as shown on this site, you might want to create a separate sections of content in your documentation like "Guide" page and `Config` page. +You may show different sidebar depending on the page path. For example, as shown on this site, you might want to create a separate sections of content in your documentation like "Guide" page and "Config" page. To do so, first organize your pages into directories for each desired section: @@ -92,27 +92,31 @@ export default { sidebar: { // This sidebar gets displayed when user is // under `guide` directory. - '/guide/': { - text: 'Guide', - items: [ - // This shows `/guide/index.md` page. - { text: 'Index', link: '/guide/' }, // /guide/index.md - { text: 'One', link: '/guide/one' }, // /guide/one.md - { text: 'Two', link: '/guide/two' } // /guide/two.md - ] - }, + '/guide/': [ + { + text: 'Guide', + items: [ + // This shows `/guide/index.md` page. + { text: 'Index', link: '/guide/' }, // /guide/index.md + { text: 'One', link: '/guide/one' }, // /guide/one.md + { text: 'Two', link: '/guide/two' } // /guide/two.md + ] + } + ], // This sidebar gets displayed when user is // under `config` directory. - '/config/': { - text: 'Config', - items: [ - // This shows `/guide/index.md` page. - { text: 'Index', link: '/config/' }, // /config/index.mdasdfasdfasdfasdfaf - { text: 'Three', link: '/config/three' }, // /config/three.md - { text: 'Four', link: '/config/four' } // /config/four.md - ] - } + '/config/': [ + { + text: 'Config', + items: [ + // This shows `/guide/index.md` page. + { text: 'Index', link: '/config/' }, // /config/index.md + { text: 'Three', link: '/config/three' }, // /config/three.md + { text: 'Four', link: '/config/four' } // /config/four.md + ] + } + ] } } } diff --git a/package.json b/package.json index d1cd5fe0..6f918243 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vitepress", - "version": "1.0.0-draft.8", + "version": "1.0.0-alpha.1", "description": "Vite & Vue powered static site generator", "type": "module", "packageManager": "pnpm@7.1.7", diff --git a/scripts/release.js b/scripts/release.js index 94f900ba..8da3732a 100644 --- a/scripts/release.js +++ b/scripts/release.js @@ -1,15 +1,20 @@ import { readFileSync, writeFileSync } from 'fs' import { resolve } from 'path' +import { fileURLToPath } from 'url' import c from 'picocolors' -import { inc as _inc, valid } from 'semver' import prompts from 'prompts' import { execa } from 'execa' -import { version as currentVersion } from '../package.json' -import { fileURLToPath } from 'url' +import semver from 'semver' +import pkg from '../package.json' assert { type: 'json' } + +const { version: currentVersion } = pkg +const { inc: _inc, valid } = semver const versionIncrements = ['patch', 'minor', 'major'] -const dir = dirname(fileURLToPath(import.meta.url)) +const tags = ['latest', 'next'] + +const dir = fileURLToPath(new URL('.', import.meta.url)) const inc = (i) => _inc(currentVersion, i) const run = (bin, args, opts = {}) => execa(bin, args, { stdio: 'inherit', ...opts }) @@ -18,34 +23,45 @@ const step = (msg) => console.log(c.cyan(msg)) async function main() { let targetVersion + const versions = versionIncrements + .map((i) => `${i} (${inc(i)})`) + .concat(['custom']) + const { release } = await prompts({ type: 'select', name: 'release', message: 'Select release type', - choices: versionIncrements.map((i) => `${i} (${inc(i)})`).concat(['custom']) + choices: versions }) - - if (release === 'custom') { + console.log(release, release === 3) + if (release === 3) { targetVersion = ( await prompts({ - type: 'input', + type: 'text', name: 'version', message: 'Input custom version', initial: currentVersion }) ).version } else { - targetVersion = release.match(/\((.*)\)/)[1] + targetVersion = versions[release].match(/\((.*)\)/)[1] } if (!valid(targetVersion)) { throw new Error(`Invalid target version: ${targetVersion}`) } + const { tag } = await prompts({ + type: 'select', + name: 'tag', + message: 'Select tag type', + choices: tags + }) + const { yes: tagOk } = await prompts({ type: 'confirm', name: 'yes', - message: `Releasing v${targetVersion}. Confirm?` + message: `Releasing v${targetVersion} on ${tags[tag]}. Confirm?` }) if (!tagOk) { @@ -83,7 +99,13 @@ async function main() { // Publish the package. step('\nPublishing the package...') - await run('pnpm', ['publish', '--ignore-scripts', '--no-git-checks']) + await run('pnpm', [ + 'publish', + '--tag', + tags[tag], + '--ignore-scripts', + '--no-git-checks' + ]) // Push to GitHub. step('\nPushing to GitHub...') diff --git a/src/client/theme-default/components/VPButton.vue b/src/client/theme-default/components/VPButton.vue index d6c5d246..e1d3408a 100644 --- a/src/client/theme-default/components/VPButton.vue +++ b/src/client/theme-default/components/VPButton.vue @@ -1,5 +1,6 @@