Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
96 changes: 45 additions & 51 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@astrojs/react": "^3.6.2",
"@astrojs/rss": "^4.0.9",
"@astrojs/sitemap": "^3.2.1",
"@astrojs/starlight": "^0.28.3",
"@astrojs/starlight": "^0.29.2",
"@astrojs/starlight-docsearch": "^0.2.0",
"@astrojs/starlight-tailwind": "^2.0.3",
"@astrojs/tailwind": "^5.1.2",
Expand Down
18 changes: 0 additions & 18 deletions patches/@astrojs+starlight+0.28.3.patch

This file was deleted.

2 changes: 1 addition & 1 deletion src/components/ProductChangelog.astro
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ if (!changelogs) {
`Changelog entry points to ${link.slice(1, -1)} but unable to find entry with that slug`,
);

description = (await entryToString(page)) ?? page.body;
description = (await entryToString(page, Astro.locals)) ?? page.body;

return (
<div data-product={entry.product.toLowerCase()}>
Expand Down
1 change: 1 addition & 0 deletions src/components/overrides/Head.astro
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ if (currentSection) {
Astro.props.entry.data.description ??= await getPageDescription(
// @ts-expect-error TODO: improve types
Astro.props.entry,
Astro.locals,
);
// Adding metadata used for reporting and search indexing
Expand Down
1 change: 1 addition & 0 deletions src/components/overrides/PageSidebar.astro
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ let rangeBetween = (x: number, y: number) =>
if (Astro.props.toc) {
const text = await entryToString(
Astro.props.entry as CollectionEntry<"docs">,
Astro.locals,
);
if (text) {
Expand Down
3 changes: 2 additions & 1 deletion src/pages/[...changelog].xml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ export const GET: APIRoute = async (context) => {
`Changelog entry points to ${link.slice(1, -1)} but unable to find entry with that slug`,
);

description = (await entryToString(page)) ?? page.body;
description =
(await entryToString(page, context.locals)) ?? page.body;
} else {
description = entry.description;
}
Expand Down
3 changes: 2 additions & 1 deletion src/pages/changelog/index/index.xml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export const GET: APIRoute = async (context) => {
`Changelog entry points to ${link.slice(1, -1)} but unable to find entry with that slug`,
);

description = (await entryToString(page)) ?? page.body;
description =
(await entryToString(page, context.locals)) ?? page.body;
} else {
description = entry.description;
}
Expand Down
6 changes: 5 additions & 1 deletion src/util/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { getContainerRenderer } from "@astrojs/mdx";
import { loadRenderers } from "astro:container";
import type { CollectionEntry } from "astro:content";

export async function entryToString(entry: CollectionEntry<"docs">) {
export async function entryToString(
entry: CollectionEntry<"docs">,
locals: any,
) {
if (!entry.render) {
return undefined;
}
Expand All @@ -17,6 +20,7 @@ export async function entryToString(entry: CollectionEntry<"docs">) {

const html = await container.renderToString(Content, {
params: { slug: entry.slug },
locals,
});

return html;
Expand Down
7 changes: 5 additions & 2 deletions src/util/description.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ import { entryToString } from "./container";
2. If there is a `<p>...</p>` element in the HTML, return that.
3. Return `undefined` to signal to consumers there is no suitable description.
*/
export async function getPageDescription(entry: CollectionEntry<"docs">) {
export async function getPageDescription(
entry: CollectionEntry<"docs">,
locals: any,
) {
if (entry.data.description) return entry.data.description;

const html = await entryToString(entry);
const html = await entryToString(entry, locals);

if (!html) return undefined;

Expand Down
Loading