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

"pattern:" does not work in CLI #18

Open
BitFis opened this issue Aug 11, 2014 · 14 comments
Open

"pattern:" does not work in CLI #18

BitFis opened this issue Aug 11, 2014 · 14 comments

Comments

@BitFis
Copy link

BitFis commented Aug 11, 2014

Somehow i can only add files to my collection by setting the metadata collection in the file.
I can not select any files with the pattern attribute like following:

"metalsmith-collections": {
    "articles": {
        "pattern": "*.md"
    }
}

or

"metalsmith-collections": {
    "articles": "*.md"
}

This will only give me an empty collection in the template

@sigo
Copy link

sigo commented Aug 14, 2014

I think it don't depends on pattern, but it just don't work for CLI.

@BitFis
Copy link
Author

BitFis commented Aug 21, 2014

Any chance that that will be fixed?

@budparr
Copy link

budparr commented Aug 21, 2014

@BigZ94 why don't you link to your repo and I'll see if I can have a look for you.

@iqbalali
Copy link

Bump. Any idea when this issue will be fixed?

I'm following the tutorial at: http://www.robinthrift.com/posts/metalsmith-part-2-shaping-the-metal/

However, the collection (if defined in the index.js as a pattern) doesn't work.

@seffw
Copy link

seffw commented Dec 8, 2014

I don't know if this is relevant, but it's caught me out a few times. What I have noticed is that in various metalsmith plugins. they don't go deeper than the folder stated. I'm not sure if it's the same with collections. So I only have 1 collection per folder.

@nlundquist
Copy link

I only had one collection and the CLI didn't work for me either.

@constantx
Copy link

Something to watch out for, that I just see. The order of where the metalsmith-collections in the metalsmith.json file matter. If you move it after metalsmith-markdown the files which are being sent to metalsmith-collections will have a .htmlextension, and will not match *.md

$ DEBUG=metalsmith-collections metalsmith, will show which files are actually being matched.

1__tbones-mbp__node_

@constantx
Copy link

* disclosure: I use grunt-metalsmith, not the pure metalsmith.json and CLI approach

@seffw
Copy link

seffw commented Feb 14, 2015

nlundquist, did you get this fixed? All the 'not working' posts in this thread have little info and follow-up. This feature does and has always worked for me in metalsmith, but I've had a few frustrating hours with some of the other plugins that needed a specific setup to work.

The plugin nature of Metalsmith clearly opens up opportunities, but it also seems to present issues due to the linear nature when parsing the plugins (so one thing must be before another, but after something else, and therefore certain combinations might not work).

If it helps, In my build.js, the first plugin is collections, setup like this:

Metalsmith(__dirname)
.use(collections({
pages: {
pattern: 'pages/
.md'
},
posts: {
pattern: 'posts/.md',
sortBy: 'date',
reverse: true
}
})

The folders pags and posts are in an src folder.

@constantx
Copy link

@simplyeffectiveweb 👍

@remotesynth
Copy link

I have run into the same issue. The pattern matching simply would not work via the CLI. I tried using every available example to see if it was just something I was doing wrong but nothing worked. Once I changed to use the metadata, it worked right away.

@GRUBES
Copy link

GRUBES commented Apr 17, 2016

I am currently using the CLI with this plugin, and it works just fine. As mentioned previously, metalsmith-collections is the very first plugin I invoke:

  "plugins": {
    "metalsmith-collections": {
      "static": {
        "pattern": {"*.{html,xml,txt,png,ico}", },
        "refer": false
      },
      "error": {
        "pattern": "{403,404}.md",
        "refer": false
      },
      "articles": {
        "pattern": "content/articles/*.md ",
        "reverse": true
      },
      "recent-articles": {
        "pattern": "content/articles/*.md",
        "reverse": true,
        "limit": 5
      }
    },
    ...

@romaklimenko
Copy link

The bug looks like already fixed. The pattern works both via CLI and metadata. The only pitfall is that pattern's path is relative to source folder. So if .source('./src'), then pattern: '*.md', not pattern: './src/*.md'

@Jackbennett
Copy link

Jackbennett commented Feb 15, 2017

This pitfall could be better documented as I suppose it's kind of obvious once you already know it. However my pattern ./*.md doesn't work. I have to lose the current folder prefix ./ then it works.

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