Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use metadata for file data #3

Open
ninjasort opened this issue Jul 22, 2016 · 3 comments
Open

Use metadata for file data #3

ninjasort opened this issue Jul 22, 2016 · 3 comments

Comments

@ninjasort
Copy link

ninjasort commented Jul 22, 2016

I haven't looked too much into the code, but I think I may have seen that the JSON files are being named-spaced in a certain permalinking naming convention? I don't really think that would be necessary.

For both yaml and json here's an ideal use case that I was considering:

  1. Add a single json, config file to the project
  2. In the file specify each files as a key (index, about, contact-us)
  3. Within each object, specify the data that should be merged onto that file object
  4. Optionally allow for additional metadata to be placed within the object prefixed with a "_" - for example, "_path": "/some/path/:id". This would mimic a directory path to the file for example. Otherwise, it could be simply indexed by key.
  5. Use the plugin above other plugins to take advantage of uses of metalsmith-permalinks, etc.

Thoughts?

@woodyrew
Copy link
Owner

The files generated aren't namespaced per se but you do provide it with a pattern to generate the "filename" in the metalsmith files object. I suppose you could add files to the object with a random hash if you didn't want to create files with meaningful names.

  1. Yup, provide a JSON or YAML filepath that contains the plugin options. Alternatively it accepts a JS object with the same options.
  2. Array of objects defining source files, file pattern, permalink style and any other frontmatter you want carried across.
  3. You could pass a JS function within the options to do any data transformations.
  4. Covered by point 2 to carry extra frontmatter over.
  5. Yes.

(I updated your comment with a numbered list)

@ninjasort
Copy link
Author

ninjasort commented Jul 23, 2016

Hmm, so if I was to use a config.yaml for global site pages for example and do something like this:

index:
  title: 'Home'
  heading: 'Welcome to this site'
about:
  title: 'About us'
  heading: 'More about us'
services:
  web-design:
    title: 'Web Design'
    heading: 'We build websites'
  seo:
    title: 'SEO'
    heading: 'We optimize websites'

Then have posts in another posts.json, like this:

[{
  'date': '2016-07-22',
  'title': 'How to use Metalsmith',
  'layout': 'post.liquid',
  'contents': '# This is Markdown',
},
{
  'date': '2016-07-23',
  'title': 'How to use Liquid',
  'layout': 'post.liquid',
  'contents': '# This is Markdown',
}
]

Would that potentially work?

@ninjasort
Copy link
Author

Thoughts on that config?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants