Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
just like we did with the language part otherwise we get `-version-....` ids with no prefixes
- Loading branch information
just like we did with the language part otherwise we get `-version-....` ids with no prefixes
ff11797
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 thought id is already taking langPart. Let me do some tests
ff11797
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.
Without this, you get:
after enabling versioning as described here: https://docusaurus.io/docs/en/versioning.html
ff11797
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.
Although, what you say makes sense :/
ff11797
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.
You are right. I got that error now
ff11797
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.
On the surface this looks like we can't have
langPart
andversionPart
being set at the same time in most scenarios.ff11797
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.
Yes. I've just tested. The Metadata we got are two sets: ['doc1', 'doc2', ...] and ['en-version-1.0.0-doc1', 'en-version-1.0.0-doc2', ...]
So when translation disabled, langPart has to respect empty string, but versionPart has to have 'en' prefix.
A proper fix maybe in
readMetadata
to solve the versioned ids, so it would be ['version-1.0.0-doc1', 'version-1.0.0-doc2', ...].This could be addressed in another PR, to have thorough review and test again
ff11797
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.
To be more clear. when translation disabled but versioning enabled. we are generating 'version 1.0.0' pages and 'version next' pages. For 'version next' it picks up metadata 'doc1' etc., for 'version 1.0.0' it picks up metadata 'en-version-1.0.0-doc1' etc.
Hope this explains better :p
ff11797
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 was just thinking, I think it is the first
-
that was causing the problem. Can't we just say something like:If we don't have a
langPart
, we don't need the-
inversionPart
Just a thought.
ff11797
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.
Yes that is one of the issue. Another issue is there is no 'version-1.0.0-doc1' alike in Metadata, instead have entries like 'en-version-1.0.0-doc1'. What we have right now works, but may not be absolutely correct depend on how we think about it. Translation is not enabled, but we have 'en-' as part of metadata id.
I think if we want to change this, it has to be two parts. fix Metadata, and then fix how we generate id.
ff11797
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.
Hi @richardzcode. Right. But wouldn't my fix above solve the case where translation is not enabled? You could even fix it like this using
env.translation.enabled
as the check withversionPart
.ff11797
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.
if
then
Totally agree, this is desired. Just as of now. in Metadata, 'version-1.0.0-doc1' does not exist, so
Metadata[id] === false
, so it would throw error.Right now Metadata['en-version-1.0.0-doc1'] exists. So your earlier fix worked. I prefer your current fix but we have to fix Metadata too.
ff11797
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.
This is the Metadata I have in my test:
ff11797
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.
👍 Got it. When creating a version, it is prefixing the id with
en
by default. We don't want that.I am working on a fix now.
ff11797
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 have a PR coming up.