Closed novusnota closed 12 hours ago
By default, there's no highlighting of inline code blocks and no existing plugins for it yet. Local implementation went rather smooth, wasn't a big deal
What does it mean "Local implementation went rather smooth"?
What does it mean "Local implementation went rather smooth"?
I just wrote a small rehype plugin (a single file with <100 lines with comments) and included it into the astro.config.mjs
. Tested, debugged, and then achieved the same (theme and all) inline code highlighting, as it's seen in Nextra framework in the current Tact docs.
P.S.: Inline code highlighting means this
gets highlighted, not:
this
Which is a code block highlighting :)
Goals
Easy i18n (translations of the docs from English to other languages) without convoluted build systems
Easy versioning of the docs: the separation into the latest (for users) and the upstream/dev versions via folders. Upon any releases, we'll have to sync the dev versions with the latest one.
Continue using LaTeX, React Components, full website search, as well as TextMate grammars for code block highlighting. Keeping highlighting for inline code segments would be nice too.
Continue using SSG (static site generation) and free deploy to Github Pages
Improve the SEO — as of now, individual pages don't stand out from each other when linked in chats or discovered in search engines
Other options considered
Docusaurus:
VuePress:
Solution
Starlight — an Astro-powered documentation framework, that allows for great extensibility and bundles (among other things): advanced i18n support via i18next, site navigation, search, SEO, easy-to-read typography, code highlighting, dark mode and more. Also, it's very lightweight.
Extra pros discovered:
Ctrl-K
), the user can simply search by the contents (Ctrl-F
) and discover titles of pages throughout the documentation sections. That is because Book, Cookbook, Reference and Ecosystem are now gathered together in the sidebar on the left now instead of the buttons on top.Cons discovered:
rehype
andremark
plugins. Local integration went quite smooth, so that wasn't a big deal tooCtrl-f
as mentioned above.About i18n and translations
All the UI elements have built-in translations to a lots of languages, including Chinese and Simplified Chinese, so we don't have to translate those, only the content of the pages.
Regarding that, one path we might take with Starlight and Crowdin (for translations) may look as follows:
src/content/i18n/
folder in Starlight docsAstro.locals.t()
and pass the keys from the files from step 2.The big issue with that approach arises from the volatile nature of Tact docs — texts get changed often and even whole paragraphs can appear and disappear at times. Containing that complexity within the keys in .json files puts WAY too much maintainance burden on the translators. Besides, those are just inconvenient to write since the whole picture of the text would be hidden away, allowing only single phrases or paragraphs to be translated at the time, lacking the larger context of the whole page.
My proposal is simple — just use the .mdx files for the translations. Crowdin already supports the .mdx format out of the box (including YAML or TOML frontmatters, see: https://store.crowdin.com/mdx), so we can:
src/content/docs/zh-cn
(for Simplified Chinese) and that's itNow, regarding sidebar and the translations of titles — nothing extra has to be done there! If we use internal links (i.e. just names of the files, which must stay the same in all localizations), we get the localized titles out of content frontmatters of translated pages for free. See: https://starlight.astro.build/guides/sidebar/#internationalization-with-internal-links.
P.S.: I believe that all technical writers and translators must know Markdown and bits of HTML and YAML to be able to figure MDX out in less than an hour, really. And giving more context (i.e. full file instead of the disjoint set of strings/lines) to translators is ALWAYS a plus.
Steps
<Callout>
where appropriate)tact-docs
repo, while keeping the list of issues stored there for a little while