feat: add `lastUpdated` option to frontmatter

pull/731/head
Kia Ishii 3 years ago
parent 92659a2e9d
commit b31fbf3621

@ -76,6 +76,19 @@ type Head =
| [string, Record<string, string>, string] | [string, Record<string, string>, string]
``` ```
## lastUpdated
- Type: `boolean`
- Default: `true`
Whether to display [Last Updated](../guide/theme-last-updated) text in the current page.
```yaml
---
lastUpdated: false
---
```
## layout ## layout
- Type: `doc | home | page` - Type: `doc | home | page`

@ -1,4 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed } from 'vue'
import { useData } from 'vitepress' import { useData } from 'vitepress'
import { normalizeLink } from '../support/utils' import { normalizeLink } from '../support/utils'
import { useEditLink } from '../composables/edit-link' import { useEditLink } from '../composables/edit-link'
@ -11,6 +12,10 @@ const { theme, page, frontmatter } = useData()
const editLink = useEditLink() const editLink = useEditLink()
const control = usePrevNext() const control = usePrevNext()
const hasLastUpdated = computed(() => {
return page.value.lastUpdated && frontmatter.value.lastUpdated !== false
})
</script> </script>
<template> <template>
@ -23,7 +28,7 @@ const control = usePrevNext()
</VPLink> </VPLink>
</div> </div>
<div v-if="page.lastUpdated" class="last-updated"> <div v-if="hasLastUpdated" class="last-updated">
<VPDocFooterLastUpdated /> <VPDocFooterLastUpdated />
</div> </div>
</div> </div>
@ -58,21 +63,18 @@ const control = usePrevNext()
.edit-info { .edit-info {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: baseline; align-items: center;
padding-bottom: 14px; padding-bottom: 14px;
} }
} }
.edit-link {
line-height: 32px;
font-size: 14px;
font-weight: 500;
}
.edit-link-button { .edit-link-button {
display: flex; display: flex;
align-items: center; align-items: center;
border: 0; border: 0;
line-height: 32px;
font-size: 14px;
font-weight: 500;
color: var(--vp-c-brand); color: var(--vp-c-brand);
transition: color 0.25s; transition: color 0.25s;
} }

Loading…
Cancel
Save