facebook / docusaurus

Easy to maintain open source documentation websites.
https://docusaurus.io
MIT License
56.99k stars 8.58k forks source link

"prependBaseUrlToHref" is defined as a string in Joi validation, and it's supposed to be a boolean in the doc #4363

Closed Pierre-Gilles closed 3 years ago

Pierre-Gilles commented 3 years ago

First, thank you very much for Docusaurus, it's a great tool that we use for another open-source project, Gladys Assistant 🙂

When I read the doc here: https://v2.docusaurus.io/fr/docs/next/api/themes/configuration, I see that the "prependBaseUrlToHref" option is a boolean:

Screenshot 2021-03-08 at 17 56 46

But in the code, the prependBaseUrlToHref option is a string:

https://github.com/facebook/docusaurus/blob/333545aa97d0a08eb35146673ec32078d5d2a19f/packages/docusaurus-theme-classic/src/validateThemeConfig.js#L54

This results in an error when I try to build my website:

Screenshot 2021-03-08 at 17 47 54

I suppose it's an error in the Joi validation :)

slorber commented 3 years ago

Thanks :)

Please add your site to our showcase: https://v2.docusaurus.io/showcase

Yes it looks like a validation error and should be a boolean. I find this option a bit confusing and would even like to remove it in the future, not sure it's worth to fix it as it would encourage usage ðŸĪŠ if only you report this bug it should not be very widely used 😅

Note the latest Docusaurus alpha has i18n support (we'll release it officially very soon) and has a "localeDropdown" navbar item for this exact usecase, and we have a pathname:///fr escape hatch to also solve this in a more generic way (we don't add baseurl in those cases, for all links with pathname://, including <Link> and md links.

slorber commented 3 years ago

Can you please try using pathname:///fr and let me know if it works for your usecase? (href or to should both work) If that's the case I'll look at removing this option and documenting this betterr

Pierre-Gilles commented 3 years ago

@slorber Good idea! Just added https://gladysassistant.com here => https://github.com/facebook/docusaurus/pull/4408

Note the latest Docusaurus alpha has i18n support (we'll release it officially very soon)

That's an amazing news! Right now, what we did is that we built two separate Docusaurus website (one in EN/one in FR) who shared React components ^^ I can't wait to migrate to the official i18n support :)

You mean like this ?

Screenshot 2021-03-12 at 15 04 18

It doesn't seem to work, the baseUrl is still added in the generated html:

Screenshot 2021-03-12 at 15 05 30
slorber commented 3 years ago

That's an amazing news! Right now, what we did is that we built two separate Docusaurus website (one in EN/one in FR) who shared React components ^^

I saw that. Somehow it's what the i18n support does, it's just you won't need to duplicate site configs.

It doesn't seem to work, the baseUrl is still added in the generated html:

Hmmm I believe it may work better with "to" instead of "href", for some legacy reasons there's a distinction in the way these 2 attributes are handled, but I'd like to remove that distinction

Pierre-Gilles commented 3 years ago

Hmmm I believe it may work better with "to" instead of "href", for some legacy reasons there's a distinction in the way these 2 attributes are handled, but I'd like to remove that distinction

Same problem with "to" instead of "href" !

Pierre-Gilles commented 3 years ago

FYI, I migrated to Docusaurus latest, it's really nice! Congrats on the work on i18n 👏

slorber commented 3 years ago

Thanks!

Can confirm there is something wrong with the pathname:// protocol here and the baseurl is appended by mistake