Skip to content

Commit

Permalink
feat: populate document.empty and hide empty indexes from bottom na…
Browse files Browse the repository at this point in the history
…vigation (#511)
  • Loading branch information
farnabaz authored Jun 24, 2021
1 parent 37a772e commit d36235f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/core/parser/markdown/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ async function parse(file, options) {
toc,
body,
text: file,
excerpt
excerpt,
empty: content.trim().length === 0
}
}

Expand Down
9 changes: 5 additions & 4 deletions src/defaultTheme/components/templates/Docs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,11 @@ export default defineComponent({
.where({
language,
draft,
// Pages should share same parent
parent: props.page.parent,
// Ignore pages without any title
// Most of `index` pages are use for parenting configuration and they don't need to be listed here
title: { $not: { $type: 'undefined' } },
// Ignore empty index files
// Index files that hold no markdown content will not show in bottom navigation
$or: [{ slug: { $ne: '' } }, { empty: { $ne: true } }],
navigation: {
$and: [
// Ignore contents that has disabled navigations
Expand All @@ -83,7 +84,7 @@ export default defineComponent({
]
}
})
.only(['title', 'slug', 'to', 'category'])
.only(['title', 'slug', 'to'])
.sortBy('position', 'asc')
.surround(props.page.path, { before: 1, after: 1 })
.fetch()
Expand Down
4 changes: 4 additions & 0 deletions src/types/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ export interface DocusDocument {
* If set to `false` the document will not render as a standalone page an can only accessible with `InjectContent` of `$docus` search API
*/
page: boolean
/**
* It will set to `false` if the file does not containts any markdown content
*/
empty: boolean
/**
* The unique key of document (file path)
*/
Expand Down

1 comment on commit d36235f

@vercel
Copy link

@vercel vercel bot commented on d36235f Jun 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.