Skip to content

Commit

Permalink
Merge branch 'main' into update-components
Browse files Browse the repository at this point in the history
  • Loading branch information
HiDeoo authored Jan 29, 2024
2 parents 95e9d63 + a0af7cc commit 4649e7f
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/cuddly-lions-warn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@astrojs/starlight": patch
---

Fix rare `font-family` issue if users have a font installed with a name of `""`
5 changes: 5 additions & 0 deletions .changeset/silver-dots-guess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/starlight': patch
---

Correctly format Pagefind search result links when `trailingSlash: 'never'` is used
2 changes: 1 addition & 1 deletion docs/src/content/docs/ko/reference/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ starlight({
**타입:** `boolean`
**기본값:** `false`

Starlight의 기본 [404 페이지](https://docs.astro.build/ko/core-concepts/astro-pages/#사용자-정의-404-오류-페이지) 삽입을 비활성화합니다. 프로젝트에서 사용자 정의 `src/pages/404.astro` 경로를 사용하려면 이 옵션을 `false`로 설정하세요.
Starlight의 기본 [404 페이지](https://docs.astro.build/ko/core-concepts/astro-pages/#사용자-정의-404-오류-페이지) 삽입을 비활성화합니다. 프로젝트에서 사용자 정의 `src/pages/404.astro` 경로를 사용하려면 이 옵션을 `true`로 설정하세요.

### `components`

Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/reference/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ For example, this page is titled “Configuration Reference” and this site is
**type:** `boolean`
**default:** `false`

Disables injecting Starlight's default [404 page](https://docs.astro.build/en/core-concepts/astro-pages/#custom-404-error-page). To use a custom `src/pages/404.astro` route in your project, set this option to `false`.
Disables injecting Starlight's default [404 page](https://docs.astro.build/en/core-concepts/astro-pages/#custom-404-error-page). To use a custom `src/pages/404.astro` route in your project, set this option to `true`.

### `components`

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
{
"name": "/_astro/*.js",
"path": "examples/basics/dist/_astro/*.js",
"limit": "22 kB"
"limit": "22.5 kB"
},
{
"name": "/_astro/*.css",
Expand Down
18 changes: 17 additions & 1 deletion packages/starlight/components/Search.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
import '@pagefind/default-ui/css/ui.css';
import Icon from '../user-components/Icon.astro';
import project from 'virtual:starlight/project-context';
import type { Props } from '../props';
const { labels } = Astro.props;
Expand All @@ -15,7 +16,10 @@ const pagefindTranslations = {
};
---

<site-search data-translations={JSON.stringify(pagefindTranslations)}>
<site-search
data-translations={JSON.stringify(pagefindTranslations)}
data-strip-trailing-slash={project.trailingSlash === 'never'}
>
<button data-open-modal disabled>
{
/* The span is `aria-hidden` because it is not shown on small screens. Instead, the icon label is used for accessibility purposes. */
Expand Down Expand Up @@ -112,10 +116,15 @@ const pagefindTranslations = {
translations = JSON.parse(this.dataset.translations || '{}');
} catch {}

const shouldStrip = this.dataset.stripTrailingSlash !== undefined;
const stripTrailingSlash = (path: string) => path.replace(/(.)\/(#.*)?$/, '$1$2');
const formatURL = shouldStrip ? stripTrailingSlash : (path: string) => path;

window.addEventListener('DOMContentLoaded', () => {
if (import.meta.env.DEV) return;
const onIdle = window.requestIdleCallback || ((cb) => setTimeout(cb, 1));
onIdle(async () => {
// @ts-expect-error — Missing types for @pagefind/default-ui package.
const { PagefindUI } = await import('@pagefind/default-ui');
new PagefindUI({
element: '#starlight__search',
Expand All @@ -124,6 +133,13 @@ const pagefindTranslations = {
showImages: false,
translations,
showSubResults: true,
processResult: (result: { url: string; sub_results: Array<{ url: string }> }) => {
result.url = formatURL(result.url);
result.sub_results = result.sub_results.map((sub_result) => {
sub_result.url = formatURL(sub_result.url);
return sub_result;
});
},
});
});
});
Expand Down
4 changes: 2 additions & 2 deletions packages/starlight/style/props.css
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@
'Segoe UI Symbol', 'Noto Color Emoji';
--sl-font-system-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono',
'Courier New', monospace;
--__sl-font: var(--sl-font, ''), var(--sl-font-system);
--__sl-font-mono: var(--sl-font-mono, ''), var(--sl-font-system-mono);
--__sl-font: var(--sl-font, var(--sl-font-system)), var(--sl-font-system);
--__sl-font-mono: var(--sl-font-mono, var(--sl-font-system-mono)), var(--sl-font-system-mono);

/** Key layout values */
--sl-nav-height: 3.5rem;
Expand Down

0 comments on commit 4649e7f

Please sign in to comment.