-
-
Notifications
You must be signed in to change notification settings - Fork 554
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into asides-i18n
- Loading branch information
Showing
12 changed files
with
256 additions
and
140 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
packages/starlight/__tests__/sidebar/navigation-unicode.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
import { describe, expect, test, vi } from 'vitest'; | ||
import { getSidebar } from '../../utils/navigation'; | ||
|
||
vi.mock('astro:content', async () => | ||
(await import('../test-utils')).mockedAstroContent({ | ||
docs: [ | ||
['index.mdx', { title: 'Home Page' }], | ||
['environmental-impact.md', { title: 'Eco-friendly docs' }], | ||
['reference/configuration.mdx', { title: 'Config Reference' }], | ||
['reference/frontmatter.md', { title: 'Frontmatter Reference' }], | ||
// @ts-expect-error — Using a slug not present in Starlight docs site | ||
['api/v1/用户.md', { title: 'Path with non-ASCII characters' }], | ||
['guides/components.mdx', { title: 'Components' }], | ||
], | ||
}) | ||
); | ||
|
||
describe('getSidebar', () => { | ||
test('matches current page when path contains non-ascii characters', () => { | ||
expect(getSidebar('/api/v1/%E7%94%A8%E6%88%B7', undefined)).toMatchInlineSnapshot(` | ||
[ | ||
{ | ||
"attrs": {}, | ||
"badge": undefined, | ||
"href": "/", | ||
"isCurrent": false, | ||
"label": "Home", | ||
"type": "link", | ||
}, | ||
{ | ||
"badge": undefined, | ||
"collapsed": false, | ||
"entries": [ | ||
{ | ||
"attrs": {}, | ||
"badge": { | ||
"text": "New", | ||
"variant": "success", | ||
}, | ||
"href": "/intro/", | ||
"isCurrent": false, | ||
"label": "Introduction", | ||
"type": "link", | ||
}, | ||
{ | ||
"attrs": {}, | ||
"badge": { | ||
"text": "Deprecated", | ||
"variant": "default", | ||
}, | ||
"href": "/next-steps/", | ||
"isCurrent": false, | ||
"label": "Next Steps", | ||
"type": "link", | ||
}, | ||
{ | ||
"attrs": { | ||
"class": "showcase-link", | ||
"target": "_blank", | ||
}, | ||
"badge": undefined, | ||
"href": "/showcase/", | ||
"isCurrent": false, | ||
"label": "Showcase", | ||
"type": "link", | ||
}, | ||
], | ||
"label": "Start Here", | ||
"type": "group", | ||
}, | ||
{ | ||
"badge": { | ||
"text": "Experimental", | ||
"variant": "default", | ||
}, | ||
"collapsed": false, | ||
"entries": [ | ||
{ | ||
"attrs": {}, | ||
"badge": undefined, | ||
"href": "/reference/configuration/", | ||
"isCurrent": false, | ||
"label": "Config Reference", | ||
"type": "link", | ||
}, | ||
{ | ||
"attrs": {}, | ||
"badge": undefined, | ||
"href": "/reference/frontmatter/", | ||
"isCurrent": false, | ||
"label": "Frontmatter Reference", | ||
"type": "link", | ||
}, | ||
], | ||
"label": "Reference", | ||
"type": "group", | ||
}, | ||
{ | ||
"badge": undefined, | ||
"collapsed": false, | ||
"entries": [ | ||
{ | ||
"attrs": {}, | ||
"badge": undefined, | ||
"href": "/api/v1/用户/", | ||
"isCurrent": true, | ||
"label": "Path with non-ASCII characters", | ||
"type": "link", | ||
}, | ||
], | ||
"label": "API v1", | ||
"type": "group", | ||
}, | ||
] | ||
`); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,127 +1,6 @@ | ||
--- | ||
import type { Props } from '../props'; | ||
import '../style/markdown.css'; | ||
--- | ||
|
||
<div class="content"><slot /></div> | ||
|
||
<style> | ||
.content | ||
:global( | ||
:not(a, strong, em, del, span, input, code) | ||
+ :not(a, strong, em, del, span, input, code, :where(.not-content *)) | ||
) { | ||
margin-top: 1.5rem; | ||
} | ||
|
||
/* Headings after non-headings have more spacing. */ | ||
.content | ||
:global( | ||
:not(h1, h2, h3, h4, h5, h6) + :is(h1, h2, h3, h4, h5, h6):not(:where(.not-content *)) | ||
) { | ||
margin-top: 2.5rem; | ||
} | ||
|
||
.content :global(li + li:not(:where(.not-content *))), | ||
.content :global(dt + dt:not(:where(.not-content *))), | ||
.content :global(dt + dd:not(:where(.not-content *))), | ||
.content :global(dd + dd:not(:where(.not-content *))) { | ||
margin-top: 0.25rem; | ||
} | ||
|
||
.content | ||
:global( | ||
li > :last-child:not(li, ul, ol):not(a, strong, em, del, span, input, :where(.not-content *)) | ||
) { | ||
margin-bottom: 1.25rem; | ||
} | ||
|
||
.content :global(dt:not(:where(.not-content *))) { | ||
font-weight: 700; | ||
} | ||
.content :global(dd:not(:where(.not-content *))) { | ||
padding-inline-start: 1rem; | ||
} | ||
|
||
.content :global(:is(h1, h2, h3, h4, h5, h6):not(:where(.not-content *))) { | ||
color: var(--sl-color-white); | ||
line-height: var(--sl-line-height-headings); | ||
font-weight: 600; | ||
} | ||
|
||
.content :global(:is(img, picture, video, canvas, svg, iframe):not(:where(.not-content *))) { | ||
display: block; | ||
max-width: 100%; | ||
height: auto; | ||
} | ||
|
||
.content :global(h1:not(:where(.not-content *))) { | ||
font-size: var(--sl-text-h1); | ||
} | ||
.content :global(h2:not(:where(.not-content *))) { | ||
font-size: var(--sl-text-h2); | ||
} | ||
.content :global(h3:not(:where(.not-content *))) { | ||
font-size: var(--sl-text-h3); | ||
} | ||
.content :global(h4:not(:where(.not-content *))) { | ||
font-size: var(--sl-text-h4); | ||
} | ||
.content :global(h5:not(:where(.not-content *))) { | ||
font-size: var(--sl-text-h5); | ||
} | ||
.content :global(h6:not(:where(.not-content *))) { | ||
font-size: var(--sl-text-h6); | ||
} | ||
|
||
.content :global(a:not(:where(.not-content *))) { | ||
color: var(--sl-color-text-accent); | ||
} | ||
.content :global(a:hover:not(:where(.not-content *))) { | ||
color: var(--sl-color-white); | ||
} | ||
|
||
.content :global(code:not(:where(.not-content *))) { | ||
background-color: var(--sl-color-bg-inline-code); | ||
margin-block: -0.125rem; | ||
padding: 0.125rem 0.375rem; | ||
font-size: var(--sl-text-code-sm); | ||
} | ||
.content :global(:is(h1, h2, h3, h4, h5, h6) code) { | ||
font-size: inherit; | ||
} | ||
|
||
.content :global(pre:not(:where(.not-content *))) { | ||
border: 1px solid var(--sl-color-gray-5); | ||
padding: 0.75rem 1rem; | ||
font-size: var(--sl-text-code); | ||
tab-size: 2; | ||
} | ||
|
||
.content :global(pre code:not(:where(.not-content *))) { | ||
all: unset; | ||
font-family: var(--__sl-font-mono); | ||
} | ||
|
||
.content :global(blockquote:not(:where(.not-content *))) { | ||
border-inline-start: 1px solid var(--sl-color-gray-5); | ||
padding-inline-start: 1rem; | ||
} | ||
|
||
.content :global(table:not(:where(.not-content *))) { | ||
display: block; | ||
overflow: auto; | ||
border-collapse: collapse; | ||
} | ||
.content :global(tr:nth-child(2n):not(:where(.not-content *))) { | ||
background-color: var(--sl-color-gray-7, var(--sl-color-gray-6)); | ||
} | ||
.content :global(:is(th, td):not(:where(.not-content *))) { | ||
border: 1px solid var(--sl-color-hairline-light); | ||
padding: 0.375rem 0.8125rem; | ||
} | ||
|
||
.content :global(hr:not(:where(.not-content *))) { | ||
border: 0; | ||
border-bottom: 1px solid var(--sl-color-hairline); | ||
} | ||
</style> | ||
<div class="sl-markdown-content"><slot /></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.