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

apostrophe-redirects

v2.4.2

Published

Allows admins to create redirects within an Apostrophe site

Downloads

644

Readme

This module allows admins to add redirects from one URL to another within an Apostrophe site.

This version is for Apostrophe 2.x. For Apostrophe 0.5 use the 0.x series.

Table of Contents

Installation

First make sure you have an Apostrophe project!

Then:

npm install --save apostrophe-redirects

Configuration

In app.js, add the module to your configuration:

// Other modules, then...
'apostrophe-redirects': { }

If you wish, you can change the default status code to 301 (permanent redirect):

// Other modules, then...
'apostrophe-redirects': {
  statusCode: 301
}

Note that permanent redirects are cached by Google for a long time. It is a good idea to encourage users to test with a temporary redirect first, then switch to permanent which is an SEO best practice — as long as it's correct.

That's it!

Usage

While logged in as an admin, click the "Redirects" button. A list of redirects appears, initially empty. Add as many redirects as you like. The "from" URL must begin with a /. The "to" URL may be anything and need not be on your site. The "description" field is for your own convenience.

By default a redirect includes any query string (the ? and whatever follows it, up to but not including any #) on incoming requests when matching for redirection. You can toggle the "ignore query string when matching" option in a redirect definition to ignore query strings on incoming requests and only match on the base URL path. A redirect that does not use this option will always match first, so you can match various specific query strings and then have a fallback rule for other cases.

Be aware that each redirect is live as soon as you save it and that it is possible to make a mess with redirects. In a pinch, you can remove unwanted redirects via the MongoDB command line client (look for { type: "apostrophe-redirect" } in the aposDocs collection in MongoDB).

Also be aware that Apostrophe already creates "soft redirects" every time you change the slug of a page. So you shouldn't need manually created "hard redirects" in that situation.

Advanced configuration with pieces

If you have pieces on your site and you would like to make a safer more persistent redirect that will update if your redirect destination changes, you can use polymorphic joins. To do this you need to add your piece(s) when configuring the module:

'apostrophe-redirects': {
  withType: ['apostrophe-page', 'product']
}

Note: When adding your own pieces, you should always define apostrophe-page to still make it possible to redirect to any normal page. Also note that your piece is written in singular and that you must have a suitable apostrophe-pieces-page for your piece (that is, it must have a ._url property when Apostrophe fetches it). Refer to the core documentation for reusable content with pieces.

Now when you create a new redirect, you have the option to browse for both pages and your pieces in the Apostrophe admin UI.