Full static mode $content options not applying to the fetch query
See original GitHub issueHi all!
I am trying to compute my own timeToRead property, but for this I need access to the text
variable (which returns the original markdown content in a text variable) which can be specified in an options object to $content. My problem is that providing this object in full static mode (introduced in nuxt v2.13.0), it seems that this variable is not requested in production. Therefore I assume that the options object is not being applied in this generation mode.
Although it would be nice to have a timeToRead property similar to what Gridsome has, this problem can also be solved if the options object was correctly applied to the $content query.
Version
@nuxt/content: v1.5.3 nuxt: v2.14.0
Reproduction Link
Universal SSR sandbox: https://codesandbox.io/s/lucid-taussig-wenze?file=/nuxt.config.js Full static sandbox: https://codesandbox.io/s/compassionate-leaf-qkjj0?file=/nuxt.config.js
Steps to reproduce
- Fork the provided @nuxt/content sandbox: https://codesandbox.io/s/nuxtcontent-demo-l164h
- Open
package.json
and edit the dev script to be"MINIMAL=1 CSB=1 nuxt generate && nuxt start"
.- This runs nuxt in a production environment full static mode and follows the steps outlined in this nuxt blog post.
- Open
pages/_slug.vue
and change line 13 toconst page = await $content(slug, { text: true })
- Still on
pages/_slug.vue
, declare a paragraph element that shows whether or not page.text is accessible. I did this on a new line underneath line 4.<p>{{ page.text ? 'page.text exists' : 'page.text missing' }}</p>
What is Expected?
For the page object to have the original markdown content in a text variable and for the paragraph element to show page.text exists
to reflect it being passed in as an option.
What is actually happening?
The page object does not have a text
variable and the paragraph shows page.text missing
when the nuxt project is run in full static mode with the production environment.
Interesting to note that this bug does not exist when you are in the full static mode but with the development environment nor when the nuxt app is server-side rendered.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (5 by maintainers)
Top GitHub Comments
Hi, in my blog I used reading-time And just added time to hook in nuxt.config.js
Nice catch! Will be fixed in next release ☺️