重构:扩展默认主题的页脚配置

This commit is contained in:
2022-07-21 22:01:17 +08:00
parent a87b93dc0e
commit 92cc6fb8af
4 changed files with 74 additions and 4 deletions

View File

@@ -15,10 +15,11 @@ export const themeConfig: DefaultTheme.Config = {
pattern: 'https://github.com/Charles7c/charles7c.github.io/edit/main/repos/:path',
text: '在 GitHub 上编辑此页面'
},
// 版权标识
footer: {
message: 'Released under the MIT License.',
copyright: `Copyright © 2019-${new Date().getFullYear()} Charles7c`
// 页脚配置, 由于vitepress官方没有此计划, 所以自行定制
footerConfig: {
showFooter: true, // 是否显示页脚
message: `<a href="https://beian.miit.gov.cn/" target="_blank">京ICP备20003712号-2</a>`, // 备案信息
copyright : `Copyright © 2019-${new Date().getFullYear()} Charles7c` // 版权信息
},
// 全文搜索
algolia: {

View File

@@ -0,0 +1,50 @@
<template>
<footer v-if="theme.footerConfig.showFooter" class="VPFooter">
<div class="container">
<p class="message" v-html="theme.footerConfig.message"></p>
<p class="copyright" v-html="theme.footerConfig.copyright"></p>
</div>
</footer>
</template>
<script lang="ts" setup>
import { useData } from 'vitepress'
const { theme } = useData()
</script>
<style scoped>
.VPFooter {
position: relative;
z-index: var(--vp-z-index-footer);
border-top: 1px solid var(--vp-c-divider-light);
padding: 32px 24px;
background-color: var(--vp-c-bg);
}
.VPFooter.has-sidebar {
display: none;
}
@media (min-width: 768px) {
.VPFooter {
padding: 32px;
}
}
.container {
margin: 0 auto;
max-width: var(--vp-layout-max-width);
text-align: center;
}
.message,
.copyright {
line-height: 24px;
font-size: 14px;
font-weight: 500;
color: var(--vp-c-text-2);
}
.message { order: 2; }
.copyright { order: 1; }
p {
margin: 0;
}
</style>

View File

@@ -0,0 +1,17 @@
<template>
<Layout>
<template #layout-bottom>
<Copyright />
</template>
</Layout>
</template>
<script lang="ts" setup>
import DefaultTheme from "vitepress/theme"
import Copyright from "./Copyright.vue"
const { Layout } = DefaultTheme
</script>
<style scoped>
</style>

View File

@@ -1,4 +1,5 @@
import DefaultTheme from 'vitepress/theme'
import MyLayout from "./components/MyLayout.vue"
import ElementPlus from 'element-plus'
import "element-plus/dist/index.css"
import * as ElIcons from '@element-plus/icons-vue'
@@ -11,6 +12,7 @@ import './custom.css'
export default {
...DefaultTheme,
Layout: MyLayout,
enhanceApp({ app }) {
// 全局注册ElementPlus的所有图标
for (const [key, elIcon] of Object.entries(ElIcons)) {