Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: populate document.empty and hide empty indexes from bottom na… #511

Merged
merged 1 commit into from
Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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