content icon indicating copy to clipboard operation
content copied to clipboard

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

Open xvaara opened this issue 1 year ago • 2 comments

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>

xvaara avatar Apr 22 '24 22:04 xvaara

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>

farnabaz avatar Apr 23 '24 19:04 farnabaz

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?

xvaara avatar Apr 24 '24 08:04 xvaara