harlan-zw/nuxt-schema-org

Be able to set host as a function

misaon opened this issue · 2 comments

Clear and concise description of the problem

In @nuxtjs/i18n we have the option to set baseUrl as a function in case we don't know which host the application will use. For example, connecting to an API, etc (https://v8.i18n.nuxtjs.org/options/routing#baseurl). For unhead-schema-org this option is not present and is quite limiting.

Suggested solution

Be able to set baseUrl as a function with the "NuxtContext" parameter

Alternative

No response

Additional context

No response

Validations

Hey @misaon, thanks for the issue!

Unfortunately, you can't pass functions defined in nuxt.config to the runtime. To get around this issue, there is a runtime hook for the meta data used to generate the schema.

There's a code sample here: https://unhead-schema-org.harlanzw.com/integrations/nuxt/module#nuxtapp-hooks

Let me know if that will solve your problem

Good idea, it works! Thanks