schema-org icon indicating copy to clipboard operation
schema-org copied to clipboard

dynamic canonicalHost

Open shtse8 opened this issue 1 year ago • 4 comments

I have multi site with different host running the same app. How can I make it dynamically setting in the app, since the config is built time setting.?

shtse8 avatar Jul 21 '22 08:07 shtse8

Can we set the host in runtime? as all my site info is stored in database.

shtse8 avatar Jul 24 '22 07:07 shtse8

ok, I found it. I can change the canonicalhost in runtime now.

injectSchemaOrg().options.canonicalHost = 'https://google.com/'

shtse8 avatar Jul 24 '22 14:07 shtse8

Hey @shtse8

Glad you could resolve this one by yourself! I think this may be the best option for the time being, if you think a better implementation is required feel free to open another issue :)

harlan-zw avatar Jul 30 '22 01:07 harlan-zw

@harlan-zw I hate setting hostname in config as it may be changed in runtime. For example, different hostname for dev env and prod env. Moving site from one domain to another. Changing subdomain or multiple tld .cn, .com for serving to China and international correspondingly. If hostname is set in config, build is needed for change. And we can't store it as info data in database. So I would suggest that providing a setter method for setting it in runtime and don't warn user if there is no hostname provided in config. 🙏

setCanonicalHost(host: MayBeRef<string>)

shtse8 avatar Jul 30 '22 05:07 shtse8

Hey @shtse8

Just wanted to update you on the new v1 behaviour.

Not sure which integration you're using, but if you're using Nuxt then you can make use of the NuxtApp hooks to override any meta.

You can see an example here: https://vue-schema-org.netlify.app/guide/getting-started/nuxt#nuxtapp-hooks

WIll close this off, but feel free to re-open if there's any issues with it

harlan-zw avatar Aug 24 '22 04:08 harlan-zw