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

gh-blogs

v0.2.2

Published

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

Downloads

50

Readme

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

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

  • [x] 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
  • [x] 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.

  1. create a script build.js at the root fo the repo folder as the script to do the work.
// 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();
  1. 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.