mirror of https://github.com/vuejs/vitepress
Merge 38b8c4dc2e
into 0c434bf537
commit
bcc1d176a5
@ -0,0 +1,54 @@
|
|||||||
|
# Print Pages
|
||||||
|
|
||||||
|
You can control what parts of the pages are printed using the `print` option. VitePress will show the whole page by default, excluding carbon-ads.
|
||||||
|
|
||||||
|
Any page with Frontmatter configuration will override the global configuration, for example, the navbar will be hidden when the page containing `navbar: false`.
|
||||||
|
|
||||||
|
VitePress has the `screen-only` class to hide elements when printing, you can use it in any component, html or Markdown html content.
|
||||||
|
|
||||||
|
```js
|
||||||
|
export default {
|
||||||
|
themeConfig: {
|
||||||
|
// or `print: false` to print only the main content
|
||||||
|
print: {
|
||||||
|
outline: true,
|
||||||
|
navbar: true,
|
||||||
|
sidebar: true,
|
||||||
|
footer: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## navbar
|
||||||
|
|
||||||
|
- Type: `boolean`
|
||||||
|
|
||||||
|
- Details:
|
||||||
|
|
||||||
|
This flag will control the navbar visibility when printing, and will be overriden by the Frontmatter navbar option if set to `false` (navbar will not be visible).
|
||||||
|
|
||||||
|
## sidebar
|
||||||
|
|
||||||
|
- Type: `boolean`
|
||||||
|
|
||||||
|
- Details:
|
||||||
|
|
||||||
|
This flag will control the left sidebar visibility when printing, and will be overriden by the Frontmatter sidebar option if set to `false` (sidebar will not be visible).
|
||||||
|
|
||||||
|
## outline
|
||||||
|
|
||||||
|
- Type: `boolean`
|
||||||
|
|
||||||
|
- Details:
|
||||||
|
|
||||||
|
This flag will control the aside and outline visibility when printing, and will be overriden by the Frontmatter aside and outline options if any set to `false` (right aside will not be visible).
|
||||||
|
|
||||||
|
|
||||||
|
## footer
|
||||||
|
|
||||||
|
- Type: `boolean`
|
||||||
|
|
||||||
|
- Details:
|
||||||
|
|
||||||
|
This flag will control the footer visibility when printing, and will be overriden by the Frontmatter footer option if set to `false` (footer will not be visible).
|
@ -0,0 +1,18 @@
|
|||||||
|
import { useData } from './data'
|
||||||
|
import type { DefaultTheme } from 'vitepress/theme'
|
||||||
|
import { computed } from 'vue'
|
||||||
|
|
||||||
|
export function useScreenOnly(entry: keyof DefaultTheme.PrintOptions) {
|
||||||
|
const { theme, frontmatter } = useData()
|
||||||
|
|
||||||
|
// we have aside and outline in frontmatter, we will check for both for outline
|
||||||
|
return computed(
|
||||||
|
() =>
|
||||||
|
(entry === 'outline'
|
||||||
|
? frontmatter.value.aside === false ||
|
||||||
|
frontmatter.value.outline === false
|
||||||
|
: frontmatter.value[entry] === false) ||
|
||||||
|
theme.value.print === false ||
|
||||||
|
theme.value.print![entry] === false
|
||||||
|
)
|
||||||
|
}
|
Loading…
Reference in new issue