Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
12fa163
feat: bump many dependencies for Astro v5
HiDeoo Nov 13, 2024
2dffec2
feat: handle mdx peer dep change
HiDeoo Nov 13, 2024
9bb4f5c
fix: handle content layer basic changes
HiDeoo Nov 13, 2024
f84465a
feat: add loaders
HiDeoo Nov 13, 2024
6714593
feat: remove `globalRoutePriority` experimental option
HiDeoo Nov 13, 2024
db6affc
feat: update shiki `css-variables` theme token names
HiDeoo Nov 13, 2024
d7e5dd0
fix: 404 slug
HiDeoo Nov 13, 2024
f1ab9e1
feat: update vitest
HiDeoo Nov 14, 2024
b6907d3
feat: remove user-configurable loader paths
HiDeoo Nov 15, 2024
aa6c6be
chore: update astro version to beta 8
HiDeoo Nov 15, 2024
e2b5173
test: fix vitest workspace configuration
HiDeoo Nov 15, 2024
806ee64
test: remove unnecessary `@ts-expect-error` directives
HiDeoo Nov 15, 2024
a6fe0ae
test: update routing tests for legacy collections
HiDeoo Nov 15, 2024
48191a2
refactor: use `filePath` with git helpers
HiDeoo Nov 15, 2024
f066341
fix: type import
HiDeoo Nov 15, 2024
574ead1
feat: legacy content collections
HiDeoo Nov 15, 2024
7fcc338
fix: edit url
HiDeoo Nov 15, 2024
19cf56d
fix: sidebar autogenerated groups
HiDeoo Nov 15, 2024
d8b0bba
feat: add new and legacy collections support
HiDeoo Nov 15, 2024
a78d975
fix: 404
HiDeoo Nov 15, 2024
5c758c0
ci: test legacy collections
HiDeoo Nov 15, 2024
a51ff9a
test: fix e2e tests
HiDeoo Nov 15, 2024
234c01d
fix: loader with custom `srcDir`
HiDeoo Nov 15, 2024
5aa97a5
fix: 404 `filePath`
HiDeoo Nov 15, 2024
c6d4a9c
fix: `output: 'static'` & `prerender: false` error message
HiDeoo Nov 15, 2024
b47c07f
feat: update examples `tsconfig.json` files
HiDeoo Nov 15, 2024
798bf84
feat: remove `env.d.ts` files
HiDeoo Nov 15, 2024
6041985
docs: update `?raw` code component examples
HiDeoo Nov 15, 2024
b178bf9
chore: remove unnecessary `.gitignore` entry
HiDeoo Nov 15, 2024
4d09de5
fix: update monorepo root `tsconfig.json`
HiDeoo Nov 15, 2024
c225761
fix: 404 `filePath`
HiDeoo Nov 15, 2024
bc6819a
fix: starlight page route data
HiDeoo Nov 15, 2024
b77bd88
fix: docs link validator
HiDeoo Nov 16, 2024
10574aa
fix: basics example
HiDeoo Nov 16, 2024
d7a6b47
fix: tailwind example
HiDeoo Nov 16, 2024
30a2e3f
feat: add markdoc support to docs loader
HiDeoo Nov 16, 2024
96a088b
fix: markdoc example
HiDeoo Nov 16, 2024
4b45a9f
feat: add `// @ts-check` to config files
HiDeoo Nov 16, 2024
a689a34
test: exclude `.astro` files from coverage
HiDeoo Nov 16, 2024
8acd505
test: tweak starlight test coverage thresholds
HiDeoo Nov 16, 2024
2c57f2f
test: disable tailwind test coverate thresholds auto update
HiDeoo Nov 16, 2024
6583163
test: tweak tailwind test coverage thresholds
HiDeoo Nov 16, 2024
214d8b4
fix: boolean data attributes
HiDeoo Nov 17, 2024
d2e5e3d
docs: update link check instructions
HiDeoo Nov 18, 2024
3bae9e3
fix: windows git path issue
HiDeoo Nov 18, 2024
073cfcb
Merge branch 'main' into hd-astro-v5
HiDeoo Nov 19, 2024
9c5dcc3
fix: ignore ssr build directory from root `tsconfig.json`
HiDeoo Nov 19, 2024
1e8edf1
chore: update jsdoc example
HiDeoo Nov 19, 2024
a74c1d1
test: update mocked collection config
HiDeoo Nov 19, 2024
1c5bdb6
Merge branch 'main' into hd-astro-v5
HiDeoo Nov 22, 2024
b56de15
feat: update to astro 5.0.0-beta.10
HiDeoo Nov 22, 2024
344878b
chore: remove fixed bug todo comment
HiDeoo Nov 22, 2024
bf69ba5
test: update test to match fixed types in astro
HiDeoo Nov 22, 2024
97a78a6
feat: add support for `content.config.ts` file
HiDeoo Nov 22, 2024
f22913c
chore: tweak comment
HiDeoo Nov 22, 2024
6c4df31
chore: update `src/content/config.ts` references
HiDeoo Nov 22, 2024
b14aca5
chore: bump astro version to beta 11
HiDeoo Nov 26, 2024
73d6e69
feat: revert mdx integration changes
HiDeoo Nov 26, 2024
4d119e6
fix: collection config import path on windows
HiDeoo Nov 26, 2024
8aa6621
fix: starlight page id for legacy collections
HiDeoo Nov 26, 2024
57c925e
docs: content collection config changes
HiDeoo Nov 26, 2024
71109b8
docs: route data `id` for legacy collections
HiDeoo Nov 26, 2024
5380aba
Merge branch 'main' into hd-astro-v5
HiDeoo Nov 26, 2024
ecd3116
docs: update astro docs links
HiDeoo Nov 26, 2024
0e23e3a
chore: bump astro version to beta 12 and vitest to 2.1.6
HiDeoo Nov 27, 2024
28ca09c
fix: explicitly await some test assertions
HiDeoo Nov 27, 2024
eb8022c
feat: remove prerender check no longer relevant
HiDeoo Nov 27, 2024
3b88a9b
chore: add changesets
HiDeoo Nov 28, 2024
9f75b18
docs: add `legacy.collections`
HiDeoo Dec 3, 2024
f446092
Merge branch 'main' into hd-astro-v5
HiDeoo Dec 3, 2024
2af3ed4
feat: update to astro 5 stable
HiDeoo Dec 3, 2024
ba7d275
feat: update to astro `5.0.2`
HiDeoo Dec 4, 2024
e07dd93
chore: pin vitest version to `2.1.6`
HiDeoo Dec 5, 2024
fc99611
docs: add step for other collections in upgrade guide
HiDeoo Dec 6, 2024
0521ba2
refactor: collection paths
HiDeoo Dec 6, 2024
000efa1
chore: update changeset version
HiDeoo Dec 12, 2024
3f41484
Merge branch 'main' into hd-astro-v5
HiDeoo Dec 13, 2024
803f8a6
refactor: `loader` → `loaders`
HiDeoo Dec 13, 2024
d73e820
chore: deprecate `slug` from route data
HiDeoo Dec 13, 2024
40469ed
docs: fix highlighting
HiDeoo Dec 13, 2024
f9b9731
docs: remove inline code markup
HiDeoo Dec 13, 2024
dcb6095
refactor: collection helpers
HiDeoo Dec 13, 2024
43e5447
feat: normalize content layer IDs
HiDeoo Dec 13, 2024
755a6d3
chore: fix typo
HiDeoo Dec 13, 2024
13c8796
docs: fix local link
HiDeoo Dec 13, 2024
39d6f3b
Merge branch 'main' into hd-astro-v5
HiDeoo Dec 13, 2024
08a74c5
chore: bump `@astrojs/starlight` peer dependency
HiDeoo Dec 13, 2024
a2c7bb3
Clarify
delucis Dec 13, 2024
444d9cf
Withhold information
delucis Dec 13, 2024
0b9a91c
Add changeset subheadings
delucis Dec 13, 2024
fd04220
Merge branch 'main' into hd-astro-v5
delucis Dec 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: normalize content layer IDs
  • Loading branch information
HiDeoo committed Dec 13, 2024
commit 43e54472d108a7a71fdc93742d9f4b17b1302efa
9 changes: 6 additions & 3 deletions packages/starlight/__tests__/basics/routing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ test('test suite is using correct env', () => {

test('route slugs are normalized', () => {
const indexRoute = routes.find(
(route) => route.id === (project.legacyCollections ? 'index.mdx' : 'index')
(route) => route.id === (project.legacyCollections ? 'index.mdx' : '')
);
expect(indexRoute?.slug).toBe('');
});

test('routes contain copy of original doc as entry', async () => {
const docs = await getCollection('docs');
for (const route of routes) {
const doc = docs.find((doc) => doc.id === route.id);
const doc = docs.find((doc) => doc.id === route.id || (doc.id === 'index' && route.id === ''));
if (!doc) throw new Error('Expected to find doc for route ' + route.id);
// Compare without slug as slugs can be normalized.
const { slug: _, ...entry } = route.entry;
Expand All @@ -43,7 +43,10 @@ test('routes contain copy of original doc as entry', async () => {
const { slug: __, ...legacyInput } = doc;
expect(legacyEntry).toEqual(legacyInput);
} else {
expect(entry).toEqual(doc);
// Compare without ids as ids can be normalized when using loaders.
const { id: _, ...loaderEntry } = entry;
const { id: __, ...loaderInput } = doc;
expect(loaderEntry).toEqual(loaderInput);
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ vi.mock('astro:content', async () =>

test('route slugs are normalized', () => {
const indexRoute = routes.find(
(route) => route.id === (project.legacyCollections ? 'index.mdx' : 'index')
(route) => route.id === (project.legacyCollections ? 'index.mdx' : '')
);
expect(indexRoute?.slug).toBe('');
});
Expand Down
7 changes: 2 additions & 5 deletions packages/starlight/utils/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ function pathsMatch(pathA: string, pathB: string) {
function getBreadcrumbs(path: string, baseDir: string): string[] {
// Strip extension from path.
const pathWithoutExt = stripExtension(path);
// Index paths will match `baseDir` and don’t include breadcrumbs.
if (pathWithoutExt === baseDir) return [];
// Index paths will match `baseDir` but we still need to consider them as a single segment.
if (pathWithoutExt === baseDir) return [path];
// Ensure base directory ends in a trailing slash.
baseDir = ensureTrailingSlash(baseDir);
// Strip base directory from path if present.
Expand All @@ -228,9 +228,6 @@ function treeify(routes: Route[], baseDir: string): Dir {
// Build the tree
.forEach((doc) => {
const parts = getBreadcrumbs(doc.id, baseDir);
// If the breadcrumb is empty, the document is at the root level so we can fallback to the
// document ID.
if (parts.length === 0) parts.push(doc.id);
let currentNode = treeRoot;

parts.forEach((part, index) => {
Expand Down
3 changes: 3 additions & 0 deletions packages/starlight/utils/routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@ const normalizeIndexSlug = (slug: string) => (slug === 'index' ? '' : slug);

/** Normalize the different collection entry we can get from a legacy collection or a loader. */
export function normalizeCollectionEntry(entry: StarlightDocsCollectionEntry): StarlightDocsEntry {
const slug = normalizeIndexSlug(entry.slug ?? entry.id);
return {
...entry,
// In a collection with a loader, the `id` is a slug and should be normalized.
id: entry.slug ? entry.id : slug,
// In a legacy collection, the `filePath` property doesn't exist.
filePath: entry.filePath ?? `${getCollectionPathFromRoot('docs', project)}/${entry.id}`,
// In a collection with a loader, the `slug` property is replaced by the `id`.
Expand Down