-
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.
feat: update Dockerfile and configuration for server host, add patche…
…s for starlight integration
- Loading branch information
1 parent
cda23f1
commit bebce26
Showing
6 changed files
with
164 additions
and
14 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
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
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,134 @@ | ||
diff --git a/utils/i18n.ts b/utils/i18n.ts | ||
index a7d5be976e1fb6cadf8ec426e40d15f418e6536e..b0cc77c0cae560426d7969014dcead6156f0c85f 100644 | ||
--- a/utils/i18n.ts | ||
+++ b/utils/i18n.ts | ||
@@ -2,26 +2,6 @@ import type { AstroConfig } from 'astro'; | ||
import { AstroError } from 'astro/errors'; | ||
import type { StarlightConfig } from './user-config'; | ||
|
||
-/** | ||
- * A proxy object that throws an error when a user tries to access the deprecated `labels` prop in | ||
- * a component override. | ||
- * | ||
- * @todo Remove in a future release once people have updated — no later than v1. | ||
- */ | ||
-export const DeprecatedLabelsPropProxy = new Proxy<Record<string, never>>( | ||
- {}, | ||
- { | ||
- get(_, key) { | ||
- const label = String(key); | ||
- throw new AstroError( | ||
- `The \`labels\` prop in component overrides has been removed.`, | ||
- `Replace \`Astro.props.labels["${label}"]\` with \`Astro.locals.t("${label}")\` instead.\n` + | ||
- 'For more information see https://starlight.astro.build/guides/i18n/#using-ui-translations' | ||
- ); | ||
- }, | ||
- } | ||
-); | ||
- | ||
/** | ||
* A list of well-known right-to-left languages used as a fallback when determining the text | ||
* direction of a locale is not supported by the `Intl.Locale` API in the current environment. | ||
@@ -77,11 +57,11 @@ function getAstroI18nConfig(config: StarlightConfig): NonNullable<AstroConfig['i | ||
config.defaultLocale.lang ?? config.defaultLocale.locale ?? BuiltInDefaultLocale.lang, | ||
locales: config.locales | ||
? Object.entries(config.locales).map(([locale, localeConfig]) => { | ||
- return { | ||
- codes: [localeConfig?.lang ?? locale], | ||
- path: locale === 'root' ? (localeConfig?.lang ?? BuiltInDefaultLocale.lang) : locale, | ||
- }; | ||
- }) | ||
+ return { | ||
+ codes: [localeConfig?.lang ?? locale], | ||
+ path: locale === 'root' ? (localeConfig?.lang ?? BuiltInDefaultLocale.lang) : locale, | ||
+ }; | ||
+ }) | ||
: [config.defaultLocale.lang], | ||
routing: { | ||
prefixDefaultLocale: | ||
@@ -114,15 +94,15 @@ function getStarlightI18nConfig( | ||
const locales = isMonolingualWithRootLocale | ||
? undefined | ||
: Object.fromEntries( | ||
- astroI18nConfig.locales.map((locale) => [ | ||
- isDefaultAstroLocale(astroI18nConfig, locale) && !prefixDefaultLocale | ||
- ? 'root' | ||
- : isAstroLocaleExtendedConfig(locale) | ||
- ? locale.path | ||
- : locale, | ||
- inferStarlightLocaleFromAstroLocale(locale), | ||
- ]) | ||
- ); | ||
+ astroI18nConfig.locales.map((locale) => [ | ||
+ isDefaultAstroLocale(astroI18nConfig, locale) && !prefixDefaultLocale | ||
+ ? 'root' | ||
+ : isAstroLocaleExtendedConfig(locale) | ||
+ ? locale.path | ||
+ : locale, | ||
+ inferStarlightLocaleFromAstroLocale(locale), | ||
+ ]) | ||
+ ); | ||
|
||
const defaultAstroLocale = astroI18nConfig.locales.find((locale) => | ||
isDefaultAstroLocale(astroI18nConfig, locale) | ||
diff --git a/utils/route-data.ts b/utils/route-data.ts | ||
index 1f6880200caa87e5bd6e901e5120a67824257e7d..a6a3fb72d143adb3766459e00eaf3481dfadfec6 100644 | ||
--- a/utils/route-data.ts | ||
+++ b/utils/route-data.ts | ||
@@ -7,7 +7,6 @@ import { ensureTrailingSlash } from './path'; | ||
import type { Route } from './routing'; | ||
import { formatPath } from './format-path'; | ||
import { useTranslations } from './translations'; | ||
-import { DeprecatedLabelsPropProxy } from './i18n'; | ||
|
||
export interface PageProps extends Route { | ||
headings: MarkdownHeading[]; | ||
@@ -56,7 +55,7 @@ export function generateRouteData({ | ||
toc: getToC(props), | ||
lastUpdated: getLastUpdated(props), | ||
editUrl: getEditUrl(props), | ||
- labels: DeprecatedLabelsPropProxy, | ||
+ labels: {}, | ||
}; | ||
} | ||
|
||
diff --git a/utils/starlight-page.ts b/utils/starlight-page.ts | ||
index fb4e0c11a977ec5b49a5062a20e32aaa7d15cff1..6ee40bbd79aef0ab271659075209309311bfc65a 100644 | ||
--- a/utils/starlight-page.ts | ||
+++ b/utils/starlight-page.ts | ||
@@ -17,7 +17,6 @@ import { slugToLocaleData, urlToSlug } from './slugs'; | ||
import { getPrevNextLinks, getSidebar, getSidebarFromConfig } from './navigation'; | ||
import { docsSchema } from '../schema'; | ||
import type { Prettify, RemoveIndexSignature } from './types'; | ||
-import { DeprecatedLabelsPropProxy } from './i18n'; | ||
import { SidebarItemSchema } from '../schemas/sidebar'; | ||
import type { StarlightConfig, StarlightUserConfig } from './user-config'; | ||
|
||
@@ -84,12 +83,12 @@ const validateSidebarProp = ( | ||
export type StarlightPageProps = Prettify< | ||
// Remove the index signature from `Route`, omit undesired properties and make the rest optional. | ||
Partial<Omit<RemoveIndexSignature<PageProps>, 'entry' | 'entryMeta' | 'id' | 'locale' | 'slug'>> & | ||
- // Add the sidebar definitions for a Starlight page. | ||
- Partial<Pick<StarlightRouteData, 'hasSidebar'>> & { | ||
- sidebar?: StarlightUserConfig['sidebar']; | ||
- // And finally add the Starlight page frontmatter properties in a `frontmatter` property. | ||
- frontmatter: StarlightPageFrontmatter; | ||
- } | ||
+ // Add the sidebar definitions for a Starlight page. | ||
+ Partial<Pick<StarlightRouteData, 'hasSidebar'>> & { | ||
+ sidebar?: StarlightUserConfig['sidebar']; | ||
+ // And finally add the Starlight page frontmatter properties in a `frontmatter` property. | ||
+ frontmatter: StarlightPageFrontmatter; | ||
+ } | ||
>; | ||
|
||
/** | ||
@@ -153,7 +152,7 @@ export async function generateStarlightPageRouteData({ | ||
entryMeta, | ||
hasSidebar: props.hasSidebar ?? entry.data.template !== 'splash', | ||
headings, | ||
- labels: DeprecatedLabelsPropProxy, | ||
+ labels: {}, | ||
lastUpdated, | ||
pagination: getPrevNextLinks(sidebar, config.pagination, entry.data), | ||
sidebar, |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.