web-infra-dev / rspress

🦀💨 A fast Rspack-based static site generator.
https://rspress.dev
MIT License
1.19k stars 107 forks source link

[Feature]: Support for injecting extra head tags via front matter #1121

Closed chenjiahan closed 2 weeks ago

chenjiahan commented 1 month ago

What problem does this feature solve?

Provide support for injecting extra head tags via front matter, like Vuepress and Vitepress:

What does the proposed API look like?

---
head:
  - - meta
    - name: description
      content: hello
  - - meta
    - name: keywords
      content: super duper SEO
---
shulaoda commented 1 month ago

The parsing function of frontmatter uses gray-matter and doesn't use mdx-rs. To achieve this feature, maybe you can view: https://github.com/web-infra-dev/rspress/blob/ec951a7a94ab6a3dd0185d9a3289b2f4536a7968/packages/shared/src/node-utils/loadFrontMatter.ts#L5-L9

toteto commented 3 weeks ago

Is there progress or timeline on this feature? Any additional input before I open PR for this?

chenjiahan commented 3 weeks ago

No progress yet, feel free to send a PR for this 😄

shulaoda commented 3 weeks ago

At present, this PR#1145 only implements this feature in theme-default, and further exploration is needed to achieve as vitepress.

toteto commented 3 weeks ago

At present, this PR#1145 only implements this feature in theme-default, and further exploration is needed to achieve as vitepress.

Yes ☹️ Probably plugging in the build step and injecting the headers there would be better. Couldn't find this place and that is why I implemented it in the default theme layout. Maybe help me find this place and I can move the implementation over to there?

Timeless0911 commented 3 weeks ago

The rendering page step when build is here. https://github.com/web-infra-dev/rspress/blob/d4432ac1108130f43ae928aafedff6c9fe6de669/packages/core/src/node/build.ts#L83-L89

toteto commented 2 weeks ago

Done with #1168

chenjiahan commented 2 weeks ago

Thanks!