feat(theme): add footer frontmatter

This commit is contained in:
pengzhanbo 2025-11-20 21:09:26 +08:00
parent a4bea8202b
commit ddb77a06a5
3 changed files with 19 additions and 3 deletions

View File

@ -227,3 +227,11 @@ permalink: /config/frontmatter/basic/
当类型为 WatermarkOptions 时,表示当前页面水印配置。 当类型为 WatermarkOptions 时,表示当前页面水印配置。
可以参考 [watermark-js-plus](https://zhensherlock.github.io/watermark-js-plus/zh/config/) 。 可以参考 [watermark-js-plus](https://zhensherlock.github.io/watermark-js-plus/zh/config/) 。
### footer
- 类型: `boolean`
- 默认值: `true`
- 详情:
当前文章是否 显示 页脚信息。

View File

@ -228,3 +228,11 @@ Display a badge on the right side of the article title.
When the type is WatermarkOptions, it represents the watermark configuration for the current page. When the type is WatermarkOptions, it represents the watermark configuration for the current page.
You can refer to [watermark-js-plus](https://zhensherlock.github.io/watermark-js-plus/zh/config/). You can refer to [watermark-js-plus](https://zhensherlock.github.io/watermark-js-plus/zh/config/).
### footer
- Type: `boolean`
- Default: `true`
- Details:
Whether to display the footer for the current article.

View File

@ -4,21 +4,21 @@ import { onMounted, ref } from 'vue'
import { useData, useSidebar } from '../composables/index.js' import { useData, useSidebar } from '../composables/index.js'
import { inBrowser } from '../utils/index.js' import { inBrowser } from '../utils/index.js'
const { theme } = useData() const { theme, frontmatter } = useData()
const { hasSidebar } = useSidebar() const { hasSidebar } = useSidebar()
const footerHeight = useCssVar('--vp-footer-height', inBrowser ? document.body : null) const footerHeight = useCssVar('--vp-footer-height', inBrowser ? document.body : null)
const footer = ref<HTMLElement | null>(null) const footer = ref<HTMLElement | null>(null)
onMounted(() => { onMounted(() => {
if (theme.value.footer && footer.value) if (theme.value.footer && frontmatter.value.footer !== false && footer.value)
footerHeight.value = `${footer.value.offsetHeight}px` footerHeight.value = `${footer.value.offsetHeight}px`
}) })
</script> </script>
<template> <template>
<footer <footer
v-if="theme.footer" v-if="theme.footer && frontmatter.footer !== false"
ref="footer" ref="footer"
class="vp-footer" class="vp-footer"
:class="{ 'has-sidebar': hasSidebar }" :class="{ 'has-sidebar': hasSidebar }"