vercel / serve

Static file serving and directory listing
https://npmjs.com/package/serve
MIT License
9.36k stars 687 forks source link

Feature request: Optional support for a template engines #568

Open automagisch opened 4 years ago

automagisch commented 4 years ago

As a user and HTML coder, I would love to not write repetitive HTML. To solve this, I'd like to see some handler that enables us to use EJS, Handlebars, Nunjucks (or something else) so I can include separate chunks of html into my static templates.

I use serve to build static websites before I add them as a template in a CMS or static generator. But also in static JS, I'd love to add chunks of html into a template to stay organized and non-repetitive.

I hope it validates as a feature. As a hint, this package deals with collecting and assigning template engines: https://www.npmjs.com/package/consolidate. This way, the user can npm install the template engine of choice, and consolidate could handle the inclusion to serve with that template engine.

I hope this suggestion fits in the core ideas of serve. I use this daily as a tool because it does the job great! Thanks a lot for maintaining this project.

styfle commented 4 years ago

Hi @automagisch

We would expect your static site generator (SSG) framework to convert templates to HTML.

This doesn't really fit with the purpose of serve which serves static files.

Instead, you could try Next.js for React templates or Hugo for Markdown templates.

Then you can deploy your project too ZEIT Now by connecting your Git Repository in couple clicks. Each time you git push it will deploy!

You get HTTP2, TLS 1.3, Brotli compression, and many other features automatically.

I hope that helps!