nuxt / content

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

Endless loop when querying in a global component used in markdown when using NuxtLayout #2618

Open xvaara opened 2 months ago

xvaara commented 2 months ago

Environment

-

Reproduction

https://stackblitz.com/edit/github-j1www5?file=content%2Findex.md,content%2Fcontact.yml,components%2FComp.global.vue,app.vue

Describe the bug

Endless loop when querying in a global component used in markdown when using NuxtLayout

Additional context

No response

Logs

[Vue warn]: Avoid app logic that relies on enumerating keys on a component instance. The keys will be empty in production mode to avoid performance overhead. 
  at <Comp.global > 
  at <AsyncComponentWrapper > 
  at <MDCRenderer body= {type: 'root', children: Array(6), toc: {…}} data= {_path: '/', _dir: '', _draft: false, _partial: false, _locale: '', …} tag="div"  ... > 
  at <ContentRendererMarkdown value= {_path: '/', _dir: '', _draft: false, _partial: false, _locale: '', …} excerpt=false tag="div" > 
  at <ContentRenderer value= {_path: '/', _dir: '', _draft: false, _partial: false, _locale: '', …} excerpt=false tag="div" > 
  at <ContentQuery path="/" find="one" > 
  at <ContentDoc> 
  at <[...slug] onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< Proxy(Object) {…} > > 
  at <Anonymous key="/" vnode= {__v_isVNode: true, __v_skip: true, type: {…}, props: {…}, key: null, …} route= {fullPath: '/', hash: '', query: {…}, name: 'slug', path: '/', …}  ... > 
  at <RouterView name=undefined route=undefined > 
  at <NuxtPage> 
  at <NuxtLayoutProvider layoutProps= {ref: RefImpl} key="default" name="default"  ... > 
  at <NuxtLayout> 
  at <App key=3 > 
  at <NuxtRoot>
farnabaz commented 2 months ago

This is not related to Content module, try removing template inside the loop:

<ul>
      <li v-for="(item, key, index) in data.links" :key="key">
        <b> {{ key }} s{{ index }}s </b>

          <a :href="item">
            {{ item }}
          </a>
      </li>
    </ul>
xvaara commented 2 months ago

The template was left there from a more complex componenent. The component works when called from vue file, endless loop when called from a markdown file. So if it's not related to Content module is the bug in mdc?