npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

enginaer

v4.1.3

Published

A simple web site engine with javascript.

Downloads

6

Readme

Enginær

Enginær is a simple static website engine.

Motivation

While developing, my motivation has been to easily publish a new post or a new page, like sending a new commit message to a git repository.

I like writing blogs, but I cannot have enough time. I know writing markdown is so easy and also the markdown document has a human-readable structure. Moreover, markdown documents also support many components that using in HTML documents is not easy such as tables, images, and lists.

Publish Test Project HitCount GitHub top language GitHub npm Vulnerabilities Bugs Code Smells

Challenges

Creating a blog engine there are some challenges. The first one is to create an automation for converting markdown documents into HTML documents. For this operation, I am using the marked library. The second challenge is creating a simple and extendable template system. The mustache library is the simple and logic-less template engine that is suitable for this challenge.

Apart from all of the other challenges, executing operations in parallel or serial order I need to develop an automated pipeline system. gulp is a flexible and repetitive system. I selected gulp and the main part of the project stands a gulp plugin.

gulp markdown markedjs mustache NodeJs Github Actions SonarCloud Glob

Usage

The usage of the tool is very easy if you have selected your blog template or blog layout and its style.

Install

npm install --save-dev enginaer

Import References

First of all import all required references.

const { series, parallel, src, dest } = require("gulp");
const clean = require("gulp-clean");
const enginær = require("enginaer");

Configuration

The configuration is very basic and user friendly.

const config = {
    "base": __dirname,
    "page": {
        "path": "./page/**/*.md",
        "visitor": "./page/**/*Visitor.js",
        "marked": {
            breaks: true,
            smartLists: true,
            headerIds: false
        }
    },
    "template": {
        "path": "./template/*.mustache",
        "helpers": "./template/templateHelpers.js"
    },
    "site-title-prefix": "Enginær - ",
    "site-name": "Enginær Demo",
    "base-url": "https://blog.tatoglu.net/enginaer/"
};

Configuration Description

| Attribute | | Description | Type | | :--- | :---: | :--- | :-- | | base | | The base path of the resources. Usually you can set __dirname. | string | | page | | The page object | object | | | path | The page folders paths. | glob | | | visitor | The page visitors paths. | glob | | | marked | The marked configuration. Reference: markedJS Options | object | | template | | The template object. | object | | | path | The templates paths. | glob | | | helpers | The render helper functions paths. | glob | | site-title-prefix | | The website title prefix. | string | | site-name | | The name of the website. | string | | base-url | | The website base url. | string |

For more details about glob data type.

Execution Steps

After defining the configuration, there are there main steps.

Initialization

var enginær = new Enginaer(config);

In this step, the engine is initialized. While initilization, if the engine is faced any invalid or missing configuration, will throw an exception.

Loading Resources

enginær.load();

This step is required for loading mandatory resources validation and processing in the engine. While loading resources engine could throw any exceptions, if the resource is not valid.

The loading steps work in the following order.

  1. Templates
  2. Template Helpers
  3. Page Visitors
  4. Pages

Generation

enginær.generate();

At the end, the engine is ready to generate web site pages.

Sample Gulpfile

For putting all execution step together the sample gulp file is below.

const outputPath = "../dist/";

// Gulp Step 1 - Clean old files.
function cleanAll() {
    return src(outputPath, { allowEmpty: true })
        .pipe(clean({ force: true }));
}

// Gulp Step 2 - Copy all required assets.
function copyAssets() {
    return src(["./assets/css/*.css",
        "./assets/js/*.js",
        "./assets/img/*.png",
        "./assets/img/*.jpg"], { base: "./assets/" })
        .pipe(dest(outputPath));
}

// Gulp Step 3 - Enginær
function generate() {

    // Initialize enginær engine.
    var enginær = new Enginaer(config);

    // load required resources (templates, template helpers, pages, and page visitors.)
    enginær.load();

    // Generate web site pages.
    return enginær.generate()
        .pipe(dest(outputPath));
}

exports.default = series(
    cleanAll,
    parallel(copyAssets, generate)
);

Customization

The enginær.generate method return file stream. If you want to customize the output, you should add new pipe steps.

The other customization options are Page Visitors and Template Helpers.

Page Visitors

This customization step provides adding new key-value pair in the page metadata. The page visitors are applied for all pages after loading and for each page object.

The page visitor must be extend from BasePageVisitor class.

class BasePageVisitor {
    name: string;
    visit(page:Page):Error | undefined;
}

Template Helpers

This customization step provides helpers for rendering mustache templates. There is one restriction that must be returns an object such as the below example.

module.exports = {
    "helper-name": function () {
        return "sample-code";
    }
};

Execute

After creating gulpfile.js the system is ready to execute. For executing follow the below steps.

# Step 1. Install NPM Packages
npm install

# Step 2. Install Gulp CLI
npm install --global gulp-cli

# Step 3. Execute Enginær
gulp

That's all. For demo you can visit Enginær Demo site.

Support

For supporting me, you can add an issue for bug cases or new feature requests.