Giter Club home page Giter Club logo

nima's Introduction

Nima

Simple static website generator in Nim

Installation

This project is currently in progress.

git clone https://github.com/andrewvy/nima
cd nima

# If you want to use Nimble
nimble install

# Else, you can manually compile the binary
nim c nima.nim

Get Started

Initialize a new Nima project!

nima init -vs new_project_folder

Compile and build the seed data! cd new_project_folder nima build

Usage

    nima - static website generator in Nim

    Usage:
        nima init [-vs] [<project_name>]
        nima serve
        nima build
        nima seed <type> <name>
        nima -h, --help
        nima --version

    Options:
        -h, --help                 Show this screen
        --version                  Show version.
        -v                         Toggle verbose mode.
        -s                         Generates with seed data.

nima's People

Contributors

andrewvy avatar

Stargazers

Shinichi Tanaka avatar TAKAHASHI Hidetsugu avatar BOYCOTT GITHUB COMMUNIST SCUM! avatar Christian Bagley avatar

Watchers

James Cloos avatar  avatar

Forkers

sept-27

nima's Issues

HTML Templating

https://github.com/onionhammer/nim-templates

Pages are static layouts.
Posts are based off of single.html.
Posts are exposed via a Posts object which you can iterate over in your main page template layout.

Layouts must be parsed to find if they have partials in them. If they do, insert the HTML from partial into that layout file.

Partials cannot have embedded partials. (future?)

  • Layouts can have partials
  • Layouts can be static, which means they can be immediately rendered without content. about.html / contact.html ... etc
  • Content can specify their layout render type. Else, we should default to default content layout.
  • Render method that takes a template string and arguments, and returns a rendered string.

Nima Generate

  • Refactor to be generate instead of seed.
  • Be able to generate compiled layout under a given name. (new content type template)
  • Be able to generate a static page under a given name. (new about me page)
  • Be able to generate partials under a given name. (new navbar partial)
  • Be able to generate content under a given name. (new blog post!)

Content rendering

  • Parse content markdown for the frontmatter JSON.
  • Make sure the above has appropriate error messages.
  • Figure out a way to implement string templating.

Refactor to use Files instead of custom file type

That's what they're supposed to be used for!

That way we can buffer and mark files that contain partials as we're reading them from the file, rather than importing all files into memory.

How we can do this:

We skip reading the partials folder/files until we've properly marked the other files.
Then, we read the partials and inject them where we need to.

READ index.html
Found partial header.html at line 2

READ partials/header.html
partials/header.html is needed at index.html line 2
REPLACE index.html buffer at line 2 with contents of partials/header.html

Serve static files

nima serve --port=3000 should spin up a quick development web server with automatic file watching/compilation.

  • Must wrap Jester or implement simple async static file webserver
  • File watchers using fsmonitor (windows support pending)

Build Process

Async/Parallel build process

  1. Partial Build/Caching - Inject partials in partials, then cache into the PartialCache
  2. Template Build/Cache - Inject partials into templates and then output into TemplateCache. One process per template type.
  3. Content Render - Content fetches their template type from the TemplateCache and renders out the compiled HTML, which then gets outputted into the template type directory.
  • Parallel builds! SPEED IT UP!
  • Partial/Layout/Content dependency tree - So we can efficiently compile those that are dependent on each other.

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.