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/delivery-plugin-interstack-reference

v1.0.0

Published

This is a SDK plugin for Interstack Reference App. This plugin fetches the referenced entry data through a custom field to display the content on your Contentstack website. Contentstack has its own [Javascript Delivery SDK](https://www.contentstack.com/do

Downloads

17

Readme

Interstack reference

This is a SDK plugin for Interstack Reference App. This plugin fetches the referenced entry data through a custom field to display the content on your Contentstack website. Contentstack has its own Javascript Delivery SDK that supports this plugin which can be used to fetch the content for your page from Contentstack for Interstack Reference app.

About Interstack Reference App

Interstack Reference App allows you to fetch referenced entries in the custom field of your content type and use the entries data across multiple stacks.

How to use this plugin

To use this plugin, you need to add the includeReference call within your SDK.

  1. Install the interstack plugin from the NPM library.
npm install @contentstack/delivery-plugin-interstack-reference
  1. Import the plugin
const InterstackPlugin = require("@contentstack/delivery-plugin-interstack-reference");
  1. Create an Interstack Reference App plugin as shown below. You must provide the stack API Key and Delivery Token of all the referred stack.
function main() {
    const interstack = new InterstackPlugin([
        {
            api_key: "blt53ed****888672",
            delivery_token: "cs9b84666******c49f48",
        },
        {
            api_key: "blt7a********053b38",
            delivery_token: "cs47178********e5ba15e",
        },
    ]);
}
  1. Now, create a new stack and call the plugin within this function. This will basically fetch the plugin details and attach it with the Contentstack data.
const Stack = contentstack.Stack({
    api_key: "bltc18****3d910",
    delivery_token: "csc030300****8914a00",
    environment: "dev",
    plugins: [interstack], // Here we have added the plugin
});
  1. To select the entry which is being used in the custom field, you will have to create a query and add the field_uid of the custom field inside includeReference() method.
const query = Stack.ContentType("cs1")
    .Query()
    .includeReference("custom")
    .toJSON();
  1. Now, to find the content you need to add the below function:
query
    .find()
    .then((res) => {
        console.log(JSON.stringify(res, null, 2));
    })
    .catch((err) => console.error(err));

Example Code:

const InterstackPlugin = require("@contentstack/delivery-plugin-interstack-reference");

function main() {
    const interstack = new InterstackPlugin([
        {
            api_key: "blt53ed***8672",
            delivery_token: "cs9b84666****efc49f48",
        },
        {
            api_key: "blt7ae6****53b38",
            delivery_token: "cs471781****7e5ba15e",
        },
    ]);

    const Stack = contentstack.Stack({
        api_key: "bltc1875****b3d910",
        delivery_token: "csc030300***8914a00",
        environment: "dev",
        plugins: [interstack],
    });

    const query = Stack.ContentType("cs1")
        .Query()
        .includeReference("custom")
        .toJSON();

    query
        .find()
        .then((res) => {
            console.log(JSON.stringify(res, null, 2));
        })
        .catch((err) => console.error(err));
}