fix(theme): hide doc footer if empty (#1126)

pull/1134/head
Divyansh Singh 2 years ago committed by GitHub
parent 8e190aa411
commit 70da5f275b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -13,15 +13,21 @@ const { theme, page, frontmatter } = useData()
const editLink = useEditLink() const editLink = useEditLink()
const control = usePrevNext() const control = usePrevNext()
const hasEditLink = computed(() => {
return theme.value.editLink && frontmatter.value.editLink !== false
})
const hasLastUpdated = computed(() => { const hasLastUpdated = computed(() => {
return page.value.lastUpdated && frontmatter.value.lastUpdated !== false return page.value.lastUpdated && frontmatter.value.lastUpdated !== false
}) })
const showFooter = computed(() => {
return hasEditLink.value || hasLastUpdated.value || control.value.prev || control.value.next
})
</script> </script>
<template> <template>
<footer class="VPDocFooter"> <footer v-if="showFooter" class="VPDocFooter">
<div class="edit-info"> <div v-if="hasEditLink || hasLastUpdated" class="edit-info">
<div v-if="theme.editLink && frontmatter.editLink !== false" class="edit-link"> <div v-if="hasEditLink" class="edit-link">
<VPLink class="edit-link-button" :href="editLink.url" :no-icon="true"> <VPLink class="edit-link-button" :href="editLink.url" :no-icon="true">
<VPIconEdit class="edit-link-icon" /> <VPIconEdit class="edit-link-icon" />
{{ editLink.text }} {{ editLink.text }}

@ -27,14 +27,14 @@ export function getSidebar(
return [] return []
} }
export function getFlatSideBarLinks( export function getFlatSideBarLinks(sidebar: DefaultTheme.SidebarGroup[]) {
sidebar: DefaultTheme.SidebarGroup[] const links: { text: string; link: string }[] = []
): DefaultTheme.SidebarItem[] {
const links: DefaultTheme.SidebarItem[] = []
function recursivelyExtractLinks(items: DefaultTheme.SidebarItem[]) { function recursivelyExtractLinks(items: DefaultTheme.SidebarItem[]) {
for (const item of items) { for (const item of items) {
item.link && links.push(item) if (item.link) {
links.push({ ...item, link: item.link })
}
if ('items' in item) { if ('items' in item) {
recursivelyExtractLinks(item.items) recursivelyExtractLinks(item.items)
} }

Loading…
Cancel
Save