Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support custom templates #46

Open
jaredkrinke opened this issue Sep 12, 2023 · 7 comments
Open

Support custom templates #46

jaredkrinke opened this issue Sep 12, 2023 · 7 comments

Comments

@jaredkrinke
Copy link
Owner

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
Copy link

tyeeman commented Oct 5, 2023

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
Copy link
Owner Author

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
Copy link

tyeeman commented Oct 5, 2023

Thanks. So deno install creates an exe?

@jaredkrinke
Copy link
Owner Author

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
Copy link

tyeeman commented Oct 7, 2023

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

@jaredkrinke
Copy link
Owner Author

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:

  • Put the image somewhere in "content/"
  • Reference the image in a tag in the partialBase function
  • Ensure that the relative reference starts with m.pathToRoot and then goes from the root, to ensure there reference can be resolved form anywhere in the directory tree

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
Copy link

tyeeman commented Apr 10, 2024

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants