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

contentstack-metalsmith

v0.0.3

Published

A Metalsmith plugin that fetches content from Built.io Contentstack

Downloads

24

Readme

About

A metalsmith plugin to create a static website using Built.io Contentstack.

Example

In order to get started using contentstack-metalsmith, you can checkout our sample app at contentstack-metalsmith-example

Installation

To install contentstack-metalsmith, run the following command in a terminal:

  $ npm install contentstack-metalsmith

Once you’re done with the installation, you will need to edit the index.js file under the root directory in order to use Built.io Contentstack with Metalsmith.

Configuring Globals

The Built.io Contentstack configuration added in the index.js file of the site will be available throughout the site and will be substituted in files where no other Built.io Contentstack specific configuration is provided.

When using the Metalsmith CLI, you’ll need to add contentstack-metalsmith in your metalsmith.json file and provide the API Key and access token of your stack along with the stack environment. This can be done as follows:

  {
    "source": "src",
    "destination": "build",
    "plugins": {
      "contentstack-metalsmith": {
        "api_key": "<<Contentstack Api Key>>",
        "access_token": "<<Contentstack Access Token>>",
        "environment": "<<Stack Environment>>"
      }
    }
  }

In case you are using Metalsmith’s JS API, you will need to add contentstack-metalsmith to the plugins section as follows:

  .use(require('contentstack-metalsmith') ({
      "api_key": "<<Contentstack Api Key>>",
      "access_token": "<<Contentstack Access Token>>",
      "environment": "<< Environment >>"
   }));

Please refer the following to get more information on configuring your global configuration file. Global configuration

Configuring Source Files

Make the necessary configuration changes in your source files which are located under the src/ directory, in the manner: ./src/home.md. Your source file can be of type: .md, .html, etc.:

---
title: contentstack-metalsmith sample demo
contentstack:
  content_type: posts
  entry_layout: post.html
  partials: [header, footer]
layout: index.html
---

The above code snippet will use the configuration provided in your global configuration stack details, and query the stack for content_type: posts. Furthermore, each entry from posts will be rendered using the post.html layout under the layouts/ directory. You will also be able to access the header and footer content types via the header and footer keys in posts.html. Please refer the following to get more information on configuring your source configuration file. Source configuration

Configuring layouts files

Consider the following code snippet of the ./layouts/post.html file:

<!DOCTYPE html>
<html lang="en">
<head>
    <title>{{title}}</title>
</head>
<body>
    <div class=”header”>{{header.title}}</div>
    <div class=”container”>
        <p>Post title: {{entry.title}}</p>
        <p>Post author: {{entry.author}}</p>
    </div>
</body>
</html>

You can use the entry key to access single entry properties (refer above example). Whereas, in index.html pages, you can access data using the entries key, which will be a collection of all entries.