You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/en/guide/data-loading.md
+4-8
Original file line number
Diff line number
Diff line change
@@ -8,8 +8,7 @@ Data loaders can be used to fetch remote data, or generate metadata based on loc
8
8
9
9
A data loader file must end with either `.data.js` or `.data.ts`. The file should provide a default export of an object with the `load()` method:
10
10
11
-
```js
12
-
// example.data.js
11
+
```js [example.data.js]
13
12
exportdefault {
14
13
load() {
15
14
return {
@@ -84,8 +83,7 @@ export default {
84
83
85
84
When building a content focused site, we often need to create an "archive" or "index" page: a page where we list all available entries in our content collection, for example blog posts or API pages. We **can** implement this directly with the data loader API, but since this is such a common use case, VitePress also provides a `createContentLoader` helper to simplify this:
Copy file name to clipboardExpand all lines: docs/en/guide/deploy.md
+6-6
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ The following guides are based on some shared assumptions:
10
10
- You are using the default build output directory (`.vitepress/dist`).
11
11
- VitePress is installed as a local dependency in your project, and you have set up the following scripts in your `package.json`:
12
12
13
-
```json
13
+
```json [package.json]
14
14
{
15
15
"scripts": {
16
16
"docs:build": "vitepress build docs",
@@ -121,7 +121,7 @@ Don't enable options like _Auto Minify_ for HTML code. It will remove comments f
121
121
122
122
1. Create a file named `deploy.yml` inside `.github/workflows` directory of your project with some content like this:
123
123
124
-
```yaml
124
+
```yaml [.github/workflows/deploy.yml]
125
125
# Sample workflow for building and deploying a VitePress site to GitHub Pages
126
126
#
127
127
name: Deploy VitePress site to Pages
@@ -204,7 +204,7 @@ Don't enable options like _Auto Minify_ for HTML code. It will remove comments f
204
204
205
205
2. Create a file named `.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:
206
206
207
-
```yaml
207
+
```yaml [.gitlab-ci.yml]
208
208
image: node:18
209
209
pages:
210
210
cache:
@@ -237,7 +237,7 @@ Don't enable options like _Auto Minify_ for HTML code. It will remove comments f
237
237
238
238
`firebase.json`:
239
239
240
-
```json
240
+
```json [firebase.json]
241
241
{
242
242
"hosting": {
243
243
"public": "docs/.vitepress/dist",
@@ -248,7 +248,7 @@ Don't enable options like _Auto Minify_ for HTML code. It will remove comments f
248
248
249
249
`.firebaserc`:
250
250
251
-
```json
251
+
```json [.firebaserc]
252
252
{
253
253
"projects": {
254
254
"default": "<YOUR_FIREBASE_ID>"
@@ -276,7 +276,7 @@ Don't enable options like _Auto Minify_ for HTML code. It will remove comments f
276
276
277
277
2. Create a file called `static.json` in the root of your project with the below content:
@@ -68,8 +66,7 @@ If you are using optional components like the [Team Page](../reference/default-t
68
66
69
67
If your font is a local file referenced via `@font-face`, it will be processed as an asset and included under `.vitepress/dist/assets` with hashed filename. To preload this file, use the [transformHead](../reference/site-config#transformhead) build hook:
70
68
71
-
```js
72
-
// .vitepress/config.js
69
+
```js [.vitepress/config.js]
73
70
exportdefault {
74
71
transformHead({ assets }) {
75
72
// adjust the regex accordingly to match your font
@@ -94,8 +91,7 @@ export default {
94
91
95
92
## Registering Global Components
96
93
97
-
```js
98
-
// .vitepress/theme/index.js
94
+
```js [.vitepress/theme/index.js]
99
95
importDefaultThemefrom'vitepress/theme'
100
96
101
97
/**@type{import('vitepress').Theme}*/
@@ -109,8 +105,7 @@ export default {
109
105
```
110
106
111
107
If you're using TypeScript:
112
-
```ts
113
-
// .vitepress/theme/index.ts
108
+
```ts [.vitepress/theme/index.ts]
114
109
importtype { Theme } from'vitepress'
115
110
importDefaultThemefrom'vitepress/theme'
116
111
@@ -129,8 +124,7 @@ Since we are using Vite, you can also leverage Vite's [glob import feature](http
129
124
130
125
The default theme's `<Layout/>` 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 before outline:
Copy file name to clipboardExpand all lines: docs/en/guide/getting-started.md
+2-3
Original file line number
Diff line number
Diff line change
@@ -120,8 +120,7 @@ By default, VitePress stores its dev server cache in `.vitepress/cache`, and the
120
120
121
121
The config file (`.vitepress/config.js`) allows you to customize various aspects of your VitePress site, with the most basic options being the title and description of the site:
122
122
123
-
```js
124
-
// .vitepress/config.js
123
+
```js [.vitepress/config.js]
125
124
exportdefault {
126
125
// site-level options
127
126
title:'VitePress',
@@ -147,7 +146,7 @@ VitePress also provides the ability to generate clean URLs, rewrite paths, and d
147
146
148
147
The tool should have also injected the following npm scripts to your `package.json` if you allowed it to do so during the setup process:
Copy file name to clipboardExpand all lines: docs/en/guide/ssr-compat.md
+2-4
Original file line number
Diff line number
Diff line change
@@ -50,8 +50,7 @@ if (!import.meta.env.SSR) {
50
50
51
51
Since [`Theme.enhanceApp`](./custom-theme#theme-interface) can be async, you can conditionally import and register Vue plugins that access browser APIs on import:
You can include custom components in the navigation bar by using the `component` option. The `component` key should be the Vue component name, and must be registered globally using [Theme.enhanceApp](../guide/custom-theme#theme-interface).
167
167
168
-
```js
169
-
// .vitepress/config.js
168
+
```js [.vitepress/config.js]
170
169
exportdefault {
171
170
themeConfig: {
172
171
nav: [
@@ -192,8 +191,7 @@ export default {
192
191
193
192
Then, you need to register the component globally:
0 commit comments