nuxt / content

The file-based CMS for your Nuxt application, powered by Markdown and Vue components.
https://content.nuxt.com
MIT License
3.13k stars 628 forks source link

ContentDoc with explicit path lags behind by one step in static site (after `generate`) #1986

Open Ni55aN opened 1 year ago

Ni55aN commented 1 year ago

Environment

Reproduction

  1. Open StackBlitz
  2. Run commands
    npm run generate
    npx serve .output/public
  3. Open preview and click on A link Expected result: three A heading Actual result: three A heading ✔
  4. Click on B link Expected result: three B heading Actual result: three B heading ✔
  5. Click on A link Expected result: three A heading Actual result: first heading is B ❌
  6. Click on B link Expected result: three B heading Actual result: first heading is A ❌

Describe the bug

ContentDoc fails to display new content based on an updated dynamic path (which depends on the route) after revisiting a link that was previously visited. Only after clicking on a different link it displays the new content, but for previous link. As a result, it lags behind by one step.

Additional context

No response

Logs

No response

Ni55aN commented 1 year ago

There is workaround using ContentRenderer

<template>
<ContentRenderer :value="data" />
</template>

<script>
import { defineComponent } from 'vue';

export default defineComponent({
  props: ['path'],
  async setup(props) {
    const { data } = await useAsyncData(props.path, () => queryContent(props.path).findOne());

    return {
      data,
    };
  },
});
</script>