jaredkrinke / md2blog

Zero-config static site generator for dev blogs
https://jaredkrinke.github.io/md2blog/
Other
49 stars 3 forks source link

Support custom templates #46

Open jaredkrinke opened 1 year ago

jaredkrinke commented 1 year ago

The default template should be all you need... but I'm probably going to grudgingly support custom templates. The biggest issue is that then I'd need to support some template language, and that is a big can of worms since there's no universal standard.

tyeeman commented 11 months ago

While you're working on this is there a simple way for me to alter the template in the source code then rebuild on my PC using the deno exe? Just wondering.

jaredkrinke commented 11 months ago

While you're working on this is there a simple way for me to alter the template in the source code then rebuild on my PC using the deno exe? Just wondering.

Yeah, if you have the Deno CLI and a copy of the md2blog code, you should be able to modify templates.ts and then run deno run --allow-read --allow-write path/to/main.ts to run your local copy of the code.

Once happy, you can use deno install to avoid typing in all the options each time.

tyeeman commented 11 months ago

Thanks. So deno install creates an exe?

jaredkrinke commented 11 months ago

Thanks. So deno install creates an exe?

No, but you can do that with Deno compile: https://docs.deno.com/runtime/manual/tools/compiler

"Install" is more like creating an alias, in case you don't need a big self contained binary like "compile".

tyeeman commented 11 months ago

What's the easiest way to add a header image in the template for all pages/posts?

jaredkrinke commented 11 months ago

What's the easiest way to add a header image in the template for all pages/posts?

Not sure how much direction you need, but here's what I can easily type on my phone:

Most of this is similar to the title link, which should be easy to find (something like href="${m.pathToRoot}index.html") in the existing code.

Some of extra context:

The template language is this one: https://deno.land/x/literal_html

The md2blog functions include metadata in a variable named m.

tyeeman commented 5 months ago

Greetings Just getting back to this - In templates.ts after line 258 <header> can I add this for the header image to show? -

<header>
 <img src="${m.pathToRoot!}image.jpg" alt="">
<h1><a href="${m.pathToRoot!}index.html">${m.site!.title!}</a></h1>

To rebuild into an exe what command line should I use?

Would this work - deno compile --allow-read --allow-write path/to/main.ts

Oh, I see you have a batch file for building. Should I just run that for the Windows build?

Update - I got it to build ok and my header image is showing fine!