-
-
Notifications
You must be signed in to change notification settings - Fork 483
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
feat(config): add site.url
as an alternative to baseUrl
#2481
base: main
Are you sure you want to change the base?
Conversation
β Live Preview ready!
|
@@ -90,6 +90,8 @@ | |||
"knitwork": "^1.0.0", | |||
"magic-string": "^0.30.4", | |||
"mlly": "^1.4.2", | |||
"nuxt-site-config": "^1.4.0", |
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.
@harlan-zw https://nuxtseo.com/site-config/getting-started/installation specifies that nuxt-site-config
has to be installed along with nuxt-site-config-kit
. As I only ever made use of a nuxt-site-config-kit
import in this PR and ignoring the playground's useSiteConfig
usage right now, I wonder: is it really required to install nuxt-site-config
as well? And if so, why?
useScope: 'local' | ||
}) | ||
console.log('locales', locales, baseUrl) | ||
const { url } = useSiteConfig() |
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.
TODO: this should require enabling the nuxt-site-config
module on the playground.
While I'm in favor of supporting/using the config module, if we want to add this for So hopefully there is a way to implement this while keeping compatibility and otherwise we will have to delay this until after |
This change should be backwards compatible already and only make use of |
src/module.ts
Outdated
@@ -72,6 +73,12 @@ export default defineNuxtModule<NuxtI18nOptions>({ | |||
) | |||
} | |||
|
|||
if (options.baseUrl && options.baseUrl !== '') { |
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.
I think a JSDoc deprecation should be enough without this. It's not really a problem if people want to keep their i18n config together
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.
How would I add the JSDoc as that's picked from vue-i18n-routing
?
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.
How would I add the JSDoc as that's picked from
vue-i18n-routing
?
Something like this is possible, I think the original JSDoc would need to be copied and extended, unless there is some way to append to existing JSDoc that I'm unaware of π .
+ /**
+ * Custom JSDoc here!
+ */
+ baseUrl?: I18nRoutingOptions<Context>['baseUrl']
} & Pick<
I18nRoutingOptions<Context>,
- | 'baseUrl'
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.
Added π
src/module.ts
Outdated
const siteConfig = useSiteConfig() | ||
|
||
if (siteConfig.url) { | ||
options.baseUrl = siteConfig.url |
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.
Is this needed? We want to use set the baseUrl in a runtime environment so that it can be easily switched
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.
Ah fair. Yeah, currently I only set it right here at build time, that should change.
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.
In ea4a900 I made that change. There could be a better place of course as @BobbieGoede pointed out, but I don't feel knowledgeable enough to decide on that.
Use `site.url` instead of `i18n.baseUrl`. | ||
|
||
::alert{type="info"} | ||
The `site` configuration option stems from [Nuxt SEO's `site-config` module](https://nuxtseo.com/site-config), which `nuxt-i18n` makes use of now. |
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.
I think there will need to be some documentation on all the ways that site config can be set and hosted on this page. The docs aren't that friendly at the moment, something on my to-do list.
docs/content/2.guide/16.migrating.md
Outdated
@@ -83,6 +83,38 @@ Deprecated for the same reason as the `localeLocation()` Option API. | |||
|
|||
Use `localeHead()` instead for the Options API style. | |||
|
|||
### Deprecated `baseUrl` component option |
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.
We don't actually need to deprecate it, both would be valid and we can just push people to use site config instead. If they really want to use baseUrl then they should be free to.
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.
I removed the deprecations.
@BobbieGoede would you mind sharing what your understanding of the From my understanding, it's just used for i18n head tags? A couple of minor notes until I can do a proper review:
|
Ah right, my bad. I mistook the deprecation notices as having the original baseURL handling removed for some reason π . It's good to support setting the value using
One thing to consider is layer support, especially when supporting multiple ways of setting options. In the current implementation a layer will override a project's
As I understand it, this is correct. Most of this happens in It is possible to override *On a separate note, I've been wanting to look into implementing/replacing the head tag handling in |
Sorry, I was preparing for vue fes japan, so I could not track of what was going on with this issue. π
|
It's on my TODO list, but as it should be a backwards compatible feature addition I had other tasks with higher priority. I think I can continue to work on it this week. |
I also need to re-review this properly when I have some time |
7931245
to
c8cb6d8
Compare
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.
I've removed the deprecations, added separate site.url
tests besides the baseUrl
tests and moved the site config to the runtime. That should form the groundwork I intended to lay. For further changes I'd need assistance from you people β€οΈ
Be invited to give examples on what needs to change or to submit PRs against this PR's base branch in my fork to get site config integrated into nuxt-i18n! πͺ π₯³
baseUrl
in favor of site.url
site.url
as an alternative to baseUrl
π Linked issue
#2474
β Type of change
π Description
This PR adds support for reading Nuxt config's
site.url
, provided by Nuxt SEO's site-config module, markingi18n.baseUrl
as deprecated.Draft because:
nuxt-site-config
does not (yet?) support options as functions, which has to be discussedπ Checklist