forked from withastro/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate Docs to Starlight (withastro#4266)
Co-authored-by: Genteure <[email protected]> Co-authored-by: HiDeoo <[email protected]> Co-authored-by: Sergio A. Arevalo Soria <[email protected]> Co-authored-by: Atharva Pise <[email protected]> Co-authored-by: Sarah Rainsberger <[email protected]> Co-authored-by: Luiz Ferraz <[email protected]> Co-authored-by: Mark Peck <[email protected]> Co-authored-by: Vitor Ayres <[email protected]> Co-authored-by: Lucid Jeon <[email protected]> Co-authored-by: Elian <[email protected]> Co-authored-by: Yan Thomas <[email protected]> Co-authored-by: Chris Swithinbank <[email protected]> Co-authored-by: Kevin Zuniga Cuellar <[email protected]> Co-authored-by: hippotastic <[email protected]> Co-authored-by: Voxel <[email protected]> @tracker-major:./src/content/docs/en/getting-started.mdx;
- Loading branch information
1 parent
ace1a42
commit cf9f93c
Showing
187 changed files
with
3,646 additions
and
8,195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,3 +35,4 @@ sandbox.config.json | |
|
||
# Cached requests | ||
.cache | ||
**/_fonts/brand/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import type starlight from '@astrojs/starlight'; | ||
import { normalizeLangTag } from '../src/i18n/bcp-normalize'; | ||
import languages, { rtlLanguages } from '../src/i18n/languages'; | ||
|
||
type StarlightLocalesConfig = NonNullable<Parameters<typeof starlight>[0]['locales']>; | ||
|
||
export function makeLocalesConfig(): StarlightLocalesConfig { | ||
return Object.fromEntries( | ||
Object.entries(languages).map(([locale, label]) => [ | ||
locale, | ||
{ label, lang: normalizeLangTag(locale), dir: rtlLanguages.has(locale) ? 'rtl' : 'ltr' }, | ||
]) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import type starlight from '@astrojs/starlight'; | ||
import { normalizeLangTag } from '../src/i18n/bcp-normalize'; | ||
import type { NavDict } from '../src/i18n/translation-checkers'; | ||
import { navTranslations } from '../src/i18n/util'; | ||
|
||
/** For an item in our sidebar, get translations of its label. */ | ||
function getTranslations(item: NavDict[number]): Record<string, string> | undefined { | ||
return Object.fromEntries( | ||
Object.entries(navTranslations) | ||
.map(([lang, translations]) => { | ||
const translation = translations.find((t) => t.key === item.key); | ||
return [ | ||
normalizeLangTag(lang), | ||
translation && translation.text !== item.text ? translation?.text : '', | ||
] as const; | ||
}) | ||
.filter(([, text]) => Boolean(text)) | ||
); | ||
} | ||
|
||
type StarlightSidebarConfig = NonNullable<Parameters<typeof starlight>[0]['sidebar']>; | ||
|
||
/** Generate a Starlight sidebar config object from our existing `nav.ts` files. */ | ||
export function makeSidebar(): StarlightSidebarConfig { | ||
return navTranslations.en.reduce((sidebar, item) => { | ||
if ('header' in item) { | ||
sidebar.push({ | ||
label: item.text, | ||
translations: getTranslations(item), | ||
items: [], | ||
}); | ||
} else { | ||
const group = sidebar.at(-1); | ||
if (group && 'items' in group) { | ||
group.items.push({ | ||
label: item.text, | ||
link: item.slug, | ||
translations: getTranslations(item), | ||
}); | ||
} | ||
} | ||
return sidebar; | ||
}, [] as StarlightSidebarConfig); | ||
} |
Oops, something went wrong.