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
6 changes: 6 additions & 0 deletions src/utilities/content-tree-enhancers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ export const sort = (a, b) => {
if (a.name === "index.mdx" || a.url === "/blog/") return -1;
if (b.name === "index.mdx" || b.url === "/blog/") return 1;

// Roadmaps outlive the releases they plan, so they sit below all of
// them rather than among the releases published around the same date.
const aIsRoadmap = aPath.includes("roadmap");
const bIsRoadmap = bPath.includes("roadmap");
if (aIsRoadmap !== bIsRoadmap) return aIsRoadmap ? 1 : -1;

// Blog specific sorting: Index at top, then newest first by date
if (a.date && b.date) {
if (a.date > b.date) return -1;
Expand Down
37 changes: 37 additions & 0 deletions src/utilities/content-tree-enhancers.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,43 @@ describe("restructure", () => {

expect(root.children.map((item) => item.title)).toEqual(["API", "Guides"]);
});

it("keeps blog roadmaps below the releases, newest first", () => {
const post = (name, date, title) => ({
type: "file",
path: `src/content/blog/${name}`,
name,
date,
title,
});

const root = {
type: "directory",
path: "src/content/blog",
children: [
post("2026-02-04-roadmap-2026.mdx", "2026-02-04", "Roadmap 2026"),
post("2020-12-08-roadmap-2021.mdx", "2020-12-08", "Roadmap 2021"),
post("2026-02-03-webpack-5-105.mdx", "2026-02-03", "Webpack 5.105"),
post("2026-09-14-webpack-5-111.mdx", "2026-09-14", "Webpack 5.111"),
{
type: "file",
path: "src/content/blog/index.mdx",
name: "index.mdx",
title: "Blog",
},
],
};

restructure(root, { dir: "src/content" });

expect(root.children.map((item) => item.title)).toEqual([
"Blog",
"Webpack 5.111",
"Webpack 5.105",
"Roadmap 2026",
"Roadmap 2021",
]);
});
});

describe("enhance", () => {
Expand Down
Loading