contentful-metalsmith icon indicating copy to clipboard operation
contentful-metalsmith copied to clipboard

global key

Open ninjasort opened this issue 9 years ago • 1 comments
trafficstars

Currently, one needs to create a file for each piece of content they want to render.

Create files based on the files defined in your source folder

This somewhat defeats the purpose of using Contentful to store content. There still remains a dependency on local files within a Metalsmith project src. I think this could be handled easier by eliminating the need for src files completely and specifying key and layout properties that get transformed into files. For example, by specifying a {"useKey": "_key"} a user could create a _key property within their contentful backend with the path to the file. { "_key": "projects/my-project.md" }, this could then be transformed into a file, remove the _key property and add all data onto that file object using the key as the filename and adding the other properties to the object with contents being transformed to a buffer.

{
  "projects/my-project.md": {
    "title": "My Project",
    "layout": "project.liquid",
    "contents": "<Buffer>",
    "other_contentful_property": ""
  }
}

This way files can be used in other plugins like metalsmith-layouts and metalsmith-permalinks. It would all be part of the pipeline at that point.

ninjasort avatar Nov 06 '16 20:11 ninjasort

@cameronroe jup. :) Agree that would be a nice improvement.

Not sure when I'll be able to tackle it. Contributions are welcome. :)

stefanjudis avatar Nov 10 '16 01:11 stefanjudis