-
-
Notifications
You must be signed in to change notification settings - Fork 373
feat(deps): use nuxt-og-image v6 #1118
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -107,9 +107,9 @@ useSeoMeta({ | |
| twitterDescription: () => pkg.value?.license ?? '', | ||
| }) | ||
|
|
||
| defineOgImageComponent('Default', { | ||
| title: () => `${pkg.value?.name ?? 'Package'} - Docs`, | ||
| description: () => pkg.value?.license ?? '', | ||
| defineOgImage('Default', { | ||
| title: `${pkg.value?.name ?? 'Package'} - Docs`, | ||
| description: pkg.value?.license ?? '', | ||
| primaryColor: '#60a5fa', | ||
| }) | ||
|
Comment on lines
+110
to
114
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same async-data concern as
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -170,9 +170,9 @@ useSeoMeta({ | |
| twitterDescription: () => `npm packages maintained by ${username.value}`, | ||
| }) | ||
|
|
||
| defineOgImageComponent('Default', { | ||
| title: () => `~${username.value}`, | ||
| description: () => (results.value ? `${results.value.total} packages` : 'npm user profile'), | ||
| defineOgImage('Default', { | ||
| title: `~${username.value}`, | ||
| description: results.value ? `${results.value.total} packages` : 'npm user profile', | ||
| primaryColor: '#60a5fa', | ||
| }) | ||
|
Comment on lines
+173
to
177
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor:
|
||
| </script> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
nuxt-og-image v6 defineOgImage reactivity💡 Result:
In nuxt-og-image v6,
defineOgImage()should be treated as non-reactive by default: it sets the OG meta once at the time you call it (duringsetup/ SSR). So if you pass values that change later on the client, crawlers won’t see those updates anyway (they only read the initial HTML), and your tags won’t update unless you calldefineOgImage()again. [1]Recommended pattern (SSR-safe)
Fetch/compute the data before calling
defineOgImage()(e.g.await useAsyncData(...), then call it with the resolved values). This is also how the docs show it for Content-driven pages. [2]If you truly need “reactivity” (client-side navigation)
Re-run it when inputs change:
When the options/props change, nuxt-og-image generates a different OG image URL (and caches by those inputs), so re-calling it with new values is the intended way to “update” the OG image definition. [3]
Sources: defineOgImage API docs [1], Nuxt Content integration example [2], caching/invalidation behavior [3].
[1] https://nuxtseo.com/docs/og-image/api/define-og-image
[2] https://nuxtseo.com/docs/og-image/integrations/content
[3] https://nuxtseo.com/docs/og-image/guides/cache
🏁 Script executed:
cat -n app/pages/org/[org].vue | head -60Repository: npmx-dev/npmx.dev
Length of output: 2030
🏁 Script executed:
sed -n '140,160p' app/pages/org/[org].vueRepository: npmx-dev/npmx.dev
Length of output: 853
🏁 Script executed:
grep -n "useOrgPackages" app/pages/org/[org].vueRepository: npmx-dev/npmx.dev
Length of output: 128
🏁 Script executed:
Repository: npmx-dev/npmx.dev
Length of output: 100
🏁 Script executed:
Repository: npmx-dev/npmx.dev
Length of output: 6789
🏁 Script executed:
Repository: npmx-dev/npmx.dev
Length of output: 259
🏁 Script executed:
sed -n '47,53p' app/composables/npm/useNpmSearch.tsRepository: npmx-dev/npmx.dev
Length of output: 207
🏁 Script executed:
grep -n "defineOgImage\|watchEffect" app/pages/org/[org].vueRepository: npmx-dev/npmx.dev
Length of output: 91
The OG image description will always show
'npm organisation'instead of the actual package count.useOrgPackagesusesuseLazyAsyncData, which does not block page setup and defaults to returning an emptyemptySearchResponse(withobjects: []). WhendefineOgImageis called during setup,packageCount.valuewill be0, causing the ternary to always resolve to the fallback text.According to the
nuxt-og-imagev6 documentation,defineOgImage()is non-reactive and should be called only after data is available. To fix this, either await the data before callingdefineOgImage, or usewatchEffectto re-call it once the lazy data resolves: