metalsmith-aliases-nginx v0.0.1
metalsmith-aliases-nginx
Create aliases for your posts compiled into a file called nginx.conf in the root of your metalsmith installation.
This file can be imported into an Nginx server directive and will emit a 301 http status for the requests.
This plugin is based on metalsmith-aliases which takes a different approach of creating html files with meta-refresh, but that is W3C depreciated behavior and results in files being downloaded twice, which can make the site appear to be slower.
If you are currently using metalsmith-aliases you can use this as a drop-in replacement. There is no need to run both.
Installation
npm install --save metalsmith-aliases-nginxUsage
This plugin depends on having an property called permalink, so in order for it to work we need to
either add that ourselves or use the permalinks plugin.
This needs to happen before the alias plugin.
Javascript API
var Metalsmith = require('metalsmith');
var aliases = require('metalsmith-aliases-nginx');
var permalinks = require('metalsmith-permalinks');
Metalsmith()
.use(permalinks())
.use(aliases());Posts
Add your aliases in the form of an array in your posts:
---
title: Reactive extensions in Javascript
aliases: [2016/01/14/reactive-extensions-in-javascript]
------
title: Metalsmith aliases
aliases: [2016/03/15/metalsmith-aliases, metalsmith-using-aliases]
---Post-build
After you run make build you will want to include the nginx.conf file that is generated into your server configuration.
9 years ago