JSRocksHQ / harmonic

The next static site generator
http://harmonicjs.com/
MIT License
282 stars 26 forks source link

Dynamic template pages #164

Closed jaydson closed 9 years ago

jaydson commented 9 years ago

Harmonic's current implementation work with just 3 template files: index.html, post.html, page.html and tags_archives.html.
This is fine for a simple blog, but for a dynamic web site, this is not very useful.

What I mean is we need a better way to handle various page templates, not just the current ones. Also, this must to be dynamic, if I want a new page template, I want to create it by myself, and Harmonic should take care of the rest.

Use case: I'm working on my blog, and I want to have 2 different pages. Each page have different structures, different HTML, etc. By having this feature, I'll be able to create as many pages I want, with different templates.

I need some feedbacks here: @UltCombo @felipenmoura @viniciusdacal

viniciusdacal commented 9 years ago

currently it's static what template we use to generate pages:

pageTpl = this.theme.getFileContents('page.html'),

maybe we could just read an atribute layout inside md files and use it to decide what template we should use to render the page.

Actually, we already have this attribute inside md files by default

<!--
layout: page
viniciusdacal commented 9 years ago

And, we could have a way to create more html pages inside theme, working the same way as index.html, which we render just with config and metadata.

UltCombo commented 9 years ago

maybe we could just read an atribute layout inside md files and use it to decide what template we should use to render the page.

:+1:

So, post, page, index and tag_archives are built-in (required, customizable) templates, and you can create new ones by placing .html files inside the theme package. And to create a new page, run harmonic new_page and change the template markdown metadata to the name of the template file (without the .html extension).

What do you guys think? I believe it can't get much simpler than this. Later on, we can add a template prompt to the harmonic new_page CLI.

jaydson commented 9 years ago

That's a great idea guys! I'll try to make this when I have a free time. Please let me know if one of you want to start something.

viniciusdacal commented 9 years ago

@jaydson did you start something? I think I'll have a free time today.

jaydson commented 9 years ago

Nope, not yet. Feel free to start :+1:

UltCombo commented 9 years ago

Fixed by #170.

jaydson commented 8 years ago

This was never released?

UltCombo commented 8 years ago

@jaydson That's true. If I recall correctly, the release was pending an Wiki update and changelog.

By the way, I'm proposing #181 in order to improve the way we maintain documentation and avoid cases such as this.

jaydson commented 8 years ago

:cry: I was trying to build something yesterday and noticed it was missing.

I'll check #181.

Thanks @UltCombo