vuejs / vitepress

Vite & Vue powered static site generator.
https://vitepress.dev
MIT License
11.48k stars 1.86k forks source link

能否像hexo一样,新文章自动发布到首页且不需要配置路由 #3814

Closed cpupg closed 3 weeks ago

cpupg commented 3 weeks ago

Is your feature request related to a problem? Please describe.

近期想用github pages搭建个人博客,先选的hexo,后选的vitepress。默认情况下,hexo会将新文章自动发表到首页,不需要配置路由,vitepress需要配置路由并展示在侧边栏。

Recently I want to use github pages to build a personal blog, first selected hexo, then selected vitepress. By default, hexo automatically publishes new articles to the front page without the need to configure a route, while vitepress needs to configure a route and display it in the sidebar.

Describe the solution you'd like

弱化路由功能,或者增加插件来绕开路由,直接将文章发布到主页并分页。使用侧边栏的模式适合做文档,不适合做博客。

Weaken the routing function, or add plugins to bypass the routing and publish articles directly to the home page and page. The sidebar model is good for documentation, not for blogging.

Describe alternatives you've considered

我搜索了issue,发现 #1297 ,但是还是围绕侧边栏展开,不能自动发表。

I searched the issue and found #1297, but it was still around the sidebar and not automatically published.

Additional context

No response

Validations

awxiaoxian2020 commented 3 weeks ago

maybe tracked in https://github.com/vuejs/vitepress/issues/1838

cpupg commented 3 weeks ago

maybe tracked in https://github.com/vuejs/vitepress/issues/1838

thank u, i will research this later.

laplacetw commented 3 weeks ago

VitePress uses file-based routing, which means the generated HTML pages are mapped from the directory structure of the source Markdown files. So if we have a posts folder with .md files and build site with createContentLoader like posts.data.ts, the posts data can be rendered to home page with custom components for pagination, e.g. my VitePress theme for blog.

cpupg commented 3 weeks ago

VitePress uses file-based routing, which means the generated HTML pages are mapped from the directory structure of the source Markdown files. So if we have a posts folder with .md files and build site with createContentLoader like posts.data.ts, the posts data can be rendered to home page with custom components for pagination, e.g. my VitePress theme for blog.

thank u,this is a good method that in offical docs and i will try this later.