Skip to content

Commit

Permalink
Merge branch 'main' into hd-file-tree
Browse files Browse the repository at this point in the history
* main:
  [ci] format
  [ci] release (withastro#1555)
  Update lockfile & patch version of EC to latest (withastro#1553)
  [ci] format
  [ci] release (withastro#1546)
  Improve Zod errors (withastro#1542)
  Update `astro-expressive-code` dependency to `^0.33.2` (withastro#1541)
  i18n(ja): Update pages.mdx (withastro#1551)
  i18n(es): update `plugins` (withastro#1548)
  • Loading branch information
HiDeoo committed Feb 26, 2024
2 parents 60e79b2 + 2ae17a5 commit 666ea8b
Show file tree
Hide file tree
Showing 17 changed files with 527 additions and 207 deletions.
5 changes: 0 additions & 5 deletions .changeset/spotty-hairs-care.md

This file was deleted.

35 changes: 25 additions & 10 deletions docs/src/content/docs/es/resources/plugins.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,26 @@ Amplia tu sitio con un plugins oficiales respaldados por el equipo de Starlight
title="starlight-typedoc"
description="Genera páginas de Starlight desde TypeScript usando TypeDoc"
/>
<LinkCard
href="https://github.com/HiDeoo/starlight-blog"
title="starlight-blog"
description="Agrega un blog a tu sitio de documentación."
/>
<LinkCard
href="https://github.com/HiDeoo/starlight-openapi"
title="starlight-openapi"
description="Crea páginas de documentación a partir de especificaciones OpenAPI/Swagger."
/>
<LinkCard
href="https://github.com/HiDeoo/starlight-obsidian"
title="starlight-obsidian"
description="Publica bóvedas de Obsidian en tu sitio de Starlight."
/>
<LinkCard
href="https://astro-ghostcms.xyz/intro/starlight/install/"
title="starlight-ghostcms"
description="Agrega tus publicaciones de blog de GhostCMS junto con tus documentos de Starlight."
/>
</CardGrid>

## Herramientas e integraciones de la comunidad
Expand All @@ -52,16 +72,6 @@ Estas herramientas e integraciones de la comunidad se pueden utilizar para añad
title="FeelBack"
description="Agrega un sistema de comentarios de usuarios a la páginas de tus docs."
/>
<LinkCard
href="https://github.com/HiDeoo/starlight-blog"
title="starlight-blog"
description="Agrega un blog a tu sitio de documentación."
/>
<LinkCard
href="https://github.com/HiDeoo/starlight-openapi"
title="starlight-openapi"
description="Crea páginas de documentación a partir de especificaciones OpenAPI/Swagger."
/>
<LinkCard
href="https://github.com/val-town/notion-to-astro"
title="notion-to-astro"
Expand All @@ -72,4 +82,9 @@ Estas herramientas e integraciones de la comunidad se pueden utilizar para añad
title="astro-live-code"
description="Renderiza bloques de código MDX como componentes interactivos."
/>
<LinkCard
href="https://github.com/HiDeoo/starlight-i18n"
title="starlight-i18n"
description="Extensión de Visual Studio Code para ayudar a traducir páginas de Starlight."
/>
</CardGrid>
38 changes: 29 additions & 9 deletions docs/src/content/docs/ja/guides/pages.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,35 @@ import CustomComponent from './CustomComponent.astro';

- [`slug`](/ja/reference/frontmatter/#slug)プロパティはサポートされておらず、カスタムページのURLに基づいて自動的に設定されます。
- [`editUrl`](/ja/reference/frontmatter/#editurl)オプションは、編集リンクを表示するためのURLが必要です。
- [`sidebar`](/ja/reference/frontmatter/#sidebar)プロパティはサポートされていません。Markdownのフロントマターでは、このオプションは[自動生成されるリンクグループ](/ja/reference/configuration/#sidebar)のカスタマイズを可能にしますが、`<StarlightPage />`コンポーネントを使用するページには適用されません。

{/* ##### `sidebar` */}

{/* **type:** `SidebarEntry[] | undefined` */}
{/* **default:** the sidebar generated based on the [global `sidebar` config](/reference/configuration/#sidebar) */}

{/* Provide a custom site navigation sidebar for this page. */}
{/* If not set, the page will use the default global sidebar. */}
- [自動生成されるリンクグループ](/ja/reference/configuration/#sidebar)にページを表示する方法をカスタマイズするための[`sidebar`](/ja/reference/frontmatter/#sidebar)フロントマタープロパティは利用できません。`<StarlightPage />`コンポーネントを使用するページはコレクションの一部ではなく、自動生成されるサイドバーグループには追加できません。

##### `sidebar`

**type:** `SidebarEntry[]`
**default:** [グローバルな`sidebar`設定値](/ja/reference/configuration/#sidebar)に基づき生成されるサイドバー

ページにカスタムのサイトナビゲーションサイドバーを設定します。未設定の場合、ページはデフォルトのグローバルサイドバーを使用します。

たとえば以下のページは、ホームページへのリンクと星座へのリンクグループによりデフォルトのサイドバーをオーバーライドします。サイドバーの現在のページは`isCurrent`プロパティを使用して設定され、またリンクアイテムにオプションの`badge`が追加されています。

```astro {3-13}
<StarlightPage
frontmatter={{ title: 'オリオン座' }}
sidebar={[
{ label: 'ホーム', href: '/' },
{
label: '星座',
items: [
{ label: 'アンドロメダ座', href: '/andromeda/' },
{ label: 'オリオン座', href: '/orion/', isCurrent: true },
{ label: 'こぐま座', href: '/ursa-minor/', badge: 'スタブ' },
],
},
]}
>
何らかのコンテンツ。
</StarlightPage>
```

##### `hasSidebar`

Expand Down
2 changes: 1 addition & 1 deletion examples/basics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/starlight": "^0.19.1",
"@astrojs/starlight": "^0.20.1",
"astro": "^4.3.5",
"sharp": "^0.32.5"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/tailwind/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/starlight": "^0.19.1",
"@astrojs/starlight": "^0.20.1",
"@astrojs/starlight-tailwind": "^2.0.1",
"@astrojs/tailwind": "^5.1.0",
"astro": "^4.3.5",
Expand Down
22 changes: 22 additions & 0 deletions packages/starlight/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# @astrojs/starlight

## 0.20.1

### Patch Changes

- [#1553](https://github.com/withastro/starlight/pull/1553) [`8e091147`](https://github.com/withastro/starlight/commit/8e09114755d37322d6e97b0dc90a5dfd781de8cc) Thanks [@hippotastic](https://github.com/hippotastic)! - Updates Expressive Code to v0.33.4 to fix potential race condition bug in Shiki.

## 0.20.0

### Minor Changes

- [#1541](https://github.com/withastro/starlight/pull/1541) [`1043052f`](https://github.com/withastro/starlight/commit/1043052f3890a577a73276472f3773924909406b) Thanks [@hippotastic](https://github.com/hippotastic)! - Updates `astro-expressive-code` dependency to the latest minor release (0.33).

This unlocks support for [word wrap](https://expressive-code.com/key-features/word-wrap/) and [line numbers](https://expressive-code.com/plugins/line-numbers/), as well as updating the syntax highlighter to the latest Shiki release, which includes new and updated language grammars.

See the [Expressive Code release notes](https://expressive-code.com/releases/) for more information including details of potentially breaking changes.

### Patch Changes

- [#1542](https://github.com/withastro/starlight/pull/1542) [`b3b7a606`](https://github.com/withastro/starlight/commit/b3b7a6069952d5f27a49b2fd097aa4db065e1718) Thanks [@delucis](https://github.com/delucis)! - Improves error messages shown by Starlight for configuration errors.

- [#1544](https://github.com/withastro/starlight/pull/1544) [`65dc6586`](https://github.com/withastro/starlight/commit/65dc6586ef7c1754875db1d48c49e709051a0b13) Thanks [@torn4dom4n](https://github.com/torn4dom4n)! - Update Vietnamese UI translations

## 0.19.1

### Patch Changes
Expand Down
189 changes: 189 additions & 0 deletions packages/starlight/__tests__/basics/config-errors.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
import { expect, test } from 'vitest';
import { parseWithFriendlyErrors } from '../../utils/error-map';
import { StarlightConfigSchema, type StarlightUserConfig } from '../../utils/user-config';

function parseStarlightConfigWithFriendlyErrors(config: StarlightUserConfig) {
return parseWithFriendlyErrors(
StarlightConfigSchema,
config,
'Invalid config passed to starlight integration'
);
}

test('parses valid config successfully', () => {
const data = parseStarlightConfigWithFriendlyErrors({ title: '' });
expect(data).toMatchInlineSnapshot(`
{
"components": {
"Banner": "@astrojs/starlight/components/Banner.astro",
"ContentPanel": "@astrojs/starlight/components/ContentPanel.astro",
"EditLink": "@astrojs/starlight/components/EditLink.astro",
"FallbackContentNotice": "@astrojs/starlight/components/FallbackContentNotice.astro",
"Footer": "@astrojs/starlight/components/Footer.astro",
"Head": "@astrojs/starlight/components/Head.astro",
"Header": "@astrojs/starlight/components/Header.astro",
"Hero": "@astrojs/starlight/components/Hero.astro",
"LanguageSelect": "@astrojs/starlight/components/LanguageSelect.astro",
"LastUpdated": "@astrojs/starlight/components/LastUpdated.astro",
"MarkdownContent": "@astrojs/starlight/components/MarkdownContent.astro",
"MobileMenuFooter": "@astrojs/starlight/components/MobileMenuFooter.astro",
"MobileMenuToggle": "@astrojs/starlight/components/MobileMenuToggle.astro",
"MobileTableOfContents": "@astrojs/starlight/components/MobileTableOfContents.astro",
"PageFrame": "@astrojs/starlight/components/PageFrame.astro",
"PageSidebar": "@astrojs/starlight/components/PageSidebar.astro",
"PageTitle": "@astrojs/starlight/components/PageTitle.astro",
"Pagination": "@astrojs/starlight/components/Pagination.astro",
"Search": "@astrojs/starlight/components/Search.astro",
"Sidebar": "@astrojs/starlight/components/Sidebar.astro",
"SiteTitle": "@astrojs/starlight/components/SiteTitle.astro",
"SkipLink": "@astrojs/starlight/components/SkipLink.astro",
"SocialIcons": "@astrojs/starlight/components/SocialIcons.astro",
"TableOfContents": "@astrojs/starlight/components/TableOfContents.astro",
"ThemeProvider": "@astrojs/starlight/components/ThemeProvider.astro",
"ThemeSelect": "@astrojs/starlight/components/ThemeSelect.astro",
"TwoColumnContent": "@astrojs/starlight/components/TwoColumnContent.astro",
},
"customCss": [],
"defaultLocale": {
"dir": "ltr",
"label": "English",
"lang": "en",
"locale": undefined,
},
"disable404Route": false,
"editLink": {},
"favicon": {
"href": "/favicon.svg",
"type": "image/svg+xml",
},
"head": [],
"isMultilingual": false,
"lastUpdated": false,
"locales": undefined,
"pagefind": true,
"pagination": true,
"tableOfContents": {
"maxHeadingLevel": 3,
"minHeadingLevel": 2,
},
"title": "",
"titleDelimiter": "|",
}
`);
});

test('errors if title is missing', () => {
expect(() =>
parseStarlightConfigWithFriendlyErrors({} as any)
).toThrowErrorMatchingInlineSnapshot(
`
"[AstroUserError]:
Invalid config passed to starlight integration
Hint:
**title**: Required"
`
);
});

test('errors if title value is not a string', () => {
expect(() =>
parseStarlightConfigWithFriendlyErrors({ title: 5 } as any)
).toThrowErrorMatchingInlineSnapshot(
`
"[AstroUserError]:
Invalid config passed to starlight integration
Hint:
**title**: Expected type \`"string"\`, received \`"number"\`"
`
);
});

test('errors with bad social icon config', () => {
expect(() =>
parseStarlightConfigWithFriendlyErrors({ title: 'Test', social: { unknown: '' } as any })
).toThrowErrorMatchingInlineSnapshot(
`
"[AstroUserError]:
Invalid config passed to starlight integration
Hint:
**social.unknown**: Invalid enum value. Expected 'twitter' | 'mastodon' | 'github' | 'gitlab' | 'bitbucket' | 'discord' | 'gitter' | 'codeberg' | 'codePen' | 'youtube' | 'threads' | 'linkedin' | 'twitch' | 'microsoftTeams' | 'instagram' | 'stackOverflow' | 'x.com' | 'telegram' | 'rss' | 'facebook' | 'email' | 'reddit' | 'patreon' | 'slack' | 'matrix' | 'openCollective', received 'unknown'
**social.unknown**: Invalid url"
`
);
});

test('errors with bad logo config', () => {
expect(() =>
parseStarlightConfigWithFriendlyErrors({ title: 'Test', logo: { html: '' } as any })
).toThrowErrorMatchingInlineSnapshot(
`
"[AstroUserError]:
Invalid config passed to starlight integration
Hint:
**logo**: Did not match union.
> Expected type \`{ src: string } | { dark: string; light: string }\`
> Received \`{ "html": "" }\`"
`
);
});

test('errors with bad head config', () => {
expect(() =>
parseStarlightConfigWithFriendlyErrors({
title: 'Test',
head: [{ tag: 'unknown', attrs: { prop: null }, content: 20 } as any],
})
).toThrowErrorMatchingInlineSnapshot(
`
"[AstroUserError]:
Invalid config passed to starlight integration
Hint:
**head.0.tag**: Invalid enum value. Expected 'title' | 'base' | 'link' | 'style' | 'meta' | 'script' | 'noscript' | 'template', received 'unknown'
**head.0.attrs.prop**: Did not match union.
> Expected type \`"string" | "boolean" | "undefined"\`, received \`"null"\`
**head.0.content**: Expected type \`"string"\`, received \`"number"\`"
`
);
});

test('errors with bad sidebar config', () => {
expect(() =>
parseStarlightConfigWithFriendlyErrors({
title: 'Test',
sidebar: [{ label: 'Example', href: '/' } as any],
})
).toThrowErrorMatchingInlineSnapshot(
`
"[AstroUserError]:
Invalid config passed to starlight integration
Hint:
**sidebar.0**: Did not match union.
> Expected type \`{ link: string } | { items: array } | { autogenerate: object }\`
> Received \`{ "label": "Example", "href": "/" }\`"
`
);
});

test('errors with bad nested sidebar config', () => {
expect(() =>
parseStarlightConfigWithFriendlyErrors({
title: 'Test',
sidebar: [
{
label: 'Example',
items: [
{ label: 'Nested Example 1', link: '/' },
{ label: 'Nested Example 2', link: true },
],
} as any,
],
})
).toThrowErrorMatchingInlineSnapshot(`
"[AstroUserError]:
Invalid config passed to starlight integration
Hint:
**sidebar.0.items.1**: Did not match union.
> Expected type \`{ link: string } | { items: array } | { autogenerate: object }\`
> Received \`{ "label": "Example", "items": [ { "label": "Nested Example 1", "link": "/" }, { "label": "Nested Example 2", "link": true } ] }\`"
`);
});
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,19 @@ const starlightPageProps: StarlightPageProps = {
};

test('throws a validation error if a built-in field required by the user schema is not passed down', async () => {
expect.assertions(3);

try {
await generateStarlightPageRouteData({
// The first line should be a user-friendly error message describing the exact issue and the second line should be
// the missing description field.
expect(() =>
generateStarlightPageRouteData({
props: starlightPageProps,
url: new URL('https://example.com/test-slug'),
});
} catch (error) {
assert(error instanceof Error);
const lines = error.message.split('\n');
// The first line should be a user-friendly error message describing the exact issue and the second line should be
// the missing description field.
expect(lines).toHaveLength(2);
const [message, missingField] = lines;
expect(message).toMatchInlineSnapshot(
`"Invalid frontmatter props passed to the \`<StarlightPage/>\` component."`
);
expect(missingField).toMatchInlineSnapshot(`"**description**: Required"`);
}
})
).rejects.toThrowErrorMatchingInlineSnapshot(`
"[AstroUserError]:
Invalid frontmatter props passed to the \`<StarlightPage/>\` component.
Hint:
**description**: Required"
`);
});

test('returns new field defined in the user schema', async () => {
Expand Down
Loading

0 comments on commit 666ea8b

Please sign in to comment.