How can I obtain the frontmatter of a document in other languages? #8197
-
Hello! I'm trying to implement a feature request I made recently: https://docusaurus.io/feature-requests/p/add-optional-version-number-in-docs-metadata-to-help-maintain-translated-docs I've played a bit with slizzing components and ended-up sizzling But now I'd like to obtain the frontmatter of that same doc in other languages. And I haven't found a solution so far. Is there an API for this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hey, I understand the problem. For sure it's hard for localized docs to stay in sync with the upstream language, particularly if done manually. You can try using:
Something to explore: using git patches to patch localized folders with changes from the "upstream folder". I've had some success with that approach recently while trying to automate the backport of docs from the upstream version This worked with this weird Git command: git format-patch -k --stdout v2.0.1...slorber/docusaurus-v2.1-backport -- website/docs | sed 's,a/website/docs,a/website/versioned_docs/version-2.1.0,g ; s,b/website/docs,b/website/versioned_docs/version-2.1.0,g' | git am -3 -k In human words: "take all recent docs changes diffs, and apply them to version 2.1.0 docs" Otherwise if you really want to do your manual docs versioning strategy, be aware that Docusaurus does not read other localized files when building a site in a given locale. If your default locale is English and you build the site in French, it won't read the English docs file. What I mean is that by default if you build in French you can only access French frontmatter. Reading extra markdown files could slow down build times and won't be used by most sites. However, we'd like to introduce a low-level This probably makes sense that we make your use-case convenient to implement by at least injecting the 2 file paths here (original doc path + localized doc path) so that you can easily read both files frontmatters and aggregate them. In the end you could have something like Does it make sense?
What do you mean, the embed iframe experience is bad? It's a std https://canny.io/ board that we didn't code ourselves. |
Beta Was this translation helpful? Give feedback.
Hey, I understand the problem.
For sure it's hard for localized docs to stay in sync with the upstream language, particularly if done manually.
You can try using:
Something to explore: using git patches to patch localized folders with changes from the "upstream folder". I've had some success with that approach recently while trying to automate the backpo…