GithubHelp home page GithubHelp logo

hashicorp / netlify-to-nextjs-redirect-exporter Goto Github PK

View Code? Open in Web Editor NEW
5.0 6.0 2.0 769 KB

Convert Netlify redirects into Next.js-compatible redirects

License: Mozilla Public License 2.0

JavaScript 47.07% TypeScript 52.93%

netlify-to-nextjs-redirect-exporter's Introduction

C/I

netlify-to-nextjs-redirect-exporter

A Node.js library and CLI that converts a Netlify _redirects file into compatible Next.js redirect/rewrite rules

Installation

npm i @hashicorp/netlify-to-nextjs-redirect-exporter

Usage

Node.js

// next.config.js
import { parseNetlifyRedirects } from "@hashicorp/netlify-to-nextjs-redirect-exporter";

const contents = fs.readFileSync("/path/to/_redirects/file", "utf8");

// `parseNetlifyRedirects()` will return an object with two keys:
// `rewrites` and `redirects`, each containing an array of corresponding rules
const { rewrites, redirects } = parseNetlifyRedirects(contents);

module.exports = {
    async rewrites() return rewrites
    async redirects() return redirects
}

CLI

Using the export-netlify-redirects CLI will create two files: rewrites.next.js and redirects.next.js, each containing an array of corresponding rules.

$ ./node_modules/.bin/export-netlify-redirects ./_redirects

Writing redirects file to redirects.next.js...
Writing rewrites file to rewrites.next.js...
Done.

Active Development

npm i
npm run watch

Run tests

npm t

netlify-to-nextjs-redirect-exporter's People

Contributors

calebalbers avatar pruett avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

netlify-to-nextjs-redirect-exporter's Issues

GitHub Actions - deprecated warnings found - action required!

Workflow Name: C/I
Branch: master
Run URL: https://github.com/hashicorp/netlify-to-nextjs-redirect-exporter/actions/runs/3914050584

save-state deprecation warnings: 0
set-output deprecation warnings: 0
node12 deprecation warnings: 1

Please review these deprecation warnings as soon as possible and merge in the necessary updates.

GitHub will be removing support for these commands and plan to fully disable them on 31st May 2023. At this time, any workflow that still utilizes these commands will fail. See https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/.

GitHub have not finalized a date for deprecating node12 yet but have indicated that this will be summer 2023. So it is advised to switch to node16 asap. See https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/.

If you need any help, please reach out to us in #team-rel-eng.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.