Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle MaybeComputedRef for UseJsonld input field #1071

Open
2 tasks
ymmooot opened this issue Jan 25, 2023 · 2 comments
Open
2 tasks

Handle MaybeComputedRef for UseJsonld input field #1071

ymmooot opened this issue Jan 25, 2023 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@ymmooot
Copy link
Owner

ymmooot commented Jan 25, 2023

Currently, useHead can handle MaybeComputedRef like below:

// static
useHead({
  title: "title",
});
// function
useHead(() => ({
  title: someRef,
}))
// ref, computed, and reactive
useHead({  
  title: someRef,  
})

useJsonld can only handle a static object and a function.

// static
useJsonld({
  name: "title",
});
// function
useJsonld(() => ({
  name: someRef.value, // .value needed
}))
  • Handle MaybeComputedRef like useHead
  • Fix broken link to useHead in README

working on nuxt-jsonld/tree/reactive

@ymmooot ymmooot added the enhancement New feature or request label Jan 25, 2023
@ymmooot ymmooot self-assigned this Jan 25, 2023
@TimGuendel
Copy link

Any update? I am trying to use a computedRef inside of useJsonld and I am getting this error:

"Converting circular structure to JSON\n --> starting at object with constructor 'ComputedRefImpl'\n | property 'effect' -> object with constructor 'ReactiveEffect'\n --- property 'computed' closes the circle",

@ymmooot
Copy link
Owner Author

ymmooot commented Nov 28, 2023

Hi @TimGuendel.
Currently you can not pass a computed value directly:

// This does not work
const nameComputed = computed(() => 'Alice');
ustJsonld({
    name: nameComputed,
});

However, you can do this:

// This works fine
const nameComputed = computed(() => 'Alice');
ustJsonld(() => ({
    name: nameComputed.value,
}));

Converting circular structure to JSON

Please make sure there are no circular references in your object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants