GithubHelp home page GithubHelp logo

fephil / metalsmith-metadata-directory Goto Github PK

View Code? Open in Web Editor NEW
13.0 13.0 4.0 174 KB

๐Ÿ“” A Metalsmith plugin to add a directory of JSON files for use as global metadata in templates, partials and pages.

Home Page: https://github.com/fephil/metalsmith-metadata-directory

License: MIT License

JavaScript 100.00%
glob json metadata metalsmith metalsmith-plugin partials templates yaml yml

metalsmith-metadata-directory's People

Contributors

fephil avatar furzeface avatar saschazar21 avatar waozi-dev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

metalsmith-metadata-directory's Issues

Ignore files if this is empty

Hi @fephil ,

Thanks for share this plugin.
I've been using since a couple of months this plugin and it works great.

But I have a little problem, is possible make metalsmith-metadata-directory ignore empty json file?

When I start a project, my data.json file is empty.

The problem is when i compile my build.js, and I get this error:

SyntaxError: Unexpected end of input
    at Object.parse (native)
    at /Users/Rodrigo/Projects/web-blog-metalsmith-njk/node_modules/metalsmith-metadata-directory/lib/index.js:42:25
    at /Users/Rodrigo/Projects/web-blog-metalsmith-njk/node_modules/metalsmith-metadata-directory/node_modules/async/dist/async.js:4700:20
    at replenish (/Users/Rodrigo/Projects/web-blog-metalsmith-njk/node_modules/metalsmith-metadata-directory/node_modules/async/dist/async.js:873:21)
    at /Users/Rodrigo/Projects/web-blog-metalsmith-njk/node_modules/metalsmith-metadata-directory/node_modules/async/dist/async.js:883:15
    at eachLimit (/Users/Rodrigo/Projects/web-blog-metalsmith-njk/node_modules/metalsmith-metadata-directory/node_modules/async/dist/async.js:4725:33)
    at Object.<anonymous> (/Users/Rodrigo/Projects/web-blog-metalsmith-njk/node_modules/metalsmith-metadata-directory/node_modules/async/dist/async.js:929:20)
    at /Users/Rodrigo/Projects/web-blog-metalsmith-njk/node_modules/metalsmith-metadata-directory/lib/index.js:38:13
    at f (/Users/Rodrigo/Projects/web-blog-metalsmith-njk/node_modules/once/once.js:17:25)
    at Glob.<anonymous> (/Users/Rodrigo/Projects/web-blog-metalsmith-njk/node_modules/metalsmith-metadata-directory/node_modules/glob/glob.js:146:7)
    at emitOne (events.js:90:13)
    at Glob.emit (events.js:182:7)
    at Glob._finish (/Users/Rodrigo/Projects/web-blog-metalsmith-njk/node_modules/metalsmith-metadata-directory/node_modules/glob/glob.js:194:8)
    at done (/Users/Rodrigo/Projects/web-blog-metalsmith-njk/node_modules/metalsmith-metadata-directory/node_modules/glob/glob.js:179:14)
    at Glob._processReaddir2 (/Users/Rodrigo/Projects/web-blog-metalsmith-njk/node_modules/metalsmith-metadata-directory/node_modules/glob/glob.js:431:12)
    at /Users/Rodrigo/Projects/web-blog-metalsmith-njk/node_modules/metalsmith-metadata-directory/node_modules/glob/glob.js:368:17

There any way to do that if the file is empty, do not run the metalsmith-metadata-directory or ignore, like a plugin option?

Thanks in advance.

Request: Allow app to specify root metadata property

As currently implemented, the plugin adds all properties to the root metadata object. So, for example, if the files foo.json and bar.yml were parsed, the metalsmith.metadata() would then have foo and bar properties containing the parsed metadata from the respective files.

It would be useful to provide an option for the app to specify a root property in which those parsed properties were added. For example, if the app specified that all parsed files be added to the '_data' property, the plugin would ensure that the _data property existed in the metadata object (possibly adding it if absent), and then add foo and bar properties to metalsmith.metadata()._data.

does not work well with metalsmith-watch

the initial start up works fine, however once any file has changed and metalsmith-watch rebuilds the files that have changes i get the continues error:

Error: Duplicate file name: file.yml

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.