Skip to content

Commit

Permalink
fix(theme): hide doc footer if empty (#1126)
Browse files Browse the repository at this point in the history
  • Loading branch information
brc-dd committed Aug 5, 2022
1 parent 8e190aa commit 70da5f2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
12 changes: 9 additions & 3 deletions src/client/theme-default/components/VPDocFooter.vue
Expand Up @@ -13,15 +13,21 @@ const { theme, page, frontmatter } = useData()
const editLink = useEditLink()
const control = usePrevNext()
const hasEditLink = computed(() => {
return theme.value.editLink && frontmatter.value.editLink !== false
})
const hasLastUpdated = computed(() => {
return page.value.lastUpdated && frontmatter.value.lastUpdated !== false
})
const showFooter = computed(() => {
return hasEditLink.value || hasLastUpdated.value || control.value.prev || control.value.next
})
</script>

<template>
<footer class="VPDocFooter">
<div class="edit-info">
<div v-if="theme.editLink && frontmatter.editLink !== false" class="edit-link">
<footer v-if="showFooter" class="VPDocFooter">
<div v-if="hasEditLink || hasLastUpdated" class="edit-info">
<div v-if="hasEditLink" class="edit-link">
<VPLink class="edit-link-button" :href="editLink.url" :no-icon="true">
<VPIconEdit class="edit-link-icon" />
{{ editLink.text }}
Expand Down
10 changes: 5 additions & 5 deletions src/client/theme-default/support/sidebar.ts
Expand Up @@ -27,14 +27,14 @@ export function getSidebar(
return []
}

export function getFlatSideBarLinks(
sidebar: DefaultTheme.SidebarGroup[]
): DefaultTheme.SidebarItem[] {
const links: DefaultTheme.SidebarItem[] = []
export function getFlatSideBarLinks(sidebar: DefaultTheme.SidebarGroup[]) {
const links: { text: string; link: string }[] = []

function recursivelyExtractLinks(items: DefaultTheme.SidebarItem[]) {
for (const item of items) {
item.link && links.push(item)
if (item.link) {
links.push({ ...item, link: item.link })
}
if ('items' in item) {
recursivelyExtractLinks(item.items)
}
Expand Down

0 comments on commit 70da5f2

Please sign in to comment.