sc0ttj / mdsh

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

Custom pages not easily updateable #31

Closed sc0ttj closed 4 years ago

sc0ttj commented 5 years ago

Custom pages are not automatically updated

Problem

The update_pages.sh script cannot update custom pages; only posts, index pages, and 'built-in' pages like contact.html, search.html, etc.. It cannot rebuild pages it doesn't know about (pages that the user created themselves).

Solution

All pages created by the user will have been built by create_pages.sh, so this script can add these pages to a pages.csv file, similar to posts.csv, so they can be 'remembered' and processed/rebuilt later by update_pages.sh..

More info

Any custom pages should be added to pages.csv, with an entry like:

path|filename|title|author|categories|tags

The update_pages script should read pages.csv and process them as required, just like posts.csv:

  1. if page has a source file, grab its source file, then rebuild

  2. if no source file, grab body html and rebuild:

Even pages created like so create_page "$html" > file.html, which don't have a source file (.md or .mdsh) to rebuild from, can be re-built by update_pages, as long as they are listed in pages.csv: update_pages.sh can update a page without a source file by grabbing everything inside <body>...</body> as $body_html, then running:

create_page "$body_html" > the-file.html

.. the 'rest' of the page (outside the body) will be updated - meta info, navigation, page headers and footers, CSS, JS, etc.

sc0ttj commented 4 years ago

Fixed as of https://github.com/sc0ttj/mdsh/commit/e75823a9bbd43ef51dfbeb6313b52ffe51b6b15b