Giter Site home page Giter Site logo

pandoc-ssg's Introduction

pandoc-ssg

a simple bash script to generate a static site from a folder full of markdown files

I wanted something simple and I really didn't want to mess with jekyll again so i decided to make a little wrapper script for pandoc.

It takes in a folder full of markdown files that link each other where all the assests are in an assets folder. and converts it into a website with common header and footer.

the site directory should look as follows

.
├── pkms-site/
│   ├── assets/
│   ├── blog/
│   ├── notes/
│   ├── projects/
│   └── index.md
└── site/
    ├── footer.html
    ├── header.html
    ├── links-to-html.lua
    └── md-pan-wiki.sh

md-pan-wiki.sh contains the following.

#! /bin/bash

# run in /site directory
# this copies the directory structure into ./export/ without copying the files
cd ../pkms-site;
find ./ -type d > ../site/dirs.txt;
cd ../site;
mkdir -p export;
cd export;
xargs mkdir -p < ../dirs.txt;
# this copies assests like images into the new export assests directory
cp -r ../../pkms-site/assets/* assets/ ;

# find all md files and feed them in to pandoc as input files.
cd ../../pkms-site;

find ./ -iname "*.md" -type f -exec sh -c 'pandoc -f markdown+tex_math_dollars-smart -t html5 "${0}" -so "../site/export/${0%.*}.html" --lua-filter=../site/links-to-html.lua --include-after-body=../site/footer.html --include-before-body=../site/header.html --css /assets/css/oldschool.css --html-q-tags --katex --no-highlight' {} \;
# ${0%.*} strips the file extension while leaving the path
# the lua filter converts all relative links to .md files to .html files

links-to-html.lua is a lua filter that changes all the relative links to .md files into links to .html files

function Link(el)
    el.target = string.gsub(el.target, "%.md", ".html")
    return el
end

for an live example see my personal site

pandoc-ssg's People

Contributors

kevontheweb avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.