mbanting / metalsmith-prismic

A Metalsmith.io plugin to pull in content from Prismic.io
MIT License
48 stars 19 forks source link

new Feature: create multiple file with the same content #33

Closed wcastand closed 7 years ago

wcastand commented 8 years ago

It would be awesome id we can create multiple files with the same content. For example, i use tags for languages and i want to assign the tag 'fr' and 'en' to a post. Actually i can't create to files at two different locations.

If we can send back an array in the link resolver, it would be cool. Something like this should work :

// use the linkResolver to generate the filename removing the leading slash if present
const files = ctx.linkResolver(file.prismic[collectionQuery].results[i]) + fileSuffix;
if(typeof files === 'array'){
  files.map(file => {
    const f = file.replace(/^\//g, '')
    newFiles[f] = newFile;
  });
}
else
  newFiles[files.replace(/^\//g, '')] = newFile;