Giter VIP home page Giter VIP logo

pacd-rs's Introduction

Pacd

A static site generator based on shopify liquid.

Liquid Reference

Installation

You need cargo available on your $PATH. If you don't have Rust and Cargo you can install both with rustup

Option 1: Clone and Install (Recommended)

  1. Clone this repository
git clone [email protected]:ashwins93/pacd-rs.git
  1. Install with cargo
cd pacd-rs
cargo install --path .

Option 2: Download release binaries

Download release binaries from Releases for your platform.

Usage

Make sure the binary pacd is on your $PATH.

$ pacd help
A static site generator based on shopify liquid

Usage: pacd <COMMAND>

Commands:
  build  Build your site from liquid templates
  pack   Pack your template files into an archive
  help   Print this message or the help of the given subcommand(s)

Options:
  -h, --help     Print help
  -V, --version  Print version

pacd build

The build command copies files recursively from a given <SITE_DIR> into the output-dir. Liquid template files are transformed into html files.

Globals

You can supply globals for use within the template files by passing the data-path argument to the build command. Pacd looks for a json file in the given path and provides them to you as data variable in your template files. For instance if you had a data file that looks like this

{
  "person": {
    "name": "John Doe"
  }
}

You can access this data using the liquid expression {{ data.person.name }}. All standard liquid operators are supported.

Collection templates

Templates with file name having a pattern [my_list].liquid are special. Pacd will look for a key my_list inside your json file. If that key points to an array of objects which at least has an id attribute, then a html file is generated for each item in the array. The output has a name <id>.html.

Note: Pacd assumes ids within the array are unique. Files will get overwritten if they aren't unique.

For collection templates you have access to one extra global variable {{ page.current_index }} which will contain the position of the object in the array being processed. Check the example file to see how the page global is used.

Build your site from liquid templates

Usage: pacd build [OPTIONS] <SITE_DIR>

Arguments:
  <SITE_DIR>  Path to the source files

Options:
  -o, --output-dir <OUTPUT_DIR>  The path for output [default: ./build]
  -d, --data-path <DATA_PATH>    Path to the JSON data [default: ./data.json]
  -w, --watch                    Watch for directory changes
  -h, --help                     Print help

pacd pack

Pack your template files into an archive

Usage: pacd pack [OPTIONS] <TEMPLATE_DIR>

Arguments:
  <TEMPLATE_DIR>  Path to the source files

Options:
  -o, --output-path <OUTPUT_PATH>  The path for output [default: ./build.tar.gz]
  -h, --help                       Print help

Check the examples directory for more usage instructions.

Disclaimer

The tool is very early in development. If you need a general purpose static site generator based on liquid, check out Cobalt

pacd-rs's People

Contributors

ashwins93 avatar

Stargazers

Ananthakumar 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.