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

netlify-cms-toolkit

v0.0.1-rc15

Published

This toolkit supercharges Netlify CMS with better developer experience.

Downloads

4

Readme

netlify-cms-toolkit

This toolkit supercharges Netlify CMS with better developer experience.

Currently only one tool is available: the compiler.

Install

npm i netlify-cms-toolkit

The compiler

The compiler turns your config.yml and content files (.md, .yml...) into a statically typed, dynamic-import friendly flat-file structure.

What you get:

  • a statically typed index file in TypeScript (see example),
  • splitted assets for each markdown field friendly to dynamic import, including collections with single_file i18n (see examples),
  • a statically schema your contents type-safely in your app.

The compiler is completely agnostic of your site generator, but it has been designed with NextJS in mind.

Using the compiler

> npx netlify-cms-toolkit compile

Compile contents and generate index file

Options:
      --version                   Show version number                  [boolean]
      --config                    Path to JSON config file
      --help                      Show help                            [boolean]
      --cwd                       Working directory (defaults to proces.cwd)
                [string] [default: "/home/elierotenberg/gh/netlify-cms-toolkit"]
      --dryRun                    Dry run (don't write output files)
                                                      [boolean] [default: false]
      --eslintConfig              Custom eslint config fig (e.g. .eslintrc.js)
                                                                        [string]
      --exitOnError               Exit on error in watch mode
                                                       [boolean] [default: true]
      --markdownLoaderIdentifier  Markdown loader identifier within markdown
                                  loader module (e.g. 'default' or 'load')
                                                             [string] [required]
      --markdownLoaderModule      Markdown loader module (e.g. 'next/dynamic' or
                                  '../markdown-loader')      [string] [required]
      --markdownTypeIdentifier    Markdown type identifier within markdown type
                                  module (e.g. 'default' or 'MDXContent')
                                                             [string] [required]
      --markdownLoaderParamsIdentifier  Markdown loader params identifier within
                                        markdown loader params module (e.g.
                                        'default' or 'getLoadParams')
                                                             [string] [required]
      --markdownLoaderParamsModule      Markdown loader params module (e.g.
                                        '../markdown-loader-params')
                                                             [string] [required]
      --markdownTypeModule        Markdown type module (e.g. '*.mdx' or
                                  '../markdown-content')     [string] [required]
      --narrowSlugs               Narrow slug types to match parse results
                                  (instead of 'string')
                                                      [boolean] [default: false]
  -o, --outFolder                 Output folder              [string] [required]
  -r, --raw                       Include raw contents[boolean] [default: false]
      --saveParseResult           Save intermediate parse results
                                                      [boolean] [default: false]
      --saveEmitResult            Save intermediate emit results
                                                      [boolean] [default: false]
  -i, --schema                    Netlify config file (config.yml)
                                                             [string] [required]
  -s, --silent                    Suppress console output
                                                      [boolean] [default: false]
      --sourceLocation            Include source location in output
                                                      [boolean] [default: false]
      --useLockfile               Use lock file to avoid write conflicts
                                                       [boolean] [default: true]
  -w, --watch                     Recompile on changes[boolean] [default: false]

You can provide a configuration file (see example).

Power of static typing

Compiled index.ts provides a very robust and safe framework for working with contents.

For example, you can create a BlogPost React component that will render contents from a folder collection:

import { contents, Schema } from "./src/contents/out/assets";

type BlogPost = Schema["collection"]["blog_post"];

const BlogPost: FunctionComponent<{ slug: string }> = ({ slug }) => {
  const blogPost = contents.blog_post.find(
    (blogPost) => blogPost.slug === slug
  );

  if (!blogPost) {
    return <NotFound />;
  }

  return (
    <div>
      {blogPost.title} {/* <== type safe */}
      <blogPost.body /> {/* <== type safe */}
    </div>
  );
};

Watch mode

Compiler can be used in watch mode, i.e. watch your schema and contents and recompile on change.

This is especially useful in dev mode with hot reloading. For example, if you are using NextJS, then you can add the following to your package.json:

{
  "scripts": {
    "next:dev": "next dev",
    "netlify-cms:proxy": "netlify-cms-proxy-server",
    "netlify-cms:watch": "netlify-cms-toolkit compile --config netlify-cms-toolkit-compiler.config.json",
    "dev": "concurrently 'npm run next:dev' 'npm run netlify-cms:proxy' 'npm run netlify-cms:watch'"
  }
}

Watch mode tries to be atomic, i.e. to write all contents at once to avoid tripping Webpack or other filesystem watchers.