Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gatsby-plugin-contentstack-client-side-redirect

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gatsby-plugin-contentstack-client-side-redirect

Generates client side redirect html files for redirecting on any static site host like s3 or netlify.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

gatsby-plugin-contentstack-client-side-redirect

Generates client side redirect html files for redirecting on any static site host like s3 or netlify.

It uses window.location.href = url for redirection and createRedirect action provided by Gatsby

Install

npm install --save gatsby-plugin-contentstack-client-side-redirect

How to use

//  Register this plugin in gatsby-config.js
plugins: [
  `gatsby-plugin-contentstack-client-side-redirect`,
  `gatsby-plugin-client-side-redirect` // make sure to put last in the array
];

For contentstack specific only -

Steps -

  1. Create a contenttype named as Redirects
  2. Create a group named as urls_mapping inside Redirects contenttype
  3. Create two text fields as old_url and new_url and save it
  4. Now enter pairs of old and new urls for redirection!

Have a look at the code if you are interested :)

const response = await graphql(`
query redirects {
  allContentstackRedirects {
    edges {
      node {
        urls_mapping {
          old_url
          new_url
        }
      }
    }
  }
}`)

const allEntries = response.data.allContentstackRedirects.edges
let urls

if (allEntries)
{
  allEntries.forEach(entry => {
    urls = entry.node.urls_mapping

    if (urls)
    {
      createRedirect({ fromPath: urls.old_url, toPath: urls.new_url, isPermanent: true })
    }
  })
}

Keywords

FAQs

Package last updated on 25 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc