Giter Club home page Giter Club logo

sold's Introduction

Sold

A minimal static blog generator.

Getting Started

Run this to install Sold

$ npm install sold -g

Usage

  1. Create instance of Sold in soldfile.js
const Sold = require("sold");

Sold({
  root: __dirname, // root folder (default is current working directory)
  template: "template", // template folder relative to root (default is "template")
  source: "src", // source folder relative to root (default is "src"),
  destination: "build", // destination folder relative to root (default is "build")
  engine: "handlebars", // template engine (default is "handlebars")
  engineOptions: {} // template engine options (default is {})
});
  1. Create or download a template and put it in the template directory.

  2. Create a folder called src (or whatever you named the source).

  3. Inside, create another folder called posts, this is the directory your posts will be in.

  4. To make a new post, make a markdown file, for example post.md. Put some metadata at the top to let Sold know of the title and description of the post, then put your content. For example:

---
title: First Post
description: My very first post
---

Hey! This blog post was made with [Sold](https://github.com/kbrsh/sold).
  1. Run
$ sold
  1. Check out the generated files in the build/ directory.

Templates

A template should be in the file declared in the template option of an instance. Sold will, by default, search in the template directory.

index.html

This file should contain the home page. It will be provided all section names as values holding arrays of the posts in that section.

post.html

This file should contain the template used for each post. All contents of the metadata provided at the top of each post's markdown content is provided in a template here, and the HTML for the post is provided in content. The HTML code should be unescaped.

The subdirectory it was in will be provided in section, the file name will be provided in file, and a map of sections to post arrays will be provided in posts. If an order option is defined in the metadata, then the posts will be given in ascending order using the value.

<h1>{{title}}</h1>

<p>{{section}}</p>
<p>{{file}}</p>

{{#posts.posts}}
	{{title}}
{{/posts.posts}}

{{{content}}}

Template Engine

Setting up a template engine can be done with the engine option, to setup an engine. Currently the supported engines are:

  • Handlebars (default)
  • EJS
  • Pug

The engine option can also be a function that calls a callback with a result when given a template, data, and options.

function engine(template, data, options, done) {
  configure(options);
  done(compile(template, data));
}

License

Licensed under the MIT License

sold's People

Contributors

kbrsh avatar december364 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.