diff --git a/website/docs/en/_nav.json b/website/docs/en/_nav.json index e5db6bcd..c75aab87 100644 --- a/website/docs/en/_nav.json +++ b/website/docs/en/_nav.json @@ -4,6 +4,11 @@ "link": "/guide/quick-start", "activeMatch": "/guide/" }, + { + "text": "Blog", + "link": "/blog/", + "activeMatch": "/blog/" + }, { "text": "Changelog", "link": "https://github.com/rstackjs/rstack-cli/releases" diff --git a/website/docs/en/blog/_meta.json b/website/docs/en/blog/_meta.json new file mode 100644 index 00000000..7f5a7c7d --- /dev/null +++ b/website/docs/en/blog/_meta.json @@ -0,0 +1 @@ +["index", "introducing-rstack-cli"] diff --git a/website/docs/en/blog/index.mdx b/website/docs/en/blog/index.mdx new file mode 100644 index 00000000..eb9b7a05 --- /dev/null +++ b/website/docs/en/blog/index.mdx @@ -0,0 +1,9 @@ +--- +title: Rstack CLI blogs +description: 'Blog posts about Rstack CLI.' +sidebar: false +--- + +import { BlogList } from '../../../theme/components/BlogList'; + + diff --git a/website/docs/en/blog/introducing-rstack-cli.mdx b/website/docs/en/blog/introducing-rstack-cli.mdx new file mode 100644 index 00000000..48c88ca0 --- /dev/null +++ b/website/docs/en/blog/introducing-rstack-cli.mdx @@ -0,0 +1,16 @@ +--- +date: 2026-11-17 +sidebar: false +authors: + - name: chenjiahan + avatar: 'https://github.com/chenjiahan.png' + github: 'chenjiahan' +--- + +import { BlogAuthors } from '@rstackjs/doc-ui/blog-authors'; + +# Introducing Rstack CLI + +_November 17, 2026_ + + diff --git a/website/docs/zh/_nav.json b/website/docs/zh/_nav.json index b1d56dcc..7e1abfa5 100644 --- a/website/docs/zh/_nav.json +++ b/website/docs/zh/_nav.json @@ -4,6 +4,11 @@ "link": "/guide/quick-start", "activeMatch": "/guide/" }, + { + "text": "博客", + "link": "/blog/", + "activeMatch": "/blog/" + }, { "text": "更新日志", "link": "https://github.com/rstackjs/rstack-cli/releases" diff --git a/website/docs/zh/blog/_meta.json b/website/docs/zh/blog/_meta.json new file mode 100644 index 00000000..7f5a7c7d --- /dev/null +++ b/website/docs/zh/blog/_meta.json @@ -0,0 +1 @@ +["index", "introducing-rstack-cli"] diff --git a/website/docs/zh/blog/index.mdx b/website/docs/zh/blog/index.mdx new file mode 100644 index 00000000..d4fdcff8 --- /dev/null +++ b/website/docs/zh/blog/index.mdx @@ -0,0 +1,9 @@ +--- +title: Rstack CLI 博客 +description: '与 Rstack CLI 相关的博客文章。' +sidebar: false +--- + +import { BlogList } from '../../../theme/components/BlogList'; + + diff --git a/website/docs/zh/blog/introducing-rstack-cli.mdx b/website/docs/zh/blog/introducing-rstack-cli.mdx new file mode 100644 index 00000000..4b6e8aa6 --- /dev/null +++ b/website/docs/zh/blog/introducing-rstack-cli.mdx @@ -0,0 +1,16 @@ +--- +date: 2026-11-17 +sidebar: false +authors: + - name: chenjiahan + avatar: 'https://github.com/chenjiahan.png' + github: 'chenjiahan' +--- + +import { BlogAuthors } from '@rstackjs/doc-ui/blog-authors'; + +# Rstack CLI 介绍 \{#introducing-rstack-cli} + +_2026 年 11 月 17 日_ + + diff --git a/website/theme/components/BlogList.tsx b/website/theme/components/BlogList.tsx new file mode 100644 index 00000000..5fcf4e81 --- /dev/null +++ b/website/theme/components/BlogList.tsx @@ -0,0 +1,55 @@ +import { useLang, usePages } from '@rspress/core/runtime'; +import { Link, renderInlineMarkdown } from '@rspress/core/theme'; +import type { BlogAvatarAuthor } from '@rstackjs/doc-ui/blog-avatar'; +import { BlogBackground } from '@rstackjs/doc-ui/blog-background'; +import { + BlogList as BaseBlogList, + type BlogListItem, +} from '@rstackjs/doc-ui/blog-list'; + +type BlogFrontmatter = { + description?: string; + date?: string; + authors?: BlogAvatarAuthor[]; +}; + +const getDateValue = (date?: BlogListItem['date']): number => { + const timestamp = date ? new Date(date).getTime() : 0; + return Number.isNaN(timestamp) ? 0 : timestamp; +}; + +export function BlogList() { + const { pages } = usePages(); + const lang = useLang(); + const posts = pages + .filter( + (page) => + page.lang === lang && + page.routePath.includes('/blog/') && + !page.routePath.endsWith('/blog/'), + ) + .map((page): BlogListItem => { + const frontmatter = (page.frontmatter ?? {}) as BlogFrontmatter; + + return { + title: page.title, + description: frontmatter.description, + date: frontmatter.date, + href: page.routePath, + authors: frontmatter.authors, + }; + }) + .sort((a, b) => getDateValue(b.date) - getDateValue(a.date)); + + return ( + <> + + + + ); +} diff --git a/website/theme/index.tsx b/website/theme/index.tsx index d9f07d14..2d7cac73 100644 --- a/website/theme/index.tsx +++ b/website/theme/index.tsx @@ -1,4 +1,11 @@ -import { Layout as BaseLayout } from '@rspress/core/theme-original'; +import { useLang, usePage } from '@rspress/core/runtime'; +import { + Layout as BaseLayout, + DocLayout as BaseDocLayout, + Link, + type DocLayoutProps, +} from '@rspress/core/theme-original'; +import { BlogBackButton } from '@rstackjs/doc-ui/blog-back-button'; import { NavIcon } from '@rstackjs/doc-ui/nav-icon'; import { HomeLayout } from './pages'; import '@rstackjs/doc-ui/theme.css'; @@ -6,6 +13,27 @@ import './index.scss'; const Layout = () => } />; -export { HomeLayout, Layout }; +const DocLayout = (props: DocLayoutProps) => { + const { page } = usePage(); + const lang = useLang(); + + return ( + + + {props.beforeDocContent} + + } + /> + ); +}; + +export { DocLayout, HomeLayout, Layout }; export * from '@rspress/core/theme-original';