question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Full static mode $content options not applying to the fetch query

See original GitHub issue

Hi 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

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:closed
  • Created 3 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
cogorcommented, Aug 4, 2020

Hi, in my blog I used reading-time And just added time to hook in nuxt.config.js

  hooks: {
    'content:file:beforeInsert': (document) => {
      if (document.extension === '.md') {
        const { minutes } = require('reading-time')(document.text)

        document.readingTime = minutes
      }
    },
  },
0reactions
benjamincanaccommented, Aug 5, 2020

Nice catch! Will be fixed in next release ☺️

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nuxt static not loading fetched state when pushing new route
I have a small blog to load as static site also, so I'm using the fetch hook to load the data from api....
Read more >
Going Full Static - Nuxt
Current issues. nuxt generate is mostly pre-rendering, when you navigate client-side, asyncData and fetch are called, making a request to your ...
Read more >
Using the Fetch API - MDN Web Docs
The Fetch API provides a JavaScript interface for accessing and manipulating parts of the protocol, such as requests and responses.
Read more >
How to take full advantage of full-static mode in Nuxt.js 2.13
Known issues with Nuxt.js · Running nuxt generate rebuilds your entire app even if it's not necessary, which slows down deployment times. ·...
Read more >
Power up your (Jam)stack with the new Nuxt - Maya Shavin
Been waiting for Nuxt 3.0 to build Jamstack (static) apps? No ... instance to our application so we can use it to fetch...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found