Skip to content

Commit 2ae90a2

Browse files
zonemeenbrc-dd
andauthored
feat(theme): support custom page class (#2696)
Co-authored-by: Divyansh Singh <[email protected]>
1 parent 13f94a6 commit 2ae90a2

File tree

2 files changed

+32
-12
lines changed

2 files changed

+32
-12
lines changed

docs/reference/frontmatter-config.md

+31-11
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ type HeadConfig =
8686
8787
The following frontmatter options are only applicable when using the default theme.
8888
89-
### layout <Badge type="info" text="default theme only" />
89+
### layout
9090
9191
- Type: `doc | home | page`
9292
- Default: `doc`
@@ -103,15 +103,15 @@ layout: doc
103103
---
104104
```
105105
106-
### hero <Badge type="info" text="default theme only" /> <Badge type="info" text="Home page only" />
106+
### hero <Badge type="info" text="home page only" />
107107
108108
Defines contents of home hero section when `layout` is set to `home`. More details in [Default Theme: Home Page](./default-theme-home-page).
109109
110-
### features <Badge type="info" text="default theme only" /> <Badge type="info" text="Home page only" />
110+
### features <Badge type="info" text="home page only" />
111111
112112
Defines items to display in features section when `layout` is set to `home`. More details in [Default Theme: Home Page](./default-theme-home-page).
113113
114-
### navbar <Badge type="info" text="default theme only" />
114+
### navbar
115115
116116
- Type: `boolean`
117117
- Default: `true`
@@ -124,7 +124,7 @@ navbar: false
124124
---
125125
```
126126
127-
### sidebar <Badge type="info" text="default theme only" />
127+
### sidebar
128128
129129
- Type: `boolean`
130130
- Default: `true`
@@ -137,7 +137,7 @@ sidebar: false
137137
---
138138
```
139139
140-
### aside <Badge type="info" text="default theme only" />
140+
### aside
141141
142142
- Type: `boolean | 'left'`
143143
- Default: `true`
@@ -154,14 +154,14 @@ aside: false
154154
---
155155
```
156156
157-
### outline <Badge type="info" text="default theme only" />
157+
### outline
158158
159159
- Type: `number | [number, number] | 'deep' | false`
160160
- Default: `2`
161161
162162
The levels of header in the outline to display for the page. It's same as [config.themeConfig.outline](./default-theme-config#outline), and it overrides the theme config.
163163
164-
### lastUpdated <Badge type="info" text="default theme only" />
164+
### lastUpdated
165165
166166
- Type: `boolean`
167167
- Default: `true`
@@ -174,7 +174,7 @@ lastUpdated: false
174174
---
175175
```
176176
177-
### editLink <Badge type="info" text="default theme only" />
177+
### editLink
178178
179179
- Type: `boolean`
180180
- Default: `true`
@@ -187,15 +187,35 @@ editLink: false
187187
---
188188
```
189189
190-
### footer <Badge type="info" text="default theme only" />
190+
### footer
191191
192192
- Type: `boolean`
193193
- Default: `true`
194194
195-
Whether to display [footer](./default-theme-footer).
195+
Whether to display [footer](./default-theme-footer).
196196
197197
```yaml
198198
---
199199
footer: false
200200
---
201201
```
202+
203+
### pageClass
204+
205+
- Type: `string`
206+
207+
Add extra class name to a specific page.
208+
209+
```yaml
210+
---
211+
pageClass: custom-page-class
212+
---
213+
```
214+
215+
Then you can customize styles of this specific page in `.vitepress/theme/custom.css` file:
216+
217+
```css
218+
.custom-page-class {
219+
  /* page-specific styles */
220+
}
221+
```

src/client/theme-default/Layout.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ provide('hero-image-slot-exists', heroImageSlotExists)
3434
</script>
3535

3636
<template>
37-
<div v-if="frontmatter.layout !== false" class="Layout">
37+
<div v-if="frontmatter.layout !== false" class="Layout" :class="frontmatter.pageClass" >
3838
<slot name="layout-top" />
3939
<VPSkipLink />
4040
<VPBackdrop class="backdrop" :show="isSidebarOpen" @click="closeSidebar" />

0 commit comments

Comments
 (0)