Mirror of
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #31 from trueberryless-org/ci-format

[ci] format

authored by

trueberryless and committed by
GitHub
402cfa0f f97059f7

+467 -397
+1 -1
.changeset/rotten-birds-tickle.md
··· 2 2 "starlight-cooler-credit": patch 3 3 --- 4 4 5 - Fix german grammar translation 5 + Fix german grammar translation
+53 -52
docs/astro.config.ts
··· 5 5 import starlightPluginsDocsComponents from "@trueberryless-org/starlight-plugins-docs-components"; 6 6 7 7 export default defineConfig({ 8 - integrations: [ 9 - starlight({ 10 - title: { 11 - en: "Starlight Cooler Credit", 12 - de: "Starlight Coolere Anerkennung", 13 - }, 14 - logo: { 15 - light: "./src/assets/logo-light.png", 16 - dark: "./src/assets/logo-dark.png", 17 - replacesTitle: true, 18 - }, 19 - editLink: { 20 - baseUrl: "https://github.com/trueberryless-org/starlight-cooler-credit/edit/main/docs/", 21 - }, 22 - locales: { 23 - root: { 24 - lang: "en", 25 - label: "English", 26 - }, 27 - de: { 28 - lang: "de", 29 - label: "Deutsch", 30 - }, 31 - }, 32 - plugins: [ 33 - starlightLinksValidator(), 34 - starlightCoolerCredit(), 35 - starlightPluginsDocsComponents({ 36 - pluginName: "starlight-cooler-credit", 37 - showcaseProps: { 38 - entries: [ 39 - { 40 - thumbnail: "./src/assets/rainsberger.ca.webp", 41 - href: "https://www.rainsberger.ca", 42 - title: "Sarah Rainsberger", 43 - }, 44 - ], 45 - }, 46 - }), 8 + integrations: [ 9 + starlight({ 10 + title: { 11 + en: "Starlight Cooler Credit", 12 + de: "Starlight Coolere Anerkennung", 13 + }, 14 + logo: { 15 + light: "./src/assets/logo-light.png", 16 + dark: "./src/assets/logo-dark.png", 17 + replacesTitle: true, 18 + }, 19 + editLink: { 20 + baseUrl: 21 + "https://github.com/trueberryless-org/starlight-cooler-credit/edit/main/docs/", 22 + }, 23 + locales: { 24 + root: { 25 + lang: "en", 26 + label: "English", 27 + }, 28 + de: { 29 + lang: "de", 30 + label: "Deutsch", 31 + }, 32 + }, 33 + plugins: [ 34 + starlightLinksValidator(), 35 + starlightCoolerCredit(), 36 + starlightPluginsDocsComponents({ 37 + pluginName: "starlight-cooler-credit", 38 + showcaseProps: { 39 + entries: [ 40 + { 41 + thumbnail: "./src/assets/rainsberger.ca.webp", 42 + href: "https://www.rainsberger.ca", 43 + title: "Sarah Rainsberger", 44 + }, 47 45 ], 48 - sidebar: [ 49 - { 50 - label: "Start Here", 51 - translations: { 52 - de: "Loslegen", 53 - }, 54 - items: [{ slug: "getting-started" }, { slug: "configuration" }], 55 - }, 56 - ], 57 - social: { 58 - github: "https://github.com/trueberryless-org/starlight-cooler-credit", 59 - }, 46 + }, 60 47 }), 61 - ], 48 + ], 49 + sidebar: [ 50 + { 51 + label: "Start Here", 52 + translations: { 53 + de: "Loslegen", 54 + }, 55 + items: [{ slug: "getting-started" }, { slug: "configuration" }], 56 + }, 57 + ], 58 + social: { 59 + github: "https://github.com/trueberryless-org/starlight-cooler-credit", 60 + }, 61 + }), 62 + ], 62 63 });
+21 -22
docs/package.json
··· 1 1 { 2 2 "name": "starlight-cooler-credit-docs", 3 3 "version": "0.1.9", 4 - "license": "MIT", 5 4 "description": "Add a nice credit to Starlight or Astro at the bottom of Table of Contents.", 5 + "keywords": [ 6 + "starlight", 7 + "docs", 8 + "astro", 9 + "credit", 10 + "cool", 11 + "multilingual" 12 + ], 13 + "homepage": "https://github.com/trueberryless-org/starlight-cooler-credit", 14 + "bugs": "https://github.com/trueberryless-org/starlight-cooler-credit/issues", 15 + "repository": { 16 + "type": "git", 17 + "url": "https://github.com/trueberryless-org/starlight-cooler-credit.git", 18 + "directory": "docs" 19 + }, 20 + "license": "MIT", 6 21 "author": "trueberryless-org", 7 22 "type": "module", 8 23 "scripts": { 24 + "astro": "astro", 25 + "build": "astro build", 9 26 "dev": "astro dev", 10 - "start": "astro dev", 11 - "build": "astro build", 12 27 "preview": "astro preview", 13 - "astro": "astro" 28 + "start": "astro dev" 14 29 }, 15 30 "dependencies": { 16 31 "@astrojs/starlight": "^0.29.0", ··· 21 36 "starlight-cooler-credit": "workspace:*", 22 37 "starlight-links-validator": "^0.13.0" 23 38 }, 39 + "packageManager": "pnpm@9.3.0", 24 40 "engines": { 25 41 "node": "^18.17.1 || ^20.3.0 || >=21.0.0" 26 - }, 27 - "keywords": [ 28 - "starlight", 29 - "docs", 30 - "astro", 31 - "credit", 32 - "cool", 33 - "multilingual" 34 - ], 35 - "packageManager": "pnpm@9.3.0", 36 - "private": true, 37 - "homepage": "https://github.com/trueberryless-org/starlight-cooler-credit", 38 - "repository": { 39 - "type": "git", 40 - "url": "https://github.com/trueberryless-org/starlight-cooler-credit.git", 41 - "directory": "docs" 42 - }, 43 - "bugs": "https://github.com/trueberryless-org/starlight-cooler-credit/issues" 42 + } 44 43 }
+3 -3
docs/src/content/config.ts
··· 1 - import { defineCollection } from 'astro:content' 2 - import { docsSchema } from '@astrojs/starlight/schema' 1 + import { defineCollection } from "astro:content"; 2 + import { docsSchema } from "@astrojs/starlight/schema"; 3 3 4 4 export const collections = { 5 5 docs: defineCollection({ schema: docsSchema() }), 6 - } 6 + };
+9 -9
docs/src/content/docs/configuration.mdx
··· 12 12 import starlightCoolerCredit from "starlight-view-modes"; 13 13 14 14 export default defineConfig({ 15 - integrations: [ 16 - starlight({ 17 - plugins: [ 18 - starlightCoolerCredit({ 19 - // Configuration options go here. 20 - }), 21 - ], 22 - title: "My Docs", 15 + integrations: [ 16 + starlight({ 17 + plugins: [ 18 + starlightCoolerCredit({ 19 + // Configuration options go here. 23 20 }), 24 - ], 21 + ], 22 + title: "My Docs", 23 + }), 24 + ], 25 25 }); 26 26 ``` 27 27
+9 -9
docs/src/content/docs/de/configuration.mdx
··· 12 12 import starlightCoolerCredit from "starlight-view-modes"; 13 13 14 14 export default defineConfig({ 15 - integrations: [ 16 - starlight({ 17 - plugins: [ 18 - starlightCoolerCredit({ 19 - // Die Konfigurationsoptionen findest du hier. 20 - }), 21 - ], 22 - title: "My Docs", 15 + integrations: [ 16 + starlight({ 17 + plugins: [ 18 + starlightCoolerCredit({ 19 + // Die Konfigurationsoptionen findest du hier. 23 20 }), 24 - ], 21 + ], 22 + title: "My Docs", 23 + }), 24 + ], 25 25 }); 26 26 ``` 27 27
+31 -31
docs/src/content/docs/de/getting-started.mdx
··· 17 17 18 18 1. `starlight-cooler-credit` ist ein Starlight [Plugin](https://starlight.astro.build/de/reference/plugins/). Installiere es, indem du den folgenden Befehl in deinem Terminal ausführst: 19 19 20 - <Tabs syncKey="pkg"> 20 + <Tabs syncKey="pkg"> 21 21 22 - <TabItem label="npm"> 22 + <TabItem label="npm"> 23 23 24 - ```sh 25 - npm install starlight-cooler-credit 26 - ``` 24 + ```sh 25 + npm install starlight-cooler-credit 26 + ``` 27 27 28 - </TabItem> 28 + </TabItem> 29 29 30 - <TabItem label="pnpm"> 30 + <TabItem label="pnpm"> 31 31 32 - ```sh 33 - pnpm add starlight-cooler-credit 34 - ``` 32 + ```sh 33 + pnpm add starlight-cooler-credit 34 + ``` 35 35 36 - </TabItem> 36 + </TabItem> 37 37 38 - <TabItem label="Yarn"> 38 + <TabItem label="Yarn"> 39 39 40 - ```sh 41 - yarn add starlight-cooler-credit 42 - ``` 40 + ```sh 41 + yarn add starlight-cooler-credit 42 + ``` 43 43 44 - </TabItem> 44 + </TabItem> 45 45 46 - </Tabs> 46 + </Tabs> 47 47 48 48 2. Konfiguriere das Plugin in deiner Starlight [Konfiguration](https://starlight.astro.build/de/reference/configuration/#plugins) in der Datei `astro.config.mjs`. 49 49 50 - ```diff lang="js" 51 - // astro.config.mjs 52 - import starlight from '@astrojs/starlight' 53 - import { defineConfig } from 'astro/config' 54 - +import starlightCoolerCredit from 'starlight-cooler-credit' 50 + ```diff lang="js" 51 + // astro.config.mjs 52 + import starlight from '@astrojs/starlight' 53 + import { defineConfig } from 'astro/config' 54 + +import starlightCoolerCredit from 'starlight-cooler-credit' 55 55 56 - export default defineConfig({ 57 - integrations: [ 58 - starlight({ 59 - + plugins: [starlightCoolerCredit()], 60 - title: 'My Docs', 61 - }), 62 - ], 63 - }) 64 - ``` 56 + export default defineConfig({ 57 + integrations: [ 58 + starlight({ 59 + + plugins: [starlightCoolerCredit()], 60 + title: 'My Docs', 61 + }), 62 + ], 63 + }) 64 + ``` 65 65 66 66 3. [Starte den Entwicklungsserver](https://starlight.astro.build/getting-started/#start-the-development-server), um das Plugin in Aktion zu sehen. 67 67
+17 -16
docs/src/content/docs/de/index.mdx
··· 2 2 title: Starlight Coolere Anerkennung 3 3 description: Füge einen netten Hinweis auf Starlight oder Astro am Ende des Inhaltsverzeichnisses hinzu. 4 4 head: 5 - - tag: title 6 - content: Starlight Coolere Anerkennung 5 + - tag: title 6 + content: Starlight Coolere Anerkennung 7 7 template: splash 8 8 editUrl: false 9 9 hero: 10 - tagline: Füge einen netten Hinweis auf Starlight oder Astro am Ende des Inhaltsverzeichnisses hinzu. 11 - image: 12 - dark: ../../../assets/big-logo-dark.png 13 - light: ../../../assets/big-logo-light.png 14 - actions: 15 - - text: Loslegen 16 - link: /de/getting-started/ 17 - icon: right-arrow 10 + tagline: Füge einen netten Hinweis auf Starlight oder Astro am Ende des Inhaltsverzeichnisses hinzu. 11 + image: 12 + dark: ../../../assets/big-logo-dark.png 13 + light: ../../../assets/big-logo-light.png 14 + actions: 15 + - text: Loslegen 16 + link: /de/getting-started/ 17 + icon: right-arrow 18 18 --- 19 19 20 20 import { Card, CardGrid } from "@astrojs/starlight/components"; ··· 22 22 ## Nächste Schritte 23 23 24 24 <CardGrid stagger> 25 - <Card title="Installiere das Plugin" icon="puzzle"> 26 - In der [Startanleitung](/de/getting-started/) findest du Anweisungen zur Installation. 27 - </Card> 28 - <Card title="Konfiguriere das Plugin" icon="setting"> 29 - Bearbeite deine Konfiguration in der Datei `astro.config.mjs`. 30 - </Card> 25 + <Card title="Installiere das Plugin" icon="puzzle"> 26 + In der [Startanleitung](/de/getting-started/) findest du Anweisungen zur 27 + Installation. 28 + </Card> 29 + <Card title="Konfiguriere das Plugin" icon="setting"> 30 + Bearbeite deine Konfiguration in der Datei `astro.config.mjs`. 31 + </Card> 31 32 </CardGrid> 32 33 33 34 import { ContributorList } from "starlight-contributor-list";
+31 -31
docs/src/content/docs/getting-started.mdx
··· 17 17 18 18 1. `starlight-cooler-credit` is a Starlight [plugin](https://starlight.astro.build/reference/plugins/). Install it by running the following command in your terminal: 19 19 20 - <Tabs syncKey="pkg"> 20 + <Tabs syncKey="pkg"> 21 21 22 - <TabItem label="npm"> 22 + <TabItem label="npm"> 23 23 24 - ```sh 25 - npm install starlight-cooler-credit 26 - ``` 24 + ```sh 25 + npm install starlight-cooler-credit 26 + ``` 27 27 28 - </TabItem> 28 + </TabItem> 29 29 30 - <TabItem label="pnpm"> 30 + <TabItem label="pnpm"> 31 31 32 - ```sh 33 - pnpm add starlight-cooler-credit 34 - ``` 32 + ```sh 33 + pnpm add starlight-cooler-credit 34 + ``` 35 35 36 - </TabItem> 36 + </TabItem> 37 37 38 - <TabItem label="Yarn"> 38 + <TabItem label="Yarn"> 39 39 40 - ```sh 41 - yarn add starlight-cooler-credit 42 - ``` 40 + ```sh 41 + yarn add starlight-cooler-credit 42 + ``` 43 43 44 - </TabItem> 44 + </TabItem> 45 45 46 - </Tabs> 46 + </Tabs> 47 47 48 48 2. Configure the plugin in your Starlight [configuration](https://starlight.astro.build/reference/configuration/#plugins) in the `astro.config.mjs` file. 49 49 50 - ```diff lang="js" 51 - // astro.config.mjs 52 - import starlight from '@astrojs/starlight' 53 - import { defineConfig } from 'astro/config' 54 - +import starlightCoolerCredit from 'starlight-cooler-credit' 50 + ```diff lang="js" 51 + // astro.config.mjs 52 + import starlight from '@astrojs/starlight' 53 + import { defineConfig } from 'astro/config' 54 + +import starlightCoolerCredit from 'starlight-cooler-credit' 55 55 56 - export default defineConfig({ 57 - integrations: [ 58 - starlight({ 59 - + plugins: [starlightCoolerCredit()], 60 - title: 'My Docs', 61 - }), 62 - ], 63 - }) 64 - ``` 56 + export default defineConfig({ 57 + integrations: [ 58 + starlight({ 59 + + plugins: [starlightCoolerCredit()], 60 + title: 'My Docs', 61 + }), 62 + ], 63 + }) 64 + ``` 65 65 66 66 3. [Start the development server](https://starlight.astro.build/getting-started/#start-the-development-server) to preview the plugin in action. 67 67
+17 -16
docs/src/content/docs/index.mdx
··· 2 2 title: Starlight Cooler Credit 3 3 description: Add a nice credit to Starlight or Astro at the bottom of Table of Contents. 4 4 head: 5 - - tag: title 6 - content: Starlight Cooler Credit 5 + - tag: title 6 + content: Starlight Cooler Credit 7 7 template: splash 8 8 editUrl: false 9 9 hero: 10 - tagline: Add a nice credit to Starlight or Astro at the bottom of Table of Contents. 11 - image: 12 - dark: ../../assets/big-logo-dark.png 13 - light: ../../assets/big-logo-light.png 14 - actions: 15 - - text: Get Started 16 - link: /getting-started/ 17 - icon: right-arrow 10 + tagline: Add a nice credit to Starlight or Astro at the bottom of Table of Contents. 11 + image: 12 + dark: ../../assets/big-logo-dark.png 13 + light: ../../assets/big-logo-light.png 14 + actions: 15 + - text: Get Started 16 + link: /getting-started/ 17 + icon: right-arrow 18 18 --- 19 19 20 20 import { Card, CardGrid } from "@astrojs/starlight/components"; ··· 22 22 ## Next steps 23 23 24 24 <CardGrid stagger> 25 - <Card title="Install the plugin" icon="puzzle"> 26 - Check the [getting started guide](/getting-started/) for installation instructions. 27 - </Card> 28 - <Card title="Configure the plugin" icon="setting"> 29 - Edit your config in the `astro.config.mjs` file. 30 - </Card> 25 + <Card title="Install the plugin" icon="puzzle"> 26 + Check the [getting started guide](/getting-started/) for installation 27 + instructions. 28 + </Card> 29 + <Card title="Configure the plugin" icon="setting"> 30 + Edit your config in the `astro.config.mjs` file. 31 + </Card> 31 32 </CardGrid> 32 33 33 34 import { ContributorList } from "starlight-contributor-list";
+1 -1
docs/src/env.d.ts
··· 1 - /// <reference path="../.astro/types.d.ts" /> 1 + /// <reference path="../.astro/types.d.ts" />
+73 -52
packages/starlight-cooler-credit/index.ts
··· 1 - import type { StarlightPlugin, StarlightUserConfig } from "@astrojs/starlight/types"; 1 + import type { 2 + StarlightPlugin, 3 + StarlightUserConfig, 4 + } from "@astrojs/starlight/types"; 2 5 import type { AstroIntegrationLogger } from "astro"; 3 6 import { Translations } from "./translations"; 4 - import { type StarlightCoolerCreditConfig, validateConfig, type StarlightCoolerCreditUserConfig } from "./libs/config"; 7 + import { 8 + type StarlightCoolerCreditConfig, 9 + validateConfig, 10 + type StarlightCoolerCreditUserConfig, 11 + } from "./libs/config"; 5 12 import { vitePluginStarlightCoolerCreditConfig } from "./libs/vite"; 6 13 7 14 export type { StarlightCoolerCreditConfig, StarlightCoolerCreditUserConfig }; 8 15 9 - export default function starlightCoolerCredit(userConfig?: StarlightCoolerCreditUserConfig): StarlightPlugin { 10 - const config = validateConfig(userConfig); 16 + export default function starlightCoolerCredit( 17 + userConfig?: StarlightCoolerCreditUserConfig 18 + ): StarlightPlugin { 19 + const config = validateConfig(userConfig); 11 20 12 - return { 13 - name: "starlight-cooler-credit", 14 - hooks: { 15 - setup({ addIntegration, updateConfig: updateStarlightConfig, config: starlightConfig, logger, injectTranslations }) { 16 - /** 17 - * This is the entry point of your Starlight plugin. 18 - * The `setup` hook is called when Starlight is initialized (during the Astro `astro:config:setup` integration 19 - * hook). 20 - * To learn more about the Starlight plugin API and all available options in this hook, check the Starlight 21 - * plugins reference. 22 - * 23 - * @see https://starlight.astro.build/reference/plugins/ 24 - */ 25 - logger.info("Hello from the starlight-cooler-credit plugin!"); 21 + return { 22 + name: "starlight-cooler-credit", 23 + hooks: { 24 + setup({ 25 + addIntegration, 26 + updateConfig: updateStarlightConfig, 27 + config: starlightConfig, 28 + logger, 29 + injectTranslations, 30 + }) { 31 + /** 32 + * This is the entry point of your Starlight plugin. 33 + * The `setup` hook is called when Starlight is initialized (during the Astro `astro:config:setup` integration 34 + * hook). 35 + * To learn more about the Starlight plugin API and all available options in this hook, check the Starlight 36 + * plugins reference. 37 + * 38 + * @see https://starlight.astro.build/reference/plugins/ 39 + */ 40 + logger.info("Hello from the starlight-cooler-credit plugin!"); 26 41 27 - injectTranslations(Translations); 42 + injectTranslations(Translations); 28 43 29 - updateStarlightConfig({ 30 - components: { 31 - ...starlightConfig.components, 32 - ...overrideStarlightComponent(starlightConfig.components, logger, "PageSidebar"), 33 - }, 34 - }); 44 + updateStarlightConfig({ 45 + components: { 46 + ...starlightConfig.components, 47 + ...overrideStarlightComponent( 48 + starlightConfig.components, 49 + logger, 50 + "PageSidebar" 51 + ), 52 + }, 53 + }); 35 54 36 - addIntegration({ 37 - name: "starlight-cooler-credit-integration", 38 - hooks: { 39 - "astro:config:setup": ({ updateConfig }) => { 40 - updateConfig({ 41 - vite: { 42 - plugins: [vitePluginStarlightCoolerCreditConfig(config)], 43 - }, 44 - }); 45 - }, 46 - }, 47 - }); 55 + addIntegration({ 56 + name: "starlight-cooler-credit-integration", 57 + hooks: { 58 + "astro:config:setup": ({ updateConfig }) => { 59 + updateConfig({ 60 + vite: { 61 + plugins: [vitePluginStarlightCoolerCreditConfig(config)], 62 + }, 63 + }); 48 64 }, 49 - }, 50 - }; 65 + }, 66 + }); 67 + }, 68 + }, 69 + }; 51 70 } 52 71 53 72 function overrideStarlightComponent( 54 - components: StarlightUserConfig["components"], 55 - logger: AstroIntegrationLogger, 56 - component: keyof NonNullable<StarlightUserConfig["components"]> 73 + components: StarlightUserConfig["components"], 74 + logger: AstroIntegrationLogger, 75 + component: keyof NonNullable<StarlightUserConfig["components"]> 57 76 ) { 58 - if (components?.[component]) { 59 - logger.warn(`It looks like you already have a \`${component}\` component override in your Starlight configuration.`); 60 - logger.warn( 61 - `To use \`starlight-cooler-credit\`, either remove your override or update it to render the content from \`starlight-cooler-credit/overrides/${component}.astro\`.` 62 - ); 77 + if (components?.[component]) { 78 + logger.warn( 79 + `It looks like you already have a \`${component}\` component override in your Starlight configuration.` 80 + ); 81 + logger.warn( 82 + `To use \`starlight-cooler-credit\`, either remove your override or update it to render the content from \`starlight-cooler-credit/overrides/${component}.astro\`.` 83 + ); 63 84 64 - return {}; 65 - } 85 + return {}; 86 + } 66 87 67 - return { 68 - [component]: `starlight-cooler-credit/overrides/${component}.astro`, 69 - }; 88 + return { 89 + [component]: `starlight-cooler-credit/overrides/${component}.astro`, 90 + }; 70 91 }
+30 -25
packages/starlight-cooler-credit/libs/config.ts
··· 2 2 import { z } from "astro/zod"; 3 3 4 4 const configSchema = z 5 - .object({ 6 - credit: z 7 - .union([ 8 - z.enum(["Astro", "Starlight", "Starlight Blog"]), 9 - z.object({ 10 - title: z.union([z.string(), z.record(z.string())]), 11 - href: z.string().url(), 12 - description: z.union([z.string(), z.record(z.string())]).optional(), 13 - }), 14 - ]) 15 - .default("Starlight"), 16 - }) 17 - .default({}); 5 + .object({ 6 + credit: z 7 + .union([ 8 + z.enum(["Astro", "Starlight", "Starlight Blog"]), 9 + z.object({ 10 + title: z.union([z.string(), z.record(z.string())]), 11 + href: z.string().url(), 12 + description: z.union([z.string(), z.record(z.string())]).optional(), 13 + }), 14 + ]) 15 + .default("Starlight"), 16 + }) 17 + .default({}); 18 18 19 - export function validateConfig(userConfig: unknown): StarlightCoolerCreditConfig { 20 - const config = configSchema.safeParse(userConfig); 19 + export function validateConfig( 20 + userConfig: unknown 21 + ): StarlightCoolerCreditConfig { 22 + const config = configSchema.safeParse(userConfig); 21 23 22 - if (!config.success) { 23 - const errors = config.error.flatten(); 24 + if (!config.success) { 25 + const errors = config.error.flatten(); 24 26 25 - throw new AstroError( 26 - `Invalid @trueberryless-org/starlight-plugins-docs-components configuration: 27 + throw new AstroError( 28 + `Invalid @trueberryless-org/starlight-plugins-docs-components configuration: 27 29 28 30 ${errors.formErrors.map((formError) => ` - ${formError}`).join("\n")} 29 31 ${Object.entries(errors.fieldErrors) 30 - .map(([fieldName, fieldErrors]) => ` - ${fieldName}: ${fieldErrors.join(" - ")}`) 31 - .join("\n")} 32 + .map( 33 + ([fieldName, fieldErrors]) => 34 + ` - ${fieldName}: ${fieldErrors.join(" - ")}` 35 + ) 36 + .join("\n")} 32 37 `, 33 - `See the error report above for more informations.\n\nIf you believe this is a bug, please file an issue at https://github.com/trueberryless-org/starlight-plugins-docs-components/issues/new` 34 - ); 35 - } 38 + `See the error report above for more informations.\n\nIf you believe this is a bug, please file an issue at https://github.com/trueberryless-org/starlight-plugins-docs-components/issues/new` 39 + ); 40 + } 36 41 37 - return config.data; 42 + return config.data; 38 43 } 39 44 40 45 export type StarlightCoolerCreditUserConfig = z.input<typeof configSchema>;
+10 -4
packages/starlight-cooler-credit/libs/i18n.ts
··· 1 1 import starlightConfig from "virtual:starlight/user-config"; 2 2 3 - export const DefaultLocale = starlightConfig.defaultLocale.locale === "root" ? undefined : starlightConfig.defaultLocale.locale; 3 + export const DefaultLocale = 4 + starlightConfig.defaultLocale.locale === "root" 5 + ? undefined 6 + : starlightConfig.defaultLocale.locale; 4 7 5 8 export function getLangFromLocale(locale: Locale): string { 6 - const lang = locale ? starlightConfig.locales?.[locale]?.lang : starlightConfig.locales?.root?.lang; 7 - const defaultLang = starlightConfig.defaultLocale.lang ?? starlightConfig.defaultLocale.locale; 8 - return lang ?? defaultLang ?? "en"; 9 + const lang = locale 10 + ? starlightConfig.locales?.[locale]?.lang 11 + : starlightConfig.locales?.root?.lang; 12 + const defaultLang = 13 + starlightConfig.defaultLocale.lang ?? starlightConfig.defaultLocale.locale; 14 + return lang ?? defaultLang ?? "en"; 9 15 } 10 16 11 17 export type Locale = string | undefined;
+45 -35
packages/starlight-cooler-credit/libs/util.ts
··· 4 4 import { kebabCase } from "change-case"; 5 5 6 6 export default function getCreditText( 7 - config: StarlightCoolerCreditConfig, 8 - type: "title" | "href" | "description", 9 - translate: (key: any) => string, 10 - locale: Locale 7 + config: StarlightCoolerCreditConfig, 8 + type: "title" | "href" | "description", 9 + translate: (key: any) => string, 10 + locale: Locale 11 11 ): string | undefined { 12 - if (typeof config.credit === "string") { 13 - if (type == "href") { 14 - if (config.credit === "Astro") { 15 - return "https://docs.astro.build/"; 16 - } else if (config.credit === "Starlight Blog") { 17 - return "https://github.com/HiDeoo/starlight-blog"; 18 - } else if (config.credit === "Starlight") { 19 - return "https://starlight.astro.build/"; 20 - } 21 - } 22 - if (type == "title" && config.credit === "Starlight") { 23 - return translate(`builtWithStarlight.label`); 24 - } 25 - return translate(`starlightCoolerCredit.${kebabCase(config.credit)}.${type}`); 26 - } else { 27 - if (type === "href") return config.credit.href; 28 - if (type === "description" && (!config.credit.description || config.credit.description === "")) return undefined; 29 - if (typeof config.credit[type] === "string") return config.credit[type]; 30 - 31 - let text: string; 32 - const lang = getLangFromLocale(locale); 33 - const defaultLang = starlightConfig.defaultLocale.lang ?? starlightConfig.defaultLocale.locale; 12 + if (typeof config.credit === "string") { 13 + if (type == "href") { 14 + if (config.credit === "Astro") { 15 + return "https://docs.astro.build/"; 16 + } else if (config.credit === "Starlight Blog") { 17 + return "https://github.com/HiDeoo/starlight-blog"; 18 + } else if (config.credit === "Starlight") { 19 + return "https://starlight.astro.build/"; 20 + } 21 + } 22 + if (type == "title" && config.credit === "Starlight") { 23 + return translate(`builtWithStarlight.label`); 24 + } 25 + return translate( 26 + `starlightCoolerCredit.${kebabCase(config.credit)}.${type}` 27 + ); 28 + } else { 29 + if (type === "href") return config.credit.href; 30 + if ( 31 + type === "description" && 32 + (!config.credit.description || config.credit.description === "") 33 + ) 34 + return undefined; 35 + if (typeof config.credit[type] === "string") return config.credit[type]; 34 36 35 - if (config.credit[type][lang]) { 36 - text = config.credit[type][lang]; 37 - } else { 38 - text = defaultLang ? config.credit[type][defaultLang] ?? "" : ""; 39 - } 37 + let text: string; 38 + const lang = getLangFromLocale(locale); 39 + const defaultLang = 40 + starlightConfig.defaultLocale.lang ?? 41 + starlightConfig.defaultLocale.locale; 40 42 41 - if (text.length === 0) { 42 - throw new Error(`The credit ${type} must have a key for the default language (${defaultLang}).`); 43 - } 43 + if (config.credit[type][lang]) { 44 + text = config.credit[type][lang]; 45 + } else { 46 + text = defaultLang ? config.credit[type][defaultLang] ?? "" : ""; 47 + } 44 48 45 - return text; 49 + if (text.length === 0) { 50 + throw new Error( 51 + `The credit ${type} must have a key for the default language (${defaultLang}).` 52 + ); 46 53 } 54 + 55 + return text; 56 + } 47 57 }
+15 -13
packages/starlight-cooler-credit/libs/vite.ts
··· 2 2 3 3 import type { StarlightCoolerCreditConfig } from ".."; 4 4 5 - export function vitePluginStarlightCoolerCreditConfig(config: StarlightCoolerCreditConfig): VitePlugin { 6 - const moduleId = "virtual:starlight-cooler-credit-config"; 7 - const resolvedModuleId = `\0${moduleId}`; 8 - const moduleContent = `export default ${JSON.stringify(config)}`; 5 + export function vitePluginStarlightCoolerCreditConfig( 6 + config: StarlightCoolerCreditConfig 7 + ): VitePlugin { 8 + const moduleId = "virtual:starlight-cooler-credit-config"; 9 + const resolvedModuleId = `\0${moduleId}`; 10 + const moduleContent = `export default ${JSON.stringify(config)}`; 9 11 10 - return { 11 - name: "vite-plugin-starlight-cooler-credit", 12 - load(id) { 13 - return id === resolvedModuleId ? moduleContent : undefined; 14 - }, 15 - resolveId(id) { 16 - return id === moduleId ? resolvedModuleId : undefined; 17 - }, 18 - }; 12 + return { 13 + name: "vite-plugin-starlight-cooler-credit", 14 + load(id) { 15 + return id === resolvedModuleId ? moduleContent : undefined; 16 + }, 17 + resolveId(id) { 18 + return id === moduleId ? resolvedModuleId : undefined; 19 + }, 20 + }; 19 21 } 20 22 21 23 type VitePlugin = NonNullable<ViteUserConfig["plugins"]>[number];
+19 -19
packages/starlight-cooler-credit/package.json
··· 1 1 { 2 2 "name": "starlight-cooler-credit", 3 3 "version": "0.1.8", 4 + "description": "Add a nice credit to Starlight or Astro at the bottom of Table of Contents.", 5 + "keywords": [ 6 + "starlight", 7 + "docs", 8 + "astro", 9 + "credit", 10 + "cool", 11 + "multilingual" 12 + ], 13 + "homepage": "https://github.com/trueberryless-org/starlight-cooler-credit", 14 + "bugs": "https://github.com/trueberryless-org/starlight-cooler-credit/issues", 15 + "repository": { 16 + "type": "git", 17 + "url": "https://github.com/trueberryless-org/starlight-cooler-credit.git", 18 + "directory": "packages/starlight-cooler-credit" 19 + }, 4 20 "license": "MIT", 5 - "description": "Add a nice credit to Starlight or Astro at the bottom of Table of Contents.", 6 21 "author": "trueberryless-org", 7 22 "type": "module", 8 23 "exports": { ··· 10 25 "./overrides/PageSidebar.astro": "./overrides/PageSidebar.astro", 11 26 "./package.json": "./package.json" 12 27 }, 28 + "dependencies": { 29 + "change-case": "^5.4.4" 30 + }, 13 31 "devDependencies": { 14 32 "@astrojs/starlight": "^0.29.0", 15 33 "astro": "^4.16.10" ··· 22 40 }, 23 41 "publishConfig": { 24 42 "access": "public" 25 - }, 26 - "keywords": [ 27 - "starlight", 28 - "docs", 29 - "astro", 30 - "credit", 31 - "cool", 32 - "multilingual" 33 - ], 34 - "homepage": "https://github.com/trueberryless-org/starlight-cooler-credit", 35 - "repository": { 36 - "type": "git", 37 - "url": "https://github.com/trueberryless-org/starlight-cooler-credit.git", 38 - "directory": "packages/starlight-cooler-credit" 39 - }, 40 - "bugs": "https://github.com/trueberryless-org/starlight-cooler-credit/issues", 41 - "dependencies": { 42 - "change-case": "^5.4.4" 43 43 } 44 44 }
+80 -56
packages/starlight-cooler-credit/translations.ts
··· 1 1 export const Translations = { 2 - en: { 3 - "starlightCoolerCredit.starlight.description": "Do you want to build your own docs? →", 4 - "starlightCoolerCredit.astro.title": "Built with Astro", 5 - "starlightCoolerCredit.astro.description": "Want to build your own static website? →", 6 - "starlightCoolerCredit.starlight-blog.title": "Built with Starlight Blog", 7 - "starlightCoolerCredit.starlight-blog.description": "Want to build your own Starlight blog? →", 8 - }, 9 - de: { 10 - "starlightCoolerCredit.starlight.description": "Willst du deine eigene Dokumentation erstellen? →", 11 - "starlightCoolerCredit.astro.title": "Erstellt mit Astro", 12 - "starlightCoolerCredit.astro.description": "Willst du deine eigene statische Website erstellen? →", 13 - "starlightCoolerCredit.starlight-blog.title": "Erstellt mit Starlight Blog", 14 - "starlightCoolerCredit.starlight-blog.description": "Willst du deinen eigenen Starlight Blog erstellen? →", 15 - }, 16 - fr: { 17 - "starlightCoolerCredit.starlight.description": "Vous souhaitez créer votre propre documentation ? →", 18 - "starlightCoolerCredit.astro.title": "Construit avec Astro", 19 - "starlightCoolerCredit.astro.description": "Vous souhaitez créer votre propre site web statique ? →", 20 - "starlightCoolerCredit.starlight-blog.title": "Construit avec Starlight Blog", 21 - "starlightCoolerCredit.starlight-blog.description": "Vous souhaitez créer votre propre blog Starlight ? →", 22 - }, 23 - ko: { 24 - "starlightCoolerCredit.starlight.description": "나만의 문서를 만들고 싶나요? →", 25 - "starlightCoolerCredit.astro.title": "Astro로 제작됨", 26 - "starlightCoolerCredit.astro.description": "나만의 정적 웹사이트를 만들고 싶나요? →", 27 - "starlightCoolerCredit.starlight-blog.title": "Starlight Blog로 제작됨", 28 - "starlightCoolerCredit.starlight-blog.description": "나만의 Starlight 블로그를 만들고 싶나요? →", 29 - }, 30 - it: { 31 - "starlightCoolerCredit.starlight.description": "Vuoi creare la tua documentazione? →", 32 - "starlightCoolerCredit.astro.title": "Creato con Astro", 33 - "starlightCoolerCredit.astro.description": "Vuoi creare il tuo sito web statico? →", 34 - "starlightCoolerCredit.starlight-blog.title": "Creato con Starlight Blog", 35 - "starlightCoolerCredit.starlight-blog.description": "Vuoi creare il tuo blog Starlight? →", 36 - }, 37 - ru: { 38 - "starlightCoolerCredit.starlight.description": "Хотите создать свою документацию? →", 39 - "starlightCoolerCredit.astro.title": "Создано с помощью Astro", 40 - "starlightCoolerCredit.astro.description": "Хотите создать свой статичный сайт? →", 41 - "starlightCoolerCredit.starlight-blog.title": "Создано с помощью Starlight Blog", 42 - "starlightCoolerCredit.starlight-blog.description": "Хотите создать свой Starlight блог? →", 43 - }, 44 - ja: { 45 - "starlightCoolerCredit.starlight.description": "自分のドキュメントを作成したいですか? →", 46 - "starlightCoolerCredit.astro.title": "Astro で作成", 47 - "starlightCoolerCredit.astro.description": "自分の静的ウェブサイトを作成したいですか? →", 48 - "starlightCoolerCredit.starlight-blog.title": "Starlight Blog で作成", 49 - "starlightCoolerCredit.starlight-blog.description": "自分の Starlight Blog を作成したいですか? →", 50 - }, 51 - zh: { 52 - "starlightCoolerCredit.starlight.description": "你想构建自己的文档吗? →", 53 - "starlightCoolerCredit.astro.title": "由 Astro 构建", 54 - "starlightCoolerCredit.astro.description": "想要构建自己的静态网站? →", 55 - "starlightCoolerCredit.starlight-blog.title": "由 Starlight Blog 构建", 56 - "starlightCoolerCredit.starlight-blog.description": "想建立自己的 Starlight 博客吗? →", 57 - }, 2 + en: { 3 + "starlightCoolerCredit.starlight.description": 4 + "Do you want to build your own docs? →", 5 + "starlightCoolerCredit.astro.title": "Built with Astro", 6 + "starlightCoolerCredit.astro.description": 7 + "Want to build your own static website? →", 8 + "starlightCoolerCredit.starlight-blog.title": "Built with Starlight Blog", 9 + "starlightCoolerCredit.starlight-blog.description": 10 + "Want to build your own Starlight blog? →", 11 + }, 12 + de: { 13 + "starlightCoolerCredit.starlight.description": 14 + "Willst du deine eigene Dokumentation erstellen? →", 15 + "starlightCoolerCredit.astro.title": "Erstellt mit Astro", 16 + "starlightCoolerCredit.astro.description": 17 + "Willst du deine eigene statische Website erstellen? →", 18 + "starlightCoolerCredit.starlight-blog.title": "Erstellt mit Starlight Blog", 19 + "starlightCoolerCredit.starlight-blog.description": 20 + "Willst du deinen eigenen Starlight Blog erstellen? →", 21 + }, 22 + fr: { 23 + "starlightCoolerCredit.starlight.description": 24 + "Vous souhaitez créer votre propre documentation ? →", 25 + "starlightCoolerCredit.astro.title": "Construit avec Astro", 26 + "starlightCoolerCredit.astro.description": 27 + "Vous souhaitez créer votre propre site web statique ? →", 28 + "starlightCoolerCredit.starlight-blog.title": 29 + "Construit avec Starlight Blog", 30 + "starlightCoolerCredit.starlight-blog.description": 31 + "Vous souhaitez créer votre propre blog Starlight ? →", 32 + }, 33 + ko: { 34 + "starlightCoolerCredit.starlight.description": 35 + "나만의 문서를 만들고 싶나요? →", 36 + "starlightCoolerCredit.astro.title": "Astro로 제작됨", 37 + "starlightCoolerCredit.astro.description": 38 + "나만의 정적 웹사이트를 만들고 싶나요? →", 39 + "starlightCoolerCredit.starlight-blog.title": "Starlight Blog로 제작됨", 40 + "starlightCoolerCredit.starlight-blog.description": 41 + "나만의 Starlight 블로그를 만들고 싶나요? →", 42 + }, 43 + it: { 44 + "starlightCoolerCredit.starlight.description": 45 + "Vuoi creare la tua documentazione? →", 46 + "starlightCoolerCredit.astro.title": "Creato con Astro", 47 + "starlightCoolerCredit.astro.description": 48 + "Vuoi creare il tuo sito web statico? →", 49 + "starlightCoolerCredit.starlight-blog.title": "Creato con Starlight Blog", 50 + "starlightCoolerCredit.starlight-blog.description": 51 + "Vuoi creare il tuo blog Starlight? →", 52 + }, 53 + ru: { 54 + "starlightCoolerCredit.starlight.description": 55 + "Хотите создать свою документацию? →", 56 + "starlightCoolerCredit.astro.title": "Создано с помощью Astro", 57 + "starlightCoolerCredit.astro.description": 58 + "Хотите создать свой статичный сайт? →", 59 + "starlightCoolerCredit.starlight-blog.title": 60 + "Создано с помощью Starlight Blog", 61 + "starlightCoolerCredit.starlight-blog.description": 62 + "Хотите создать свой Starlight блог? →", 63 + }, 64 + ja: { 65 + "starlightCoolerCredit.starlight.description": 66 + "自分のドキュメントを作成したいですか? →", 67 + "starlightCoolerCredit.astro.title": "Astro で作成", 68 + "starlightCoolerCredit.astro.description": 69 + "自分の静的ウェブサイトを作成したいですか? →", 70 + "starlightCoolerCredit.starlight-blog.title": "Starlight Blog で作成", 71 + "starlightCoolerCredit.starlight-blog.description": 72 + "自分の Starlight Blog を作成したいですか? →", 73 + }, 74 + zh: { 75 + "starlightCoolerCredit.starlight.description": "你想构建自己的文档吗? →", 76 + "starlightCoolerCredit.astro.title": "由 Astro 构建", 77 + "starlightCoolerCredit.astro.description": "想要构建自己的静态网站? →", 78 + "starlightCoolerCredit.starlight-blog.title": "由 Starlight Blog 构建", 79 + "starlightCoolerCredit.starlight-blog.description": 80 + "想建立自己的 Starlight 博客吗? →", 81 + }, 58 82 };
+2 -2
packages/starlight-cooler-credit/virtual.d.ts
··· 1 1 declare module "virtual:starlight-cooler-credit-config" { 2 - const StarlightCoolerCreditConfig: import("./index").StarlightCoolerCreditConfig; 3 - export default StarlightCoolerCreditConfig; 2 + const StarlightCoolerCreditConfig: import("./index").StarlightCoolerCreditConfig; 3 + export default StarlightCoolerCreditConfig; 4 4 }