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

cmslab

v3.0.1

Published

a git-based cms package that provide variase composables to interact and create a content-based website/command line tool

Downloads

10

Readme

CMSLab is a github-based CMS package that provide variase functionality to fetch and built a CMS on top of GitHub API

the package is open-source, means you can customize the functionality exactly as you want. if you've developed something unique and want to include your code on the next release, Please contact me Here or send an email to [email protected]

Installation

tip: Always use CMSLab latest version to receive recent updates and bug fixes

to install CMSLab on your project, go to your project directory and run:

npm I cmslab@latest

after installing the package, you can import and use the functionality from boath cjs and mjs:

// example.cjs
const cms = require('cmslab');
cms.configure({user: 'github', repo: 'docs'});
async function main() {
const content = await cms.searchContent({input: 'API'});
console.log(content);
}
main();

or in mjs:

// example.mjs
import cms from 'cmslab';
// you can also use tree-shakable sintacs to import only the function that you need:
// import {configure, searchContent} from 'cmslab';
cms.configure({user: 'github', repo: 'docs'});
async function main() {
const content = await cms.searchContent({input: 'API'});
console.log(content);
}
main();

features

Here is the list of features that CMSLab version 3.x supports. we're regularly observing the usage patern of our package to built new features

  • Configure metadata: to remember your configuration so you do not need to pass the same informations again and again

  • Authenticated Requests: to get more rate-limit on GitHub API

  • extract user information, repozatory information, and file path from an GitHub URL: to extract and process any data from a plane GitHub link

  • formatNavigation: a function to format a GitHub response and return an structured Array to create a sidebar

  • getList: fetch the List of articles from a relative or apsilute path

  • getSingle: fetch a single article from a filename

  • built-in excerpt and last updated date extraction fasility: to display on your archive or post page

  • searchContent: to lookup about a specific text on your base directory(and/or any subdirectory)

complete usage

configure metadata to use on all requests

note: you can override any metadata by passing it to the options object in the specific function

cms.configure({
user: "GitHub", // your GitHub username
repo: "docs", // your GitHub repo to lookup articles
path: "", // any base path you want to set by default. leave it to set a blank path("")
token: null // your GitHub personal token to make authenticated requests. leave it to make unauthenticated requests
});

get list of articles

// getting the list of articles from the default path
const articles = await cms.getList();
// passing our own options(you can pass any valid options similar to the configure function)
const articles = await cms.getList({path: "src"});
console.log(articles);

search Content

const content = await cms.searchContent({input: "API"});
console.log(content);

get a single article

const single = await cms.getSingle({filename: "src/account/using-profile.md"});
console.log(single);

extracting informations from a plane,github URL

const url = "https://github.com/github/docs/src/account/introduction.md";
const metadata = cms.getInfo(url);
console.log(metadata);

formatting a GitHub rest API response to create a sidebar

const sidebar = cms.formatNavigation(response);
console.log(sidebar);

response object

the response Object is contains 2fields:

  • data: the main field for success responses. for list of posts, the data is an Array and for single post, the data is an Object
  • error: a string containing the error message if the response encountered an error while processing if the response successful, the error field will be null and if the response encountered an error, the data field will be null

for list of posts, the data field should looks like:

[
{
"name": "something.md",
"path": "src/something.md",
"link": "https://api.github.com/repos/user/repo/contents/src/something.md?ref=main/src/something.md",
"type": "file",
"updated": "2024-08-23T07:17:54Z",
"excerpt": "once apon a time, there [...]",
"content": "full content"
},
{...},
...
]

and a single post's response is the same but this time, the response will be just a single item instead of Array of items

feature requests

I welcome new feature requests. please contact me here or send an email to m at [email protected]