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

datocms-plugin-sidebar-link-buttons

v1.0.2

Published

A plugin for automatically generating link buttons in the sidebar. Intended for preview links but flexible enough to do other stuff too!

Downloads

7

Readme

Sidebar Link Buttons DatoCMS plugin

A plugin for automatically generating link buttons in the sidebar. Intended for preview links but flexible enough to do other stuff too!

Setup

Install the plugin

  1. On your DatoCMS dashboard, go to Settings > Plugins and hit the "+" button to add a new plugin.
  2. Search for "Sidebar Link Buttons" and hit "Install"

Add the buttons

  1. Go to the settings for a model you want to display the link buttons alongside.
  2. Add a new field of type: "JSON"
  3. Give the field a name, such as "View Content". This name will be shown as the title of the sidebar section.
  4. In the "Presentation" tab, select "Sidebar Link Buttons" from the "Field Editor" dowpdown, then hit "Save Field".
  5. Create a new instance or edit an existing instance of the model you just saved.
  6. Expand the sidebar and you should see the link buttons.

Point the buttons to the correct URLs

  1. Go back to the settings for the model you updated in the last step.
  2. In the "Presentation" tab, select the "Buttons" field, edit the link for each button you want be displayed, then hit "Save Field".
    • You can substitute any of the numeric or single-line text fields on the entity, including ${id} and ${slug}, or any of the global properties (explained later) using the syntax ${property_name}.

Example:

[
  {
    "text": "${GLOBAL_PREVIEW_TEXT}",
    "link": "${GLOBAL_PREVIEW_BASE_URL}?secret=${GLOBAL_PREVIEW_SECRET}&slug=${slug}"
  },
  {
    "text": "${GLOBAL_LIVE_TEXT}",
    "link": "${GLOBAL_LIVE_BASE_URL}/posts/${slug}"
  }
]

Update the global properties

  1. Go to the settings for the plugin (Settings > Plugins > Sidebar Link Buttons).
  2. Under "Plugin settings" select the "Global Properties field and add/edit/remove the properties that will (or won't) be used.
    • These key/value pairs are made available for substitution when rendering the sidebar buttons.

Example:

{
  "GLOBAL_PREVIEW_TEXT": "Preview",
  "GLOBAL_LIVE_TEXT": "Live",
  "GLOBAL_PREVIEW_BASE_URL": "https://your-domain/api/preview",
  "GLOBAL_PREVIEW_SECRET": "your-secret",
  "GLOBAL_LIVE_BASE_URL": "https://your-domain"
}

Usage

  1. Open an instance of a model which your have added buttons to.
  2. Expand the sidebar.
  3. Click one of the buttons and the browser will open a new tab, taking you to the configured link.

How it looks

Development

Install all the project dependencies with: yarn install

Add this plugin in development mode to one of your DatoCMS project with: yarn addToProject

Start the local development server with: yarn start

The plugin will be served from http://localhost:5000/. Insert this URL as the plugin Entry point URL.

Publishing

Before publishing this plugin, make sure:

  • you've properly described any configuration parameters in this README file;
  • you've properly compiled this project's package.json following the official rules;
  • you've added a cover image (cover.png) and a preview GIF (preview.gif) into the docs folder.

When everything's ready, run: yarn publish