Skip to content

Commit 9f13e0d

Browse files
Boshenclaude
andcommitted
feat: auto-redirect /blog to the latest blog post
Add dynamic redirect from /blog to the first entry in sidebar.blog.json, eliminating the need to manually update blog links when new posts are added. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 797119f commit 9f13e0d

File tree

5 files changed

+20
-2
lines changed

5 files changed

+20
-2
lines changed

.vitepress/config/en.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const enConfig = defineLocaleConfig("root", {
2323
{
2424
text: "Resources",
2525
items: [
26-
{ text: "Release Blog", link: "/blog/2025-12-08-type-aware-alpha" },
26+
{ text: "Release Blog", link: "/blog" },
2727
{ text: "Endorsements", link: "/endorsements" },
2828
{ text: "Team", link: "/team" },
2929
{ text: "Releases", link: "https://github.com/oxc-project/oxc/releases" },

.vitepress/config/rss.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ export const rssConfig = defineConfig({
8282
);
8383

8484
for (const { url, excerpt, frontmatter, html } of posts) {
85+
// Skip the blog index redirect page
86+
if (url.endsWith("/blog/") || url.endsWith("/blog/index.html")) {
87+
continue;
88+
}
89+
8590
const result = url.match(/blog\/(?<dateGroup>\d{4}-\d{2}-\d{2})-.*$/);
8691
// The date is required by the `feed` package, but the logic that deals with date parsing from blog posts in this repo doesn't guarantee a date
8792
if (!result || !result.groups) {

.vitepress/config/shared.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { fileURLToPath } from "node:url";
44
import { defineConfig, HeadConfig } from "vitepress";
55
import { groupIconMdPlugin, groupIconVitePlugin } from "vitepress-plugin-group-icons";
66
import llmstxt from "vitepress-plugin-llms";
7+
import blogSidebar from "../sidebar.blog.json";
78

89
function inlineScript(file: string): HeadConfig {
910
return ["script", {}, readFileSync(resolve(__dirname, `./inlined-scripts/${file}`), "utf-8")];
@@ -61,9 +62,18 @@ export const sharedConfig = defineConfig({
6162
base: "/",
6263
head,
6364
lastUpdated: false,
65+
ignoreDeadLinks: ["/blog"],
6466
transformPageData(pageData) {
6567
pageData.frontmatter.head ??= [];
6668

69+
// Redirect /blog to the first blog post
70+
if (pageData.relativePath === "blog/index.md" && blogSidebar.length > 0) {
71+
pageData.frontmatter.head.push([
72+
"meta",
73+
{ "http-equiv": "refresh", content: `0; url=${blogSidebar[0].link}` },
74+
]);
75+
}
76+
6777
if (pageData.frontmatter.canonical) {
6878
pageData.frontmatter.head.push([
6979
"link",

src/blog/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
layout: false
3+
---

src/docs/guide/introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ title: Getting Started
3131
- [Talks and media](/docs/guide/media)
3232
- [Team](/team)
3333
- [Endorsements](/endorsements)
34-
- [Release Blog](/blog/2025-12-08-type-aware-alpha)
34+
- [Release Blog](/blog)
3535
- [Releases](https://github.com/oxc-project/oxc/releases)

0 commit comments

Comments
 (0)