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

fix(<ContentDoc>): render blink in SSG #1600

Merged
merged 1 commit into from
Oct 14, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -570,14 +570,14 @@ export default defineNuxtModule<ModuleOptions>({
// Disable cache in dev mode
integrity: nuxt.options.dev ? undefined : Date.now()
},
navigation: contentContext.navigation,
navigation: contentContext.navigation as any,
base: options.base,
// Tags will use in markdown renderer for component replacement
tags: contentContext.markdown.tags as any,
highlight: options.highlight as any,
wsUrl: '',
// Document-driven configuration
documentDriven: options.documentDriven as ModuleOptions['documentDriven'],
documentDriven: options.documentDriven as any,
// Anchor link generation config
anchorLinks: options.markdown.anchorLinks
})
Expand Down
9 changes: 7 additions & 2 deletions src/runtime/components/ContentDoc.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script lang="ts">
import { PropType, defineComponent, h, useSlots } from 'vue'
import { withTrailingSlash } from 'ufo'
import type { QueryBuilderParams } from '../types'
import ContentRenderer from './ContentRenderer'
import ContentQuery from './ContentQuery'
Expand Down Expand Up @@ -42,7 +43,7 @@ export default defineComponent({
path: {
type: String,
required: false,
default: () => useRoute().path
default: undefined
},

/**
Expand Down Expand Up @@ -78,7 +79,11 @@ export default defineComponent({
const { tag, excerpt, path, query, head } = ctx

// Merge local `path` props and apply `findOne` query default.
const contentQueryProps = Object.assign(query || {}, { path, find: 'one' })
const contentQueryProps = {
...query || {},
path: path || query?.path || withTrailingSlash(useRoute().path),
find: 'one'
}

const emptyNode = (slot: string, data: any) => h('pre', null, JSON.stringify({ message: 'You should use slots with <ContentDoc>', slot, data }, null, 2))

Expand Down