Skip to content

Commit

Permalink
feat: add lastUpdated option to frontmatter
Browse files Browse the repository at this point in the history
  • Loading branch information
kiaking committed Jun 6, 2022
1 parent 92659a2 commit b31fbf3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
13 changes: 13 additions & 0 deletions docs/config/frontmatter-configs.md
Expand Up @@ -76,6 +76,19 @@ type Head =
| [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
- Type: `doc | home | page`
Expand Down
18 changes: 10 additions & 8 deletions src/client/theme-default/components/VPDocFooter.vue
@@ -1,4 +1,5 @@
<script setup lang="ts">
import { computed } from 'vue'
import { useData } from 'vitepress'
import { normalizeLink } from '../support/utils'
import { useEditLink } from '../composables/edit-link'
Expand All @@ -11,6 +12,10 @@ const { theme, page, frontmatter } = useData()
const editLink = useEditLink()
const control = usePrevNext()
const hasLastUpdated = computed(() => {
return page.value.lastUpdated && frontmatter.value.lastUpdated !== false
})
</script>

<template>
Expand All @@ -23,7 +28,7 @@ const control = usePrevNext()
</VPLink>
</div>

<div v-if="page.lastUpdated" class="last-updated">
<div v-if="hasLastUpdated" class="last-updated">
<VPDocFooterLastUpdated />
</div>
</div>
Expand Down Expand Up @@ -58,21 +63,18 @@ const control = usePrevNext()
.edit-info {
display: flex;
justify-content: space-between;
align-items: baseline;
align-items: center;
padding-bottom: 14px;
}
}
.edit-link {
line-height: 32px;
font-size: 14px;
font-weight: 500;
}
.edit-link-button {
display: flex;
align-items: center;
border: 0;
line-height: 32px;
font-size: 14px;
font-weight: 500;
color: var(--vp-c-brand);
transition: color 0.25s;
}
Expand Down

0 comments on commit b31fbf3

Please sign in to comment.