Skip to content

Commit

Permalink
Add kudos option to add “Built with Starlight” badge to site footers (#…
Browse files Browse the repository at this point in the history
…1958)

Co-authored-by: Luiz Ferraz <luiz@lferraz.com>
Co-authored-by: NotJaime13 <104889849+notjaime13@users.noreply.github.com>
Co-authored-by: HiDeoo <494699+HiDeoo@users.noreply.github.com>
Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Co-authored-by: liruifengv <liruifeng1024@gmail.com>
Co-authored-by: Adam Matthiesen <30383579+Adammatthiesen@users.noreply.github.com>
Co-authored-by: Atharva <atharvapise19@gmail.com>
Co-authored-by: trueberryless <99918022+trueberryless@users.noreply.github.com>
Co-authored-by: Kevin <46791833+kevinzunigacuellar@users.noreply.github.com>
Co-authored-by: Jacob Jenkins <7649031+jdtjenkins@users.noreply.github.com>
Co-authored-by: Bryce Russell <19967622+BryceRussell@users.noreply.github.com>
Co-authored-by: Lorenzo Lewis <15347255+lorenzolewis@users.noreply.github.com>
  • Loading branch information
14 people committed Jun 5, 2024
1 parent ee0cd38 commit 081d1a9
Show file tree
Hide file tree
Showing 33 changed files with 113 additions and 29 deletions.
5 changes: 5 additions & 0 deletions .changeset/sharp-crabs-sparkle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/starlight': minor
---

Allows users to opt into displaying a “Built with Starlight” link in the site footer
10 changes: 10 additions & 0 deletions docs/src/content/docs/reference/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -569,3 +569,13 @@ starlight({
```

See the [Plugins Reference](/reference/plugins/) for details about creating your own plugins.

### `credits`

Enable displaying a “Built with Starlight” link in your site’s footer.

```js
starlight({
credits: true,
});
```
1 change: 1 addition & 0 deletions packages/starlight/__tests__/basics/config-errors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ test('parses valid config successfully', () => {
"ThemeSelect": "@astrojs/starlight/components/ThemeSelect.astro",
"TwoColumnContent": "@astrojs/starlight/components/TwoColumnContent.astro",
},
"credits": false,
"customCss": [],
"defaultLocale": {
"dir": "ltr",
Expand Down
33 changes: 31 additions & 2 deletions packages/starlight/components/Footer.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,55 @@ import type { Props } from '../props';
import EditLink from 'virtual:starlight/components/EditLink';
import LastUpdated from 'virtual:starlight/components/LastUpdated';
import Pagination from 'virtual:starlight/components/Pagination';
import config from 'virtual:starlight/user-config';
import { Icon } from '../components';
---

<footer>
<footer class="sl-flex">
<div class="meta sl-flex">
<EditLink {...Astro.props} />
<LastUpdated {...Astro.props} />
</div>
<Pagination {...Astro.props} />

{
config.credits && (
<a class="kudos sl-flex" href="https://starlight.astro.build">
<Icon name={'starlight'} /> {Astro.props.labels['builtWithStarlight.label']}
</a>
)
}
</footer>

<style>
footer {
flex-direction: column;
gap: 1.5rem;
}
.meta {
gap: 0.75rem 3rem;
justify-content: space-between;
flex-wrap: wrap;
margin-block: 3rem 1.5rem;
margin-top: 3rem;
font-size: var(--sl-text-sm);
color: var(--sl-color-gray-3);
}
.meta > :global(p:only-child) {
margin-inline-start: auto;
}

.kudos {
align-items: center;
gap: 0.5em;
margin: 1.5rem auto;
font-size: var(--sl-text-xs);
text-decoration: none;
color: var(--sl-color-gray-3);
}
.kudos :global(svg) {
color: var(--sl-color-orange);
}
.kudos:hover {
color: var(--sl-color-white);
}
</style>
6 changes: 6 additions & 0 deletions packages/starlight/schemas/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ function starlightI18nSchema() {
'fileTree.directory': z
.string()
.describe('Label for the directory icon in the file tree component.'),

'builtWithStarlight.label': z
.string()
.describe(
'Label for the “Built with Starlight” badge optionally displayed in the site footer.'
),
})
.partial();
}
Expand Down
3 changes: 2 additions & 1 deletion packages/starlight/translations/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
"aside.tip": "نصيحة",
"aside.caution": "تنبيه",
"aside.danger": "تحذير",
"fileTree.directory": "Directory"
"fileTree.directory": "Directory",
"builtWithStarlight.label": "Built with Starlight"
}
3 changes: 2 additions & 1 deletion packages/starlight/translations/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
"aside.tip": "Tip",
"aside.caution": "Caution",
"aside.danger": "Danger",
"fileTree.directory": "Directory"
"fileTree.directory": "Directory",
"builtWithStarlight.label": "Built with Starlight"
}
3 changes: 2 additions & 1 deletion packages/starlight/translations/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
"aside.tip": "Tip",
"aside.caution": "Caution",
"aside.danger": "Danger",
"fileTree.directory": "Directory"
"fileTree.directory": "Directory",
"builtWithStarlight.label": "Built with Starlight"
}
3 changes: 2 additions & 1 deletion packages/starlight/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
"aside.tip": "Tipp",
"aside.caution": "Achtung",
"aside.danger": "Gefahr",
"fileTree.directory": "Directory"
"fileTree.directory": "Directory",
"builtWithStarlight.label": "Erstellt mit Starlight"
}
3 changes: 2 additions & 1 deletion packages/starlight/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
"aside.tip": "Tip",
"aside.caution": "Caution",
"aside.danger": "Danger",
"fileTree.directory": "Directory"
"fileTree.directory": "Directory",
"builtWithStarlight.label": "Built with Starlight"
}
3 changes: 2 additions & 1 deletion packages/starlight/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@
"expressiveCode.copyButtonCopied": "¡Copiado!",
"expressiveCode.copyButtonTooltip": "Copiar al portapapeles",
"expressiveCode.terminalWindowFallbackTitle": "Ventana de terminal",
"fileTree.directory": "Directory"
"fileTree.directory": "Directory",
"builtWithStarlight.label": "Hecho con Starlight"
}
3 changes: 2 additions & 1 deletion packages/starlight/translations/fa.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
"aside.tip": "نکته",
"aside.caution": "احتیاط",
"aside.danger": "خطر",
"fileTree.directory": "فهرست"
"fileTree.directory": "فهرست",
"builtWithStarlight.label": "Built with Starlight"
}
3 changes: 2 additions & 1 deletion packages/starlight/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@
"expressiveCode.copyButtonCopied": "Copié !",
"expressiveCode.copyButtonTooltip": "Copier dans le presse-papiers",
"expressiveCode.terminalWindowFallbackTitle": "Fenêtre de terminal",
"fileTree.directory": "Répertoire"
"fileTree.directory": "Répertoire",
"builtWithStarlight.label": "Créé avec Starlight"
}
3 changes: 2 additions & 1 deletion packages/starlight/translations/gl.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
"aside.tip": "Tip",
"aside.caution": "Caution",
"aside.danger": "Danger",
"fileTree.directory": "Directory"
"fileTree.directory": "Directory",
"builtWithStarlight.label": "Built with Starlight"
}
3 changes: 2 additions & 1 deletion packages/starlight/translations/he.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
"aside.tip": "Tip",
"aside.caution": "Caution",
"aside.danger": "Danger",
"fileTree.directory": "Directory"
"fileTree.directory": "Directory",
"builtWithStarlight.label": "Built with Starlight"
}
3 changes: 2 additions & 1 deletion packages/starlight/translations/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
"aside.tip": "संकेत",
"aside.caution": "सावधानी",
"aside.danger": "खतरा",
"fileTree.directory": "Directory"
"fileTree.directory": "Directory",
"builtWithStarlight.label": "Starlight द्वारा निर्मित"
}
3 changes: 2 additions & 1 deletion packages/starlight/translations/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
"aside.tip": "Tips",
"aside.caution": "Perhatian",
"aside.danger": "Bahaya",
"fileTree.directory": "Directory"
"fileTree.directory": "Directory",
"builtWithStarlight.label": "Built with Starlight"
}
3 changes: 2 additions & 1 deletion packages/starlight/translations/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
"aside.tip": "Consiglio",
"aside.caution": "Attenzione",
"aside.danger": "Pericolo",
"fileTree.directory": "Directory"
"fileTree.directory": "Directory",
"builtWithStarlight.label": "Built with Starlight"
}
3 changes: 2 additions & 1 deletion packages/starlight/translations/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
"aside.tip": "ヒント",
"aside.caution": "注意",
"aside.danger": "危険",
"fileTree.directory": "ディレクトリ"
"fileTree.directory": "ディレクトリ",
"builtWithStarlight.label": "Built with Starlight"
}
3 changes: 2 additions & 1 deletion packages/starlight/translations/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
"aside.tip": "",
"aside.caution": "주의",
"aside.danger": "위험",
"fileTree.directory": "Directory"
"fileTree.directory": "Directory",
"builtWithStarlight.label": "Built with Starlight"
}
3 changes: 2 additions & 1 deletion packages/starlight/translations/nb.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
"aside.tip": "Tip",
"aside.caution": "Caution",
"aside.danger": "Danger",
"fileTree.directory": "Directory"
"fileTree.directory": "Directory",
"builtWithStarlight.label": "Laget med Starlight"
}
3 changes: 2 additions & 1 deletion packages/starlight/translations/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
"aside.tip": "Tip",
"aside.caution": "Opgepast",
"aside.danger": "Gevaar",
"fileTree.directory": "Directory"
"fileTree.directory": "Directory",
"builtWithStarlight.label": "Built with Starlight"
}
3 changes: 2 additions & 1 deletion packages/starlight/translations/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@
"fileTree.directory": "Folder",
"expressiveCode.copyButtonCopied": "Skopiowane!",
"expressiveCode.copyButtonTooltip": "Skopiuj do schowka",
"expressiveCode.terminalWindowFallbackTitle": "Okno terminala"
"expressiveCode.terminalWindowFallbackTitle": "Okno terminala",
"builtWithStarlight.label": "Built with Starlight"
}
3 changes: 2 additions & 1 deletion packages/starlight/translations/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
"aside.tip": "Dica",
"aside.caution": "Cuidado",
"aside.danger": "Perigo",
"fileTree.directory": "Directory"
"fileTree.directory": "Directory",
"builtWithStarlight.label": "Feito com Starlight"
}
3 changes: 2 additions & 1 deletion packages/starlight/translations/ro.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
"aside.tip": "Sfat",
"aside.caution": "Atenție",
"aside.danger": "Pericol",
"fileTree.directory": "Directory"
"fileTree.directory": "Directory",
"builtWithStarlight.label": "Built with Starlight"
}
3 changes: 2 additions & 1 deletion packages/starlight/translations/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@
"fileTree.directory": "Директория",
"expressiveCode.copyButtonCopied": "Скопировано!",
"expressiveCode.copyButtonTooltip": "Копировать",
"expressiveCode.terminalWindowFallbackTitle": "Окно терминала"
"expressiveCode.terminalWindowFallbackTitle": "Окно терминала",
"builtWithStarlight.label": "Built with Starlight"
}
3 changes: 2 additions & 1 deletion packages/starlight/translations/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
"aside.tip": "Tip",
"aside.caution": "Caution",
"aside.danger": "Danger",
"fileTree.directory": "Directory"
"fileTree.directory": "Directory",
"builtWithStarlight.label": "Built with Starlight"
}
3 changes: 2 additions & 1 deletion packages/starlight/translations/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
"aside.tip": "İpucu",
"aside.caution": "Dikkat",
"aside.danger": "Tehlike",
"fileTree.directory": "Dizin"
"fileTree.directory": "Dizin",
"builtWithStarlight.label": "Built with Starlight"
}
3 changes: 2 additions & 1 deletion packages/starlight/translations/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
"aside.tip": "Порада",
"aside.caution": "Обережно",
"aside.danger": "Небезпечно",
"fileTree.directory": "Directory"
"fileTree.directory": "Directory",
"builtWithStarlight.label": "Built with Starlight"
}
3 changes: 2 additions & 1 deletion packages/starlight/translations/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
"aside.tip": "Mẹo",
"aside.caution": "Thận trọng",
"aside.danger": "Nguy hiểm",
"fileTree.directory": "Danh mục"
"fileTree.directory": "Danh mục",
"builtWithStarlight.label": "Built with Starlight"
}
3 changes: 2 additions & 1 deletion packages/starlight/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
"aside.tip": "提示",
"aside.caution": "警告",
"aside.danger": "危险",
"fileTree.directory": "文件夹"
"fileTree.directory": "文件夹",
"builtWithStarlight.label": "基于 Starlight 构建"
}
3 changes: 2 additions & 1 deletion packages/starlight/translations/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
"aside.tip": "提示",
"aside.caution": "警告",
"aside.danger": "危險",
"fileTree.directory": "目錄"
"fileTree.directory": "目錄",
"builtWithStarlight.label": "Built with Starlight"
}
6 changes: 6 additions & 0 deletions packages/starlight/utils/user-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,12 @@ const UserConfigSchema = z.object({

/** Disable Starlight's default 404 page. */
disable404Route: z.boolean().default(false).describe("Disable Starlight's default 404 page."),

/** Enable displaying a “Built with Starlight” link in your site’s footer. */
credits: z
.boolean()
.default(false)
.describe('Enable displaying a “Built with Starlight” link in your site’s footer.'),
});

export const StarlightConfigSchema = UserConfigSchema.strict().transform(
Expand Down

0 comments on commit 081d1a9

Please sign in to comment.