New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

gh-blogs

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gh-blogs

The lib to symulate manage blogs through Github repo with fildDB easily.

latest
Source
npmnpm
Version
0.2.2
Version published
Maintainers
1
Created
Source

Github Blogs

The lib to symulate manage blogs through Github repo with fildDB easily.

Motivation

  • Github is Free to build Github Pages
  • Yaml favoured Markdown
  • Comfort to working with Github flows
  • Good experience with modify files in the Github Editor

Features

  • Use independent repo as blogs, SRP(Single Responsibility Principle)

  • Use file DB to simulate oprations with blogs instead files.

    • Load all blog meta info
    • Load a blog by ID and catch for next time view on site
    • Able to search within browser
  • Easy to generate blog index

TODO:

  • Add exceptions folders
  • Add load process event info
  • Auto build blog index with CI/CD
  • Use repo issues to save and manage comments

Usage

Use Locally

Generate the blogs index based on the Github YAML favoured Markedown file, and save it to a file for later to use. It it not need when later update the content in Github.

Blogs should be nested in any level under the blog folder, all the nested will be take as the categories of the blogs.

// build.js
const GHBlog = require('gh-blogs');

const blogRepo = 'https://github.com/ole3021/blogs';
const options = {
  folder: './blogs', // path for the blogs folder
  dbFile: './blogs.db' // file path for the db file
};

const myBlogs = new GHBlog(blogRepo, options);

const dumpFile = async () => {
  try {
    await myBlogs.dumpFile();
    console.log('>>> Generate successfully.');
  } catch (error) {
    console.log('>>> Faild to generate index', error);
  }
};

dumpFile();
  • add all the files and commit to the master branch of the repo.

Load from remote

Use this lib as a DB in memoyr with load the generate file.

const GHBlogs = require('gh-blogs');

const blogRepo = 'https://github.com/ole3021/blogs';
const options = {
  folder: './blogs', // path for the blogs folder
  dbFile: './blogs.db' // path for the db file
};

const myBlogs = new GHBlogs(blogRepo, options);
const init = async () => {
  await myBlogs.loadRemote(); // will load data from the repo remotely

  const allBlogMetaInfo = myBlogs.getAll();
  const aBlog = myBlogs.get('The _id in the meta info');
};

Details

  • File create date and last modified data will be use as createdAt and updateAt in the meta info
  • Use yaml info in header to save any other meta info you like, eg title, intro, cover, themeColor and etc.
  • English file will have id whith the file name which will be replaced all non alphabet char will be replace by '_'
  • Non-English file will have a short hash id generate as the id(like Zldfjz) in the meta info.
  • When get blog with id, the lib will fetch the blog remotely and then catch it in memory.

FAQs

Package last updated on 18 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts