-
Notifications
You must be signed in to change notification settings - Fork 41
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
Documentation for using the 'scripts:registry' hook wrong #267
Labels
documentation
Improvements or additions to documentation
Comments
bernhardberger
added
the
documentation
Improvements or additions to documentation
label
Sep 16, 2024
Proper way to implement it currently seems to be: import { addImports, createResolver, defineNuxtModule, installModule } from 'nuxt/kit'
export default defineNuxtModule({
meta: {
configKey: 'oneTrust',
name: '@my-namespace/nuxt-onetrust',
compatibility: {
bridge: false,
nuxt: '>=3',
},
},
async setup(_options, nuxt) {
const { resolve } = createResolver(import.meta.url)
const runtimeDir = resolve('./runtime')
await installModule('@nuxt/scripts')
const onetrustRegistry = {
import: {
from: resolve(runtimeDir, 'registry/onetrust'),
name: 'useScriptOneTrust',
},
}
addImports(onetrustRegistry.import)
nuxt.hook('scripts:registry', (registry) => {
registry.push ({
// used in DevTools
label: 'OneTrust SDK',
logo: ``,
// if the script can be bundled we need to define a resolver
src: 'https://xxx.my.onetrust.eu/cdn/cookies/scripttemplates/otSDKStub.js',
category: 'consent-management',
import: onetrustRegistry.import,
})
})
},
}) |
bernhardberger
added a commit
to bernhardberger/scripts
that referenced
this issue
Sep 17, 2024
update example on how to use script:registry hook - fixes nuxt#267
6 tasks
bernhardberger
added a commit
to bernhardberger/scripts
that referenced
this issue
Sep 17, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
📚 Is your documentation request related to a problem?
I tried implementing a module to add OneTrust SDK integration to the registry, however:
https://scripts.nuxt.com/docs/api/nuxt-hooks
This flat out doesn't work.
🔍 Where should you find it?
https://scripts.nuxt.com/docs/api/nuxt-hooks
The text was updated successfully, but these errors were encountered: