YunYouJun / valaxy

🌌 Next Generation Static Blog Framework (Beta) 下一代静态博客框架(支持页面/配置热重载)
https://valaxy.site
MIT License
724 stars 87 forks source link

feat: client redirects at vue router level #328

Closed yixiaojiu closed 9 months ago

yixiaojiu commented 9 months ago

Clear and concise description of the problem

related pr https://github.com/YunYouJun/valaxy/pull/314

Suggested solution

  1. Since VueRouter can configure redirection in RouteRecordRaw, I want to push redirection rules in this variable. https://github.com/YunYouJun/valaxy/blob/df2c16f1cf38e04fdda30b35f2534cf2d64379fa/packages/valaxy/client/main.ts#L4

  2. Redirect configuration may have a broken change. How about this?

    export default defineSiteConfig({
    redirects: {
    runtime: true,
    rules: [
      {
        from: '/foo',
        to: '/about',
      },
    ],
    },
    });
  3. For configure redirection in frontmatter, is there any way to get all markdowns' frontmatter while resolving options? If not, how about add a functions to do that. https://github.com/YunYouJun/valaxy/blob/df2c16f1cf38e04fdda30b35f2534cf2d64379fa/packages/valaxy/node/options.ts#L163-L164

Alternative

No response

Additional context

No response

Validations

YunYouJun commented 9 months ago

It's always better to take advantage of the vue router's existing features. We can align the api as much as possible.

We can get all markdown frontmatter in extendRoute.

Refer here:

https://github.com/YunYouJun/valaxy/blob/df2c16f1cf38e04fdda30b35f2534cf2d64379fa/packages/valaxy/node/plugins/vueRouter.ts#L52

yixiaojiu commented 9 months ago

Ok, thank you for your answer.