kylenstone / kylethinks

professional blog
0 stars 0 forks source link

use permalinks #10

Closed kylenstone closed 6 years ago

kylenstone commented 6 years ago

https://github.com/segmentio/metalsmith-permalinks

The pattern can contain a reference to any piece of metadata associated with the file by using the :PROPERTY syntax for placeholders.

If no pattern is provided, the files won't be remapped, but the path metadata key will still be set, so that you can use it for outputting links to files in the template.

The pattern can also be a set as such:

var Metalsmith = require('metalsmith');
var permalinks = require('metalsmith-permalinks');

var metalsmith = new Metalsmith(__dirname)
  .use(permalinks({
      // original options would act as the keys of a `default` linkset, 
      pattern: ':title',
      date: 'YYYY',

      // each linkset defines a match, and any other desired option
      linksets: [{
          match: { collection: 'blogposts' },
          pattern: 'blog/:date/:title',
          date: 'mmddyy'
      },{
          match: { collection: 'pages' },
          pattern: 'pages/:title'
      }]
  }));
kylenstone commented 6 years ago

built