Skip to content

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.

  1. Follow the Starlight guide to use a root locale.

  2. 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@v0
    with:
    starlight_dir: ./docs
  3. If you have set the Astro base option as well, you need to provide the starlight_base input as well.

    .github/workflows/ct.yml
    uses: pelikhan/action-continuous-translation@v0
    with:
    starlight_dir: ./docs
    starlight_base: astro_base_option

Aside from the Markdown/MDX, we support some of the possible frontmatter metadata that Starlight supports:

We also support frontmatter entries from Starlight Blog:

  • excerpt: The excerpt of the blog post.

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.

astro.config.mjs
// other imports
import { 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.

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 and Hero components in your astro.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 the docs/src/components in this repository.

Feel free to modify the logic in AIGeneratedNotice.astro to fit your needs.

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.

astro.config.mjs
import starlightLinksValidator from "starlight-links-validator";
export default defineConfig({
integrations: [
starlight({
plugins: [
starlightLinksValidator({
errorOnRelativeLinks: false,
errorOnInconsistentLocale: true,
}),
],
}),
],
});

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.