I created a wonderful GitHub Pages website for my little project, and I added some other pages into the gh-pages
branch.
My problem is that, everytime I regenerate
Well, after some tries I found the solution.
I noticed that the only file changed for my site was the index.html, the rest of the generated site was the same. Inside the index.html there was a
tag that was containing the html generated from the markdown.
So I created two files header.inc
and footer.inc
, that contained the "static" part for the index page. The content part should have been generated from the README.md
file.
I found that there is an API provided by github to render a RAW markdown in raw mode to html.
So, last piece of the puzzle was to obtain a permalink for the README.md of my project, with the RAW content; which I happened to find here.
So I wrote this simple bash script that regenerates the index.html alone, without touching the rest of the site:
#!/bin/sh
PG_DIR=$(dirname $0)
RAW_README_URL=https://raw.github.com/lviggiano/owner/master/README.md
GITHUB_API_URL=https://api.github.com/markdown/raw
cat $PG_DIR/header.inc
curl -s $RAW_README_URL | curl -s --data-binary @- -H 'Content-Type: text/plain' $GITHUB_API_URL
cat $PG_DIR/footer.inc
Then I just launch the script as:
$ cd myproject
$ git checkout gh-pages
$ git pull origin gh-pages:gh-pages
$ ./bin/autogen > index.html
$ git commit -m "updated index.html from latest README.md" index.html
$ git push origin gh-pages:gh-pages
See the implementation details here.
I tested with the "Leap Day" layout; but I suppose it works also for the others.