sc0ttj / mdsh

A simple static site generator, using Markdown and Bash
https://sc0ttj.github.io/mdsh/
10 stars 0 forks source link

Allow easy changing of page layouts at build time #66

Closed sc0ttj closed 4 years ago

sc0ttj commented 5 years ago

When the user creates a new page or post, they should be able to change the layout of the page by setting a $post_layout variable.

When creating pages or posts, users should give the -all option, and they will be asked to choose a post layout.

Additionally, index pages should be build-able with specific layouts, using something like:

# $post_layout is used by `list_categories` to set the template to use
# build the page
post_title="Foo" \
  post_layout="grid" \
  create_page.sh "$(list_categories)" > categories/index.html

^ The functions in .app/functions/** should use the value of $post_layout (or $page_layout) to choose which template partial to use. If $post_layout not a file name in templates, error out.

To keep things tidy, different layouts could live in different dirs:

# default template 
templates/html/main.mustache
templates/html/_site_header.mustache
...

# templates for layout called "news"
templates/html/news/main.mustache
templates/html/news/_site_header.mustache
...
sc0ttj commented 4 years ago

This feature was added in this PR: https://github.com/sc0ttj/mdsh/pull/85

Except that the layout is defined as page_layout, which can be set when creating a post, is saved in the front matter, and must match the name of a template file in .app/templates.