Skip to content

Commit

Permalink
feat: update Dockerfile and configuration for server host, add patche…
Browse files Browse the repository at this point in the history
…s for starlight integration
  • Loading branch information
louisescher committed Dec 22, 2024
1 parent cda23f1 commit bebce26
Show file tree
Hide file tree
Showing 6 changed files with 164 additions and 14 deletions.
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ COPY package.json /app/package.json
COPY pnpm-lock.yaml /app/pnpm-lock.yaml
COPY pnpm-workspace.yaml /app/pnpm-workspace.yaml

COPY ./patches /app/patches
COPY ./package /app/package
COPY ./docs /app/docs

Expand All @@ -19,4 +20,6 @@ RUN corepack enable
RUN pnpm install
RUN pnpm build

CMD ["pnpm", "start"]
EXPOSE 4321:4321

CMD ["export HOST=0.0.0.0;", "pnpm", "start"]
3 changes: 3 additions & 0 deletions docs/astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import starlightImageZoomPlugin from 'starlight-image-zoom';
// https://astro.build/config
export default defineConfig({
site: 'https://domainexpansion.gg',
server: {
host: '0.0.0.0'
},
integrations: [
domainExpansion(),
starlight({
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@astrojs/node": "^9.0.0",
"@astrojs/starlight": "^0.30.0",
"@domain-expansion/astro": "workspace:^",
"astro": "^5.0.2",
"astro": "^5.0.8",
"sharp": "^0.32.5",
"starlight-image-zoom": "^0.9.0",
"starlight-theme-catppuccin": "^2.0.0"
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,10 @@
"devDependencies": {
"@biomejs/biome": "1.9.4",
"@changesets/cli": "^2.27.10"
},
"pnpm": {
"patchedDependencies": {
"@astrojs/starlight": "patches/@astrojs__starlight.patch"
}
}
}
134 changes: 134 additions & 0 deletions patches/@astrojs__starlight.patch
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,
29 changes: 17 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bebce26

Please sign in to comment.