4 ms·
If you consider static site generators as a special case of side-server rendering, then that is basically the principle that underlies my personal ssg [0]. Hig
by fabianholzer 2y ago
If you consider static site generators as a special case of side-server rendering, then that is basically the principle that underlies my personal ssg [0].
Highlevel idea: It reads in all HTML files, parses them with JSDOM, builds a metamodel of the overall website, which (ab-)uses standard HTML meta tags as alternative to a frontmatter (e.g <meta name="template" content="articles"> declares the particular file as the template for the category articles, while <meta name="category" content="article"> declares a particular file as part of the category articles. And then it uses a non-standard HTML tag to call JS plugins with the whole meta-model of the site, so it can plug together content and template, rewrite parts of the DOM (for example add bidirectional links when desired, run a syntax highlighter on <code> tag, count words). When all plugins have run the DOM is serialized into HTML. Admittedly it could be a tad faster, but for my purposes it is good enough. I don't mind running a ton of JS on my machine, but still can serve mostly static HTML with very few sprinkles of client-side JS
[0] https://github.com/fnh/intertwingle/ https://github.com/fnh/intertwingle/