honojs / honox

HonoX - Hono based meta framework
https://hono.dev
MIT License
1.4k stars 38 forks source link

Support `.md` / custom extension omission #187

Closed goisaki closed 3 months ago

goisaki commented 3 months ago

What is the feature you are proposing?

When I’m creating a blog site that parses .md as route, the extension was not omitted and converted like: /app/routes/blog/post-1.md -> /blog/post-1.md

I would like to see an option to omit paths and recognize files as routes for extensions other the currently supported .ts, tsx, and .mdx. Or I would like to hardcode .md as such. I personally support providing the option, as I think some people would prefer to use files such as .vue or .svelte. (And I can implement it!)

Plugins that make it possible

Codes to be affected

Related discussion

I am considering creating a PR to add this functionality to HonoX, what do you think about this issue?

The reason why it is hard-coded is to prevent extensions other than the expected ones. But, allowing .md not only .mdx makes sense. If you can confirm that the *.md works well, you can create the PR to support .md!

Originally posted by @yusukebe in https://github.com/honojs/website/issues/262#issuecomment-1986979520

yusukebe commented 3 months ago

Hi @goisaki

Let's add .md!

I personally support providing the option, as I think some people would prefer to use files such as .vue or .svelte. (And I can implement it!)

Ideally, we should make it so that users can add the extension by themselves by specifying them as an option. But, we can't do that because the Glob Import which is used in the src/server/server.ts or src/server/with-default.ts is not support variables: https://vitejs.dev/guide/features#glob-import-caveats

So, at this time, we should make it support only .md. Can you create the PR?

goisaki commented 3 months ago

Hi @yusukebe I didn't know that. Thanks. I will send you a PR right away.