Astro Starlight
This action can be used to translation the content of a Astro Starlight documentation site. It requires a specific setup of Starlight as detailed below.
-
Follow the Starlight guide to use a root locale.
-
To enable the Starlight mode, you need to provide the
starlight_dir
input in the action..github/workflows/ct.yml uses: pelikhan/action-continuous-translation@v0with:starlight_dir: ./docs -
If you have set the Astro
base
option as well, you need to provide thestarlight_base
input as well..github/workflows/ct.yml uses: pelikhan/action-continuous-translation@v0with:starlight_dir: ./docsstarlight_base: astro_base_option
Supported Frontmatter entries
Section titled “Supported Frontmatter entries”Aside from the Markdown/MDX, we support some of the possible frontmatter metadata that Starlight supports:
title
: The title of the page.description
: The description of the page.head.content
: The content of<head>
tags for specific pages.hero.tagline
: The tagline of the hero section.hero.actions.text
: The text of the action button in the hero section.banner.content
: The content of a page specific banner.prev
/prev.label
: The link text of the previous page.next
/next.label
: The link text of the next page.sidebar.label
: Custom text in the sidebar (by defaulttitle
).sidebar.badge
/sidebar.badge.text
: Badge text for the sidebar.
We also support frontmatter entries from Starlight Blog:
excerpt
: The excerpt of the blog post.
Title and Sidebar
Section titled “Title and Sidebar”The title
and sidebar
entries in the frontmatter are not automatically translated by the action.
We recommend moving those entries to a JSON file and importing it into your astro.config.mjs
file.
// other importsimport { title } from "./resources.json" assert { type: "json" };
export default defineConfig({ integrations: [ starlight({ title, }), ],});
Follow the specific title docs and sidebar docs from Starlight for further details.
AI Content Notice
Section titled “AI Content Notice”You can inform your users that the translation was generated by GenAI by adding a notice in the title. At this time, the Astro Starlight does not support a builtin feature to add notices so it requires to override a few components.
-
Override the
PageTitle
andHero
components in yourastro.config.mjs
file:astro.config.mjs export default defineConfig({integrations: [starlight({components: {PageTitle: "./src/components/PageTitle.astro",Hero: "./src/components/Hero.astro",},}),],}); -
Add the components in your
src/components
directory from thedocs/src/components
in this repository.
Feel free to modify the logic in AIGeneratedNotice.astro
to fit your needs.
Astro Link Validator
Section titled “Astro Link Validator”If you use the Astro Link Validator,
make sure to disable errorOnRelativeLinks
option in your astro.config.mjs
file
as the localized links are relative to the root locale.
You can also enable the errorOnInconsistentLocale
option to ensure that all links are consistent with the current locale.
import starlightLinksValidator from "starlight-links-validator";
export default defineConfig({ integrations: [ starlight({ plugins: [ starlightLinksValidator({ errorOnRelativeLinks: false, errorOnInconsistentLocale: true, }), ], }), ],});
Lunaria Translation Dashboard
Section titled “Lunaria Translation Dashboard”You can use the Lunaria Translation Dashboard to generate a translation status dashboard for your Starlight site.
You can try the dashboard by navigating to the Translation Dashboard link in the sidebar of this page.