Coder Social home page Coder Social logo

teezzan / abell Goto Github PK

View Code? Open in Web Editor NEW

This project forked from abelljs/abell

0.0 0.0 0.0 394 KB

Abell is a static site generator that generates blog in Vanilla JavaScript ⚝

Home Page: https://www.npmjs.com/package/abell

License: MIT License

JavaScript 100.00%

abell's Introduction

logo of abell Abell

GitHub package.json version

Abell is a static blog generator that generates blog in Vanilla JavaScript

NOT READY ENOUGH TO USE IN PRODUCTION. ☠️

The API is not finalised so I will be breaking the functionality a lot.

📖 Documentation for Contributors

This documentation is only for the people who want to help me in making Abell!

Table of Content

1. Create your site

Deploy to netlify button below will create copy of Abell Starter Project in your GitHub and will deploy it to Netlify and boom! that's it 🎉

Deploy to Netlify Button

REMEMBER! ABELL IS NOT READY! SO DON'T GET TOO EXCITED TO CREATE AN ACTUAL PRODUCTION BLOG WITH THIS.

Write/Edit Content

You can edit markdown files from ./content directory in your repo to edit content.

To test your blog, you can either run your site locally or open your site's github repository in CodeSandbox

Run your site locally

  • You can git clone <project-github-url>
  • cd <project-name>
  • npm install
  • npm run dev to run a dev server and npm run build to create final build.

2. Abell Guide

Abell Configs

Sample abell.config.js:

module.exports = {
  sourcePath: 'src', // path of source where index.abell and [content]/index.abell are located
  destinationPath: 'dist', // Build destination
  contentPath: 'content', // Content Path which has .md 
  globalMeta: { // All the global variables
    siteName: 'Abell Demo', 
    author: 'Saurabh Daware',
    foo: 'bar'
  }
}

Variables in Abell

Abell lets you use variables inside your .abell files.

Content specific variables

Your content may sometimes have meta data like title, og:image, etc. which is dynamic (different for different content). You can set this meta info from ./content/<content-slug>/meta.json.

Example ./content/<content-slug>/meta.json

{
  "title": "Another blog",
  "description": "Amazing blog right",
  "foo": "bar"
}

These variables can be accessed from ./src/[content]/index.abell with {{ meta.title }}, {{ meta.description }}, {{ meta.foo }}

Global variables

You can add your variables in globalMeta property inside abell.config.js file and access those variables from .abell files with {{ globalMeta.<key> }} (e.g {{ globalMeta.siteTitle }})

Predefined variables

In addition to Content Specific Variables and Global Variables, Abell has some predefined variables to provide required meta data about the content.

Predefined variables start with $ and are accessible from .abell files.

List of predefined variables

Variables description Example Value
meta.$slug Folder name of content, used as slug my-cool-blog
meta.$createdAt Date & Time of creation of content. Sun Apr 30 2020
meta.$modifiedAt Date & Time of last modification of content. Thu May 20 2020
$contentList Array of all 'meta' values from content [{title: 'Cool Blog', $slug: 'my-cool-blog'}, {title: 'Nice blog', $slug: 'nice-blog-69'}]

Loops in Abell

Starting from v0.1.12, Abell uses abell-renderer for rendering.

You can use JavaScript methods within {{ and }} so to loop through an object and generate HTML, you can use .map() method from JavaScript.

Note: The JavaScript you write inside {{ and }} compiles on build time and runs in NodeJS context so you cannot use frontend JavaScript methods from DOM

Example 1

Let's say we have this object in variable $contentList

// $contentList
[
  {
    title: 'Cool Blog', 
    $slug: 'my-cool-blog',
    $createdAt: 'Sun Apr 30 2020',
    $modifiedAt: 'Wed May 10 2020'
  }, 
  {
    title: 'Nice blog', 
    $slug: 'nice-blog-69',
    $createdAt: 'Sun Apr 06 2069',
    $modifiedAt: 'Wed May 09 2069'
  }
]

We can loop $contentList with,

<div class="article-container">
{{ 
  $contentList
    .map(meta => `
      <article>
        <a href="${meta.$slug}"><h2>${meta.title.toUpperCase()}</h2></a>
        <p>Created at: ${meta.$createdAt}</p>
      </article>
    `).join('')
}}
</div>

outputs:

<div class="article-container">
  <article>
    <a href="my-cool-blog"><h2>Cool Blog</h2></a>
    <p>Created at: Sun Apr 30 2020</p>
  </article>
  <article>
    <a href="nice-blog-69"><h2>Nice Blog</h2></a>
    <p>Created at: Sun Apr 06 2069</p>
  </article>
</div>
Example 2

Let's say we have globalMeta.foo as,

['Hi I am 1', 'John Doe', 'Lorem Ipsum']
<div>
  {{ 
    globalMeta.foo
      .map(content => `<b>${content}<b>`)
      .join('')
  }}
</div>

outputs:

<div>
  <b>Hi I am 1</b>
  <b>John Doe</b>
  <b>Lorem Ipsum</b>
</div>

You can also use other JavaScript methods within {{ }}

3. Contributing to Abell

This repository contains the code that builds the Abell Website. If you want you can also contribute to other repositories in this organization that deal with starter-templates, vscode extension for .abell files, etc.

Local Setup of Abell Builder

  • Fork this repository
  • git clone {url of your fork}
  • cd abell
  • npm install to install dependencies
  • npm run dev:build to build static site!

and you will have your website in ./demo/dist

To run a DEV server, you can run npm run dev:serve which will serve the website on localhost

Creating Pull Request

  • Create a branch with name of feature you are working on. (e.g. feat-abell-config, fix-serve-fails, etc)
  • Make changes in your locally cloned fork
  • Send Pull Request from your branch to master of main repository.

npm run dev:build is equivalent to abell build and npm run dev:serve is equivalent to abell serve

Changelog

Changelogs are maintained in CHANGELOG.md


Buy me a Coffee Button   Buy me a Coffee Button

If you want to know the status and get updates you can follow me on Twitter @saurabhcodes

abell's People

Contributors

0xflotus avatar prafulla-codes avatar saurabhdaware 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.