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

@notepad/cms-tools

v1.0.5

Published

cms-tools for static content repositories

Downloads

7

Readme

CMS-updater

Server module for reading and updating content files. This would generally used as a dev-tool in a static build process such as with JAMStack websites. However, it is completely unopinionated, so you can use it to manage any set of content documents, even with no associated website.

Notepad content tools read local content files (generally Markdown documents) and sychronize content into a lightweight database. You can then use that data to build site feature on both the server-side and the client side. You can even build editing tools to update the content.

To use, you will first need to set up a configuration file which defines your content types and how to read them.

To Install:

  npm install @notepad/cms-updater --save-dev

To Use

You can use the tool (synchronously) to sync local content with database and then use the data.

  const = import updater from "@notepad/cms-updater"
  updater.sync_content() // update database from content and content files from database

  // filter, sort, fetch details, set
  let all_articles = updater.get() // returns a list of all ids
  let sorted_articles = updater.get({_sort: 'pubdate'}). // returns a list ids sorted by pubdate
  let pet_articles = updater.get({lang:'en', _sort: 'pubdate'}) // returns list limted to lang=en and sorted by pubdate
  let pet_articles_meta = updater.get({lang:'en', _sort: 'pubdate'}, 'meta') // fetch details for one or more article ids
  let pet_article = updater.get(pet_articles[0], 'all') // use an article id (or array of ids) to fetch content

  // All fields are from document graymatter except for those with underscore. These are generated or required
  // _sort, _html, _ver, _crc, _id, _type, _prefix, _permalink

  // modify source object and some metadata then save
  pet_article.source = pet_article.source.replace(/cat/g, 'dog')
  pet_article.animal = 'dog'
  updater.set(pet_article) // updates db but also updates `pet_article` with new _html, _ver, _crc etc.


  // add a new object -- will be validated against document definition
  let new_obj = {lang: 'en', animal: 'dog', pubdate='2019-10-5', src="# Let's get Started {.title}"}
  updater.set(new_obj) // adds object and returns new doucument id if none

To Configure

To configure, you'll need to create an account at notepad.com. If you want to add another developer, add them inside the account and they will be sent a verification link.

Inside your project folder, initialize your project:

> npm notepad_content init

This will add your

notepad.config.json5: (a JSON5 file)

{
  project: 'KidCo Pet Catalog',

  // enumerate content types, file location, default sort order and url of each
  content:  {
    article: {label:'Pet Articles', path:'content/articles', _sort: 'pubdate', _url: "{pubdate}_{stub}_{lang}" }
  },

  // enumerate the fields for each content type
  fields: {
    article: {
      title:  {type: 'string', required: true, maxlength: 50, minlength: 0, default: ''},
      author: {type: 'string', required: true, default: 'unknown'},
      pubdate: {type: 'date', required: true, default: '{{today}}'},
      published: {type: 'boolean', required: true, default: false},
      status: {type: 'option', options:'draft|unapproved|approved', required: true, default: 'draft'},
      lang: {type: 'string', required: true, default: 'en'},
      tags: {type: 'set', required: false, default: ''}, // a set is comma-delimited
      category: {type: 'string', required: true, default: 'dogs'},
      stub: {type: 'string', required: true, default:"{{stub}}", hidden: true}, // default from title
      likes: {type: 'integer', required: true, default: 0, hidden: true}
    },
  }
}

Tasklist

  • [x] Create Readme with basic definition
  • [x] Create cms-updater repository
  • [x] Init NPM with scope (@notepad.com/cms-tools)
  • [x] Publish initial NPM module to reserve name
  • [x] Command-line interface (very simple, just 'sync')
  • [x] Init -- create default config
  • [ ] Init -- check for required content processor stack (like marked or markdown-it)
  • [ ] Sync -- Load content
  • [ ] Sync -- Validate content
  • [ ] Sync -- Update databse
  • [ ] Sync -- Copy assets to static
  • [ ] Sync -- Optimize images on copy
  • [ ] Reader -- sync
  • [ ] Reader -- get
  • [ ] Reader -- filter
  • [ ] Reader -- sort
  • [ ] Reader -- validate
  • [ ] Reader -- set
  • [ ] Reader -- watch
  • [ ] Split out read-only reader as exported object
  • [ ] Build read-only reader as min.js
  • [ ] Init -- integrate login