diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 09f2a04b..b9de2cf2 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -54,10 +54,20 @@ function sidebarGuide() { text: 'Introduction', items: [ { text: 'What is VitePress?', link: '/guide/what-is-vitepress' }, + { text: 'Getting Started', link: '/guide/getting-started' }, + { text: 'Configuration', link: '/guide/configuration' }, + { text: 'Asset Handling', link: '/guide/asset-handling' }, { text: 'Markdown Extensions', link: '/guide/markdown-extensions' }, - { text: 'Frontmatter', link: '/guide/frontmatter' } + { text: 'Frontmatter', link: '/guide/frontmatter' }, + { text: 'Using Vue in Markdown', link: '/guide/using-vue' }, + { text: 'API Reference', link: '/guide/api' }, + { text: 'Deploying', link: '/guide/deploying' } ] }, + { + text: 'Theme', + items: [{ text: 'Introduction', link: '/guide/theme-introduction' }] + }, { text: 'Migrations', items: [ diff --git a/docs/components/ComponentInHeader.vue b/docs/components/ComponentInHeader.vue new file mode 100644 index 00000000..bbccc8ef --- /dev/null +++ b/docs/components/ComponentInHeader.vue @@ -0,0 +1,3 @@ + diff --git a/docs/config/introduction.md b/docs/config/introduction.md index da6c6b02..c8be97e0 100644 --- a/docs/config/introduction.md +++ b/docs/config/introduction.md @@ -1,3 +1,66 @@ # Introduction -Here we plan to describe all about configurations. What the difference between app config and theme config, how to access them within markdown or in Vue Component and such. +Place your configuration file at `.vitepress/config.js`. This is where all VitePress-specific files will be placed. + +``` +. +├─ docs +│ ├─ .vitepress +│ │ └─ config.js +│ └─ index.md +└─ package.json +``` + +## Config Intellisense + +Since VitePress ships with TypeScript typings, you can leverage your IDE's intellisense with jsdoc type hints: + +```js +/** + * @type {import('vitepress').UserConfig} + */ +const config = { + // ... +} + +export default config +``` + +Alternatively, you can use the `defineConfig` helper at which should provide intellisense without the need for jsdoc annotations: + +```js +import { defineConfig } from 'vitepress' + +export default defineConfig({ + // ... +}) +``` + +VitePress also directly supports TS config files. You can use `.vitepress/config.ts` with the `defineConfig` helper as well. + +## Typed Theme Config + +By default, `defineConfig` helper leverages the theme config type from default theme: + +```ts +import { defineConfig } from 'vitepress' + +export default defineConfig({ + themeConfig: { + // Type is `DefaultTheme.Config` + } +}) +``` + +If you use a custom theme and want type checks for the theme config, you'll need to use `defineConfigWithTheme` instead, and pass the config type for your custom theme via a generic argument: + +```ts +import { defineConfigWithTheme } from 'vitepress' +import { ThemeConfig } from 'your-theme' + +export default defineConfigWithTheme({ + themeConfig: { + // Type is `ThemeConfig` + } +}) +``` diff --git a/docs/guide/api.md b/docs/guide/api.md new file mode 100644 index 00000000..ba427e5a --- /dev/null +++ b/docs/guide/api.md @@ -0,0 +1,92 @@ +# API Reference + +VitePress offers several built in API to let you access app data. VitePress also comes with few built-in component that can be used globally. + +The helper methods are globally importable from `vitepress` and are typically used in custom theme Vue components. However, they are also usable inside `.md` pages because markdown files are compiled into Vue single-file components. + +Methods that start with `use*` indicates that it is a [Vue 3 Composition API](https://vuejs.org/guide/introduction.html#composition-api) function that can only be used inside `setup()` or ` + + +``` + +## `useRoute` + +Returns the current route object with the following type: + +```ts +interface Route { + path: string + data: PageData + component: Component | null +} +``` + +## `useRouter` + +Returns the VitePress router instance so you can programmatically navigate to another page. + +```ts +interface Router { + route: Route + go: (href?: string) => Promise +} +``` + +## `withBase` + +- **Type**: `(path: string) => string` + +Appends the configured [`base`](../config/app-configs#base) to a given URL path. Also see [Base URL](./asset-handling#base-url). + +## `` + +The `` component displays the rendered markdown contents. Useful [when creating your own theme](./theme-introduction). + +```vue + +``` + +## `` + +The `` component renders its slot only at client side. + +Because VitePress applications are server-rendered in Node.js when generating static builds, any Vue usage must conform to the universal code requirements. In short, make sure to only access Browser / DOM APIs in beforeMount or mounted hooks. + +If you are using or demoing components that are not SSR-friendly (for example, contain custom directives), you can wrap them inside the `ClientOnly` component. + +```html + + + +``` diff --git a/docs/guide/asset-handling.md b/docs/guide/asset-handling.md new file mode 100644 index 00000000..20969f9c --- /dev/null +++ b/docs/guide/asset-handling.md @@ -0,0 +1,55 @@ +# Asset Handling + +All Markdown files are compiled into Vue components and processed by [Vite](https://github.com/vitejs/vite). You can, **and should**, reference any assets using relative URLs: + +```md +![An image](./image.png) +``` + +You can reference static assets in your markdown files, your `*.vue` components in the theme, styles and plain `.css` files either using absolute public paths (based on project root) or relative paths (based on your file system). The latter is similar to the behavior you are used to if you have used `vue-cli` or webpack's `file-loader`. + +Common image, media, and font filetypes are detected and included as assets automatically. + +All referenced assets, including those using absolute paths, will be copied to the dist folder with a hashed file name in the production build. Never-referenced assets will not be copied. Similar to `vue-cli`, image assets smaller than 4kb will be base64 inlined. + +All **static** path references, including absolute paths, should be based on your working directory structure. + +## 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). + +Assets placed in `public` will be copied to the root of the dist directory as-is. + +Note that you should reference files placed in `public` using root absolute path - for example, `public/icon.png` should always be referenced in source code as `/icon.png`. + +## Base URL + +If your site is deployed to a non-root URL, you will need to set the `base` option in `.vitepress/config.js`. For example, if you plan to deploy your site to `https://foo.github.io/bar/`, then `base` should be set to `'/bar/'` (it should always start and end with a slash). + +All your static asset paths are automatically processed to adjust for different `base` config values. For example, if you have an absolute reference to an asset under `public` in your markdown: + +```md +![An image](/image-inside-public.png) +``` + +You do **not** need to update it when you change the `base` config value in this case. + +However, if you are authoring a theme component that links to assets dynamically, e.g. an image whose `src` is based on a theme config value: + +```vue + +``` + +In this case it is recommended to wrap the path with the [`withBase` helper](./api#withbase) provided by VitePress: + +```vue + + + +``` diff --git a/docs/guide/configuration.md b/docs/guide/configuration.md new file mode 100644 index 00000000..625fa8e2 --- /dev/null +++ b/docs/guide/configuration.md @@ -0,0 +1,23 @@ +# Configuration + +Without any configuration, the page is pretty minimal, and the user has no way to navigate around the site. To customize your site, let's first create a `.vitepress` directory inside your docs directory. This is where all VitePress-specific files will be placed. Your project structure is probably like this: + +``` +. +├─ docs +│ ├─ .vitepress +│ │ └─ config.js +│ └─ index.md +└─ package.json +``` + +The essential file for configuring a VitePress site is `.vitepress/config.js`, which should export a JavaScript object: + +```js +export default { + title: 'Hello VitePress', + description: 'Just playing around.' +} +``` + +Learn everything about VitePress configuration at [configuration page](../config/introduction). diff --git a/docs/guide/deploying.md b/docs/guide/deploying.md new file mode 100644 index 00000000..5e9d53f6 --- /dev/null +++ b/docs/guide/deploying.md @@ -0,0 +1,260 @@ +# Deploying + +The following guides are based on some shared assumptions: + +- You are placing your docs inside the `docs` directory of your project; +- You are using the default build output location (`.vitepress/dist`); +- VitePress is installed as a local dependency in your project, and you have setup the following npm scripts: + +```json +{ + "scripts": { + "docs:build": "vitepress build docs", + "docs:serve": "vitepress serve docs" + } +} +``` + +## Build and test locally + +You may run `yarn docs:build` command to build the docs. + +```bash +$ yarn docs:build +``` + +By default, the build output will be placed at `.vitepress/dist`. You may deploy this `dist` folder to any of your preferred platforms. + +Once you've built the docs, you may test them locally by running `yarn docs:serve` command. + +```bash +$ yarn docs:build +$ 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. + +```json +{ + "scripts": { + "docs:serve": "vitepress serve docs --port 8080" + } +} +``` + +Now the `docs:serve` method will launch the server at `http://localhost:8080`. + +## GitHub Pages + +1. Set the correct `base` in `docs/.vitepress/config.js`. + + If you are deploying to `https://.github.io/`, you can omit `base` as it defaults to `'/'`. + + If you are deploying to `https://.github.io//`, for example your repository is at `https://github.com//`, then set `base` to `'//'`. + +2. Inside your project, create `deploy.sh` with the following content (with highlighted lines uncommented appropriately), and run it to deploy: + +```bash{13,20,23} +#!/usr/bin/env sh + +# abort on errors +set -e + +# build +npm run docs:build + +# navigate into the build output directory +cd docs/.vitepress/dist + +# if you are deploying to a custom domain +# echo 'www.example.com' > CNAME + +git init +git add -A +git commit -m 'deploy' + +# if you are deploying to https://.github.io +# git push -f git@github.com:/.github.io.git main + +# if you are deploying to https://.github.io/ +# git push -f git@github.com:/.git main:gh-pages + +cd - +``` + +::: tip +You can also run the above script in your CI setup to enable automatic deployment on each push. +::: + +## GitHub Pages and Travis CI + +1. Set the correct `base` in `docs/.vitepress/config.js`. + + If you are deploying to `https://.github.io/`, you can omit `base` as it defaults to `'/'`. + + If you are deploying to `https://.github.io//`, for example your repository is at `https://github.com//`, then set `base` to `'//'`. + +2. Create a file named `.travis.yml` in the root of your project. + +3. Run `yarn` or `npm install` locally and commit the generated lockfile (that is `yarn.lock` or `package-lock.json`). + +4. Use the GitHub Pages deploy provider template, and follow the [Travis CI documentation](https://docs.travis-ci.com/user/deployment/pages). + +```yaml +language: node_js +node_js: + - lts/* +install: + - yarn install # npm ci +script: + - yarn docs:build # npm run docs:build +deploy: + provider: pages + skip_cleanup: true + local_dir: docs/.vitepress/dist + # A token generated on GitHub allowing Travis to push code on you repository. + # Set in the Travis settings page of your repository, as a secure variable. + github_token: $GITHUB_TOKEN + keep_history: true + on: + branch: main +``` + +## GitLab Pages and GitLab CI + +1. Set the correct `base` in `docs/.vitepress/config.js`. + + If you are deploying to `https://.gitlab.io/`, you can omit `base` as it defaults to `'/'`. + + If you are deploying to `https://.gitlab.io//`, for example your repository is at `https://gitlab.com//`, then set `base` to `'//'`. + +2. Set `outDir` in `.vitepress/config.js` to `../public`. + +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 +pages: + cache: + paths: + - node_modules/ + script: + - yarn install # npm install + - yarn docs:build # npm run docs:build + artifacts: + paths: + - public + only: + - main +``` + +## Netlify + +1. On [Netlify](https://www.netlify.com/), setup up a new project from GitHub with the following settings: + +- **Build Command:** `vitepress build docs` or `yarn docs:build` or `npm run docs:build` +- **Publish directory:** `docs/.vitepress/dist` + +2. Hit the deploy button. + +## Google Firebase + +1. Make sure you have [firebase-tools](https://www.npmjs.com/package/firebase-tools) installed. + +2. Create `firebase.json` and `.firebaserc` at the root of your project with the following content: + +`firebase.json`: + +```json +{ + "hosting": { + "public": "./docs/.vitepress/dist", + "ignore": [] + } +} +``` + +`.firebaserc`: + +```js +{ + "projects": { + "default": "" + } +} +``` + +3. After running `yarn docs:build` or `npm run docs:build`, deploy using the command `firebase deploy`. + +## Surge + +1. First install [surge](https://www.npmjs.com/package/surge), if you haven’t already. + +2. Run `yarn docs:build` or `npm run docs:build`. + +3. Deploy to surge by typing `surge docs/.vitepress/dist`. + +You can also deploy to a [custom domain](https://surge.sh/help/adding-a-custom-domain) by adding `surge docs/.vitepress/dist yourdomain.com`. + +## Heroku + +1. Install [Heroku CLI](https://devcenter.heroku.com/articles/heroku-cli). + +2. Create a Heroku account by [signing up](https://signup.heroku.com). + +3. Run `heroku login` and fill in your Heroku credentials: + +```bash +$ heroku login +``` + +4. Create a file called `static.json` in the root of your project with the below content: + +`static.json`: + +```json +{ + "root": "./docs/.vitepress/dist" +} +``` + +This is the configuration of your site; read more at [heroku-buildpack-static](https://github.com/heroku/heroku-buildpack-static). + +5. Set up your Heroku git remote: + +```bash +# version change +$ git init +$ git add . +$ git commit -m "My site ready for deployment." + +# creates a new app with a specified name +$ heroku apps:create example + +# set buildpack for static sites +$ heroku buildpacks:set https://github.com/heroku/heroku-buildpack-static.git +``` + +6. Deploy your site: + +```bash +# publish site +$ git push heroku main + +# opens a browser to view the Dashboard version of Heroku CI +$ heroku open +``` + +## Vercel + +To deploy your VitePress app with a [Vercel for Git](https://vercel.com/docs/concepts/git), make sure it has been pushed to a Git repository. + +Go to https://vercel.com/new and import the project into Vercel using your Git of choice (GitHub, GitLab or BitBucket). Follow the wizard to select the project root with the project's `package.json` and override the build step using `yarn docs:build` or `npm run docs:build` and the output dir to be `./docs/.vitepress/dist` + +![Override Vercel Configuration](../images/vercel-configuration.png) + +After your project has been imported, all subsequent pushes to branches will generate Preview Deployments, and all changes made to the Production Branch (commonly "main") will result in a Production Deployment. + +Once deployed, you will get a URL to see your app live, such as the following: https://vitepress.vercel.app diff --git a/docs/guide/getting-started.md b/docs/guide/getting-started.md new file mode 100644 index 00000000..cf034bdc --- /dev/null +++ b/docs/guide/getting-started.md @@ -0,0 +1,67 @@ +# Getting Started + +This section will help you build a basic VitePress documentation site from ground up. If you already have an existing project and would like to keep documentation inside the project, start from Step 3. + +## Step. 1 + +Create and change into a new directory. + +```bash +$ mkdir vitepress-starter && cd vitepress-starter +``` + +## Step. 2 + +Initialize with your preferred package manager. + +```bash +$ yarn init +``` + +## Step. 3 + +Install VitePress. + +```bash +$ yarn add --dev vitepress +``` + +## Step. 4 + +Create your first document. + +```bash +$ mkdir docs && echo '# Hello VitePress' > docs/index.md +``` + +## Step. 5 + +Add some scripts to `package.json`. + +```json +{ + ... + "scripts": { + "docs:dev": "vitepress dev docs", + "docs:build": "vitepress build docs", + "docs:serve": "vitepress serve docs" + }, + ... +} +``` + +## Step. 6 + +Serve the documentation site in the local server. + +```bash +$ yarn docs:dev +``` + +VitePress will start a hot-reloading development server at `http://localhost:3000`. + +## What's next? + +By now, you should have a basic but functional VitePress documentation site. + +When your documentation site starts to take shape, be sure to read the [deployment guide](./deploying). diff --git a/docs/guide/theme-introduction.md b/docs/guide/theme-introduction.md new file mode 100644 index 00000000..183f9e4b --- /dev/null +++ b/docs/guide/theme-introduction.md @@ -0,0 +1,179 @@ +# Theme Introduction + +VitePress comes with its own default theme, and provides a way to customize it, or evenr create your own theme. At this page, we'll go through the basics of theme customizations. + +## Using a Custom Theme + +You can enable a custom theme by adding the `.vitepress/theme/index.js` file (the "theme entry file"). + +``` +. +├─ docs +│ ├─ .vitepress +│ │ ├─ theme +│ │ │ └─ index.js +│ │ └─ config.js +│ └─ index.md +└─ package.json +``` + +A VitePress custom theme is simply an object containing three properties and is defined as follows: + +```ts +interface Theme { + Layout: Component // Vue 3 component + NotFound?: Component + enhanceApp?: (ctx: EnhanceAppContext) => void +} + +interface EnhanceAppContext { + app: App // Vue 3 app instance + router: Router // VitePress router instance + siteData: Ref +} +``` + +The theme entry file should export the theme as its default export: + +```js +// .vitepress/theme/index.js +import Layout from './Layout.vue' + +export default { + Layout, + + // this is a Vue 3 functional component + NotFound: () => 'custom 404', + + enhanceApp({ app, router, siteData }) { + // app is the Vue 3 app instance from `createApp()`. + // router is VitePress' custom router. `siteData` is + // a `ref` of current site-level metadata. + } +} +``` + +...where the `Layout` component could look like this: + +```vue + + +``` + +The default export is the only contract for a custom theme. Inside your custom theme, it works just like a normal Vite + Vue 3 application. Do note the theme also needs to be [SSR-compatible](./using-vue#browser-api-access-restrictions). + +To distribute a theme, simply export the object in your package entry. To consume an external theme, import and re-export it from the custom theme entry: + +```js +// .vitepress/theme/index.js +import Theme from 'awesome-vitepress-theme' + +export default Theme +``` + +## Extending the Default Theme + +If you want to extend and customize the default theme, you can import it from `vitepress/theme` and augment it in a custom theme entry. Here are some examples of common customizations: + +### Registering Global Components + +```js +// .vitepress/theme/index.js +import DefaultTheme from 'vitepress/theme' + +export default { + ...DefaultTheme, + enhanceApp({ app }) { + // register global components + app.component('MyGlobalComponent', /* ... */) + } +} +``` + +Since we are using Vite, you can also leverage Vite's [glob import feature](https://vitejs.dev/guide/features.html#glob-import) to auto register a directory of components. + +### Customizing CSS + +The default theme CSS is customizable by overriding root level CSS variables: + +```js +// .vitepress/theme/index.js +import DefaultTheme from 'vitepress/theme' +import './custom.css' + +export default DefaultTheme +``` + +```css +/* .vitepress/theme/custom.css */ +:root { + --vp-c-brand: #646cff; + --vp-c-brand-light: #747bff; +} +``` + +See [default theme CSS variables](https://github.com/vuejs/vitepress/blob/main/src/client/theme-default/styles/vars.css) that can be overridden. + +### Layout Slots + +The default theme's `` component has a few slots that can be used to inject content at certain locations of the page. Here's an example of injecting a component into the top of the sidebar: + +```js +// .vitepress/theme/index.js +import DefaultTheme from 'vitepress/theme' +import MyLayout from './MyLayout.vue' + +export default { + ...DefaultTheme, + // override the Layout with a wrapper component that + // injects the slots + Layout: MyLayout +} +``` + +```vue + + + + +``` + +Or you could use render function as well. + +```js +// .vitepress/theme/index.js +import DefaultTheme from 'vitepress/theme' +import MyComponent from './MyComponent.vue' + +export default { + ...DefaultTheme, + Layout() { + return h(DefaultTheme.Layout, null, { + 'sidebar-top': () => h(MyComponent) + }) + } +} +``` + +Full list of slots available in the default theme layout: + +- Only when `layout: 'home'` is enabled via frontmatter: + - `home-hero-before` + - `home-hero-after` + - `home-features-before` + - `home-features-after` diff --git a/docs/guide/using-vue.md b/docs/guide/using-vue.md new file mode 100644 index 00000000..8ed6b0aa --- /dev/null +++ b/docs/guide/using-vue.md @@ -0,0 +1,261 @@ +# Using Vue in Markdown + +In VitePress, each markdown file is compiled into HTML and then processed as a Vue Single-File Component. This means you can use any Vue features inside the markdown, including dynamic templating, using Vue components, or arbitrary in-page Vue component logic by adding a ` + +
{{ page }}
+``` + +**Output** + +```json +{ + "path": "/using-vue.html", + "title": "Using Vue in Markdown", + "frontmatter": {} +} +``` + +## Escaping + +By default, fenced code blocks are automatically wrapped with `v-pre`. To display raw mustaches or Vue-specific syntax inside inline code snippets or plain text, you need to wrap a paragraph with the `v-pre` custom container: + +**Input** + +```md +::: v-pre +`{{ This will be displayed as-is }}` +::: +``` + +**Output** + +::: v-pre +`{{ This will be displayed as-is }}` +::: + +## Using Components + +When you need to have more flexibility, VitePress allows you to extend your authoring toolbox with your own Vue Components. + +### Importing components in markdown + +If your components are going to be used in only a few places, the recommended way to use them is to importing the components in the file where it is used. + +```md + + +# Docs + +This is a .md using a custom component + + + +## More docs + +... +``` + +### Registering global components in the theme + +If the components are going to be used across several pages in the docs, they can be registered globally in the theme (or as part of extending the default VitePress theme). Check out the [Theming Guide](./theme-introduction) for more information. + +In `.vitepress/theme/index.js`, the `enhanceApp` function receives the Vue `app` instance so you can [register components](https://vuejs.org/guide/components/registration.html) as you would do in a regular Vue application. + +```js +import DefaultTheme from 'vitepress/theme' + +export default { + ...DefaultTheme, + enhanceApp({ app }) { + app.component('VueClickAwayExample', VueClickAwayExample) + } +} +``` + +Later in your markdown files, the component can be interleaved between the content + +```md +# Vue Click Away + + +``` + +::: warning IMPORTANT +Make sure a custom component’s name either contains a hyphen or is in PascalCase. Otherwise, it will be treated as an inline element and wrapped inside a `

` tag, which will lead to hydration mismatch because `

` does not allow block elements to be placed inside it. +::: + +### Using Components In Headers + +You can use Vue components in the headers, but note the difference between the following syntaxes: + +| Markdown | Output HTML | Parsed Header | +| ------------------------------------------------------- | ----------------------------------------- | ------------- | +|

 # text <Tag/> 
| `

text

` | `text` | +|
 # text \`<Tag/>\` 
| `

text <Tag/>

` | `text ` | + +The HTML wrapped by `` will be displayed as-is; only the HTML that is **not** wrapped will be parsed by Vue. + +::: tip +The output HTML is accomplished by [markdown-it](https://github.com/markdown-it/markdown-it), while the parsed headers are handled by VitePress (and used for both the sidebar and document title). +::: + +## Using CSS Pre-processors + +VitePress has [built-in support](https://vitejs.dev/guide/features.html#css-pre-processors) for CSS pre-processors: `.scss`, `.sass`, `.less`, `.styl` and `.stylus` files. There is no need to install Vite-specific plugins for them, but the corresponding pre-processor itself must be installed: + +``` +# .scss and .sass +npm install -D sass + +# .less +npm install -D less + +# .styl and .stylus +npm install -D stylus +``` + +Then you can use the following in Markdown and theme components: + +```vue + +``` + +## Script & Style Hoisting + +Sometimes you may need to apply some JavaScript or CSS only to the current page. In those cases, you can directly write root-level ` + +## Built-In Components + +VitePress provides Built-In Vue Components like `ClientOnly` and `OutboundLink`, check out the [Global Component Guide](./api) for more information. + +**Also see:** + +- [Using Components In Headers](#using-components-in-headers) + +## Browser API Access Restrictions + +Because VitePress applications are server-rendered in Node.js when generating static builds, any Vue usage must conform to the [universal code requirements](https://vuejs.org/guide/scaling-up/ssr.html). In short, make sure to only access Browser / DOM APIs in `beforeMount` or `mounted` hooks. + +If you are using or demoing components that are not SSR-friendly (for example, contain custom directives), you can wrap them inside the built-in `` component: + +```md + + + +``` + +Note this does not fix components or libraries that access Browser APIs **on import**. To use code that assumes a browser environment on import, you need to dynamically import them in proper lifecycle hooks: + +```vue + +``` + +If your module `export default` a Vue component, you can register it dynamically: + +```vue + + + +``` + +**Also see:** + +- [Vue.js > Dynamic Components](https://vuejs.org/guide/essentials/component-basics.html#dynamic-components) diff --git a/docs/images/line-numbers-desktop.png b/docs/images/line-numbers-desktop.png new file mode 100644 index 00000000..e16e6707 Binary files /dev/null and b/docs/images/line-numbers-desktop.png differ diff --git a/docs/images/line-numbers-mobile.gif b/docs/images/line-numbers-mobile.gif new file mode 100644 index 00000000..87af6cf0 Binary files /dev/null and b/docs/images/line-numbers-mobile.gif differ diff --git a/docs/images/vercel-configuration.png b/docs/images/vercel-configuration.png new file mode 100644 index 00000000..51874e15 Binary files /dev/null and b/docs/images/vercel-configuration.png differ diff --git a/docs/index.md b/docs/index.md index ac33ff2b..dfbec2ea 100644 --- a/docs/index.md +++ b/docs/index.md @@ -11,7 +11,7 @@ hero: actions: - theme: brand text: Get Started - link: /guide/what-is-vitepress + link: /guide/getting-started - theme: alt text: View on GitHub link: https://github.com/vuejs/vitepress diff --git a/src/client/theme-default/components/VPDocFooter.vue b/src/client/theme-default/components/VPDocFooter.vue index e8db091f..b5d724cf 100644 --- a/src/client/theme-default/components/VPDocFooter.vue +++ b/src/client/theme-default/components/VPDocFooter.vue @@ -44,7 +44,7 @@ const control = usePrevNext() } .edit-link { - padding-bottom: 8px; + padding-bottom: 14px; } .edit-link-button {