diff --git a/cypress/e2e/test.cy.js b/cypress/e2e/test.cy.js
index 8c172c02..5c04e7da 100644
--- a/cypress/e2e/test.cy.js
+++ b/cypress/e2e/test.cy.js
@@ -91,4 +91,16 @@ describe('nuxt-jsonld', () => {
expect(json).to.have.property('count', 2);
});
});
+
+ it('places jsonld with tagPosition', () => {
+ cy.visit('/composable-options');
+ cy.get('body script[type="application/ld+json"]')
+ .should('exist')
+ .then((el) => {
+ const json = JSON.parse(el.text());
+ expect(json).to.have.property('@context', 'https://schema.org');
+ expect(json).to.have.property('@type', 'WebSite');
+ expect(json).to.have.property('name', 'nuxt-jsonld composable options');
+ });
+ });
});
diff --git a/packages/example/pages/composable-options.vue b/packages/example/pages/composable-options.vue
new file mode 100644
index 00000000..6b18f187
--- /dev/null
+++ b/packages/example/pages/composable-options.vue
@@ -0,0 +1,24 @@
+
+
+
Composable Options
+
+
+
+
diff --git a/packages/example/pages/index.vue b/packages/example/pages/index.vue
index 2b715273..f7649465 100644
--- a/packages/example/pages/index.vue
+++ b/packages/example/pages/index.vue
@@ -10,6 +10,7 @@
Static JSON
Options API
+ Composable API Options
diff --git a/packages/nuxt-jsonld/src/module.ts b/packages/nuxt-jsonld/src/module.ts
index 2cbd6832..2cb741c6 100644
--- a/packages/nuxt-jsonld/src/module.ts
+++ b/packages/nuxt-jsonld/src/module.ts
@@ -3,6 +3,8 @@ import { defineNuxtModule, addPlugin, addImports } from '@nuxt/kit';
import type { Nuxt } from '@nuxt/schema';
import type { JsonLDFunc } from './types';
+export type { UseJsonldOptions } from './runtime/composable';
+
type ModuleOptions = {
disableOptionsAPI: boolean;
};
diff --git a/packages/nuxt-jsonld/src/runtime/composable.ts b/packages/nuxt-jsonld/src/runtime/composable.ts
index 237a156b..1c98ac59 100644
--- a/packages/nuxt-jsonld/src/runtime/composable.ts
+++ b/packages/nuxt-jsonld/src/runtime/composable.ts
@@ -1,10 +1,11 @@
import { computed } from 'vue';
import type { JsonLD, JsonLDFunc } from '../types';
-import { useHead } from '@unhead/vue';
+import { useHead, type UseHeadOptions } from '@unhead/vue';
const isFunc = (json: JsonLD | JsonLDFunc): json is JsonLDFunc => typeof json === 'function';
+export type UseJsonldOptions = Pick;
-export const useJsonld = (json: JsonLD | JsonLDFunc) => {
+export const useJsonld = (json: JsonLD | JsonLDFunc, options?: UseJsonldOptions) => {
if (!json) {
return;
}
@@ -22,5 +23,5 @@ export const useJsonld = (json: JsonLD | JsonLDFunc) => {
},
],
};
- });
+ }, options);
};