Feat: Support Content Subdirectories

This issue has been tracked since 2023-03-01.

Which scope/s are relevant/related to the feature request?

content

Information

Right now, all of the content files must be placed in the content directory like /src/content/*.md in order for injectContent to work.

There may be cases where content needs to be separated. For example, maybe you have blog posts, but also project markdown files for a portfolio page. Something like this would be ideal (in order to make the blog list or project list components easier to write):

src/
└── content/
    └── posts/
    |   └── 2023-01-01-my-post.md
    |   └── 2023-01-12-my-other-post.md
    └──projects/
       └── some-awesome-app.md

Could we add another parameter to the injectContent() to accept a prefix? Then update the switchMap to something like this:

switchMap((slug) => {
      const filename = `/src/content/${prefix}${slug}.md`;

Happy to open a PR for this 😄

Describe any alternatives/workarounds you're currently using

No response

I would be willing to submit a PR to fix this issue

  • Yes
  • No
brandonroberts wrote this answer on 2023-03-02

Good idea. What about changing the slug argument taking a string | { slug: string, prefix: string }?

BaronVonPerko wrote this answer on 2023-03-02

Yeah, I think that makes more sense. I'll work on that PR 👍

More Details About Repo
Owner Name analogjs
Repo Name analog
Full Name analogjs/analog
Language TypeScript
Created Date 2022-07-06
Updated Date 2023-03-28
Star Count 885
Watcher Count 18
Fork Count 67
Issue Count 33

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date