Skip to content

Commit 265fbb3

Browse files
committed
[Docs Site] Remove Container API usage from changelog
1 parent 5429ae3 commit 265fbb3

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

astro.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import rehypeMermaid from "./src/plugins/rehype/mermaid.ts";
1616
import rehypeAutolinkHeadings from "./src/plugins/rehype/autolink-headings.ts";
1717
import rehypeExternalLinks from "./src/plugins/rehype/external-links.ts";
1818
import rehypeHeadingSlugs from "./src/plugins/rehype/heading-slugs.ts";
19+
import rehypeShiftHeadings from "./src/plugins/rehype/shift-headings.ts";
1920

2021
async function autogenSections() {
2122
const sections = (
@@ -67,6 +68,7 @@ export default defineConfig({
6768
rehypeAutolinkHeadings,
6869
// @ts-expect-error plugins types are outdated but functional
6970
rehypeTitleFigure,
71+
rehypeShiftHeadings,
7072
],
7173
},
7274
image: {

src/pages/changelog/index.astro

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@ import { Steps } from "~/components";
1010
import { format } from "date-fns";
1111
import { getChangelogs } from "~/util/changelog";
1212
import { productsByGroup } from "~/util/products";
13-
import { entryToString } from "~/util/container";
14-
import { process } from "~/util/rehype";
1513
16-
import rehypeShiftHeadings from "~/plugins/rehype/shift-headings.ts";
14+
import { render } from "astro:content";
1715
1816
const notes = await getChangelogs({
1917
filter: (entry) => !entry.data.hidden,
@@ -45,8 +43,7 @@ const props = {
4543
.map((group) => group[0])
4644
.sort();
4745

48-
const html = await entryToString(entry, Astro.locals);
49-
const processed = await process(html, [[rehypeShiftHeadings]]);
46+
const { Content } = await render(entry);
5047

5148
return (
5249
<div
@@ -62,7 +59,7 @@ const props = {
6259
>
6360
<time
6461
datetime={entry.data.date.toISOString()}
65-
class="whitespace-nowrap text-xs font-bold leading-6 sm:pr-4 sm:text-right"
62+
class="text-xs leading-6 font-bold whitespace-nowrap sm:pr-4 sm:text-right"
6663
>
6764
{date}
6865
</time>
@@ -80,7 +77,7 @@ const props = {
8077
</h3>
8178
<ProductPills products={entry.data.products} />
8279
</div>
83-
<p set:html={processed} />
80+
<Content />
8481
</li>
8582
</ol>
8683
</Steps>
@@ -91,7 +88,7 @@ const props = {
9188
<div class="flex items-center justify-center">
9289
<button
9390
id="changelogs-next-button"
94-
class="h-12 cursor-pointer rounded-sm bg-cl1-brand-orange px-6 font-medium text-cl1-black"
91+
class="bg-cl1-brand-orange text-cl1-black h-12 cursor-pointer rounded-sm px-6 font-medium"
9592
>
9693
Load more items
9794
</button>

src/plugins/rehype/shift-headings.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,16 @@ import { visit } from "unist-util-visit";
33
import type { Root, Element } from "hast";
44

55
export default function () {
6-
return function (tree: Root) {
6+
return function (tree: Root, file: any) {
77
visit(tree, "element", function (element) {
8+
if (
9+
!file.history.find((path: string) =>
10+
path.includes("/src/content/changelog/"),
11+
)
12+
) {
13+
return;
14+
}
15+
816
const classNames = (element.properties.className as string[]) ?? [];
917

1018
if (classNames.includes("heading-wrapper")) {

0 commit comments

Comments
 (0)