Code Monkey home page Code Monkey logo

Comments (3)

misterdai avatar misterdai commented on June 12, 2024

๐Ÿ‘ I need as well and there doesn't appear to be a way available with the plugin currently. However, I've modified my copy to support it when provided options in the following format:

  .use(permalinks({
    {posts: {pattern: '/:collection/:date/:title'}},
    {pages: {pattern: '/:collection/:title'}},
    {"*": {pattern: '/:title'}}
  })

Gist: https://gist.github.com/misterdai/84fa94cd382e66262357

The modification simply checks for a permalink rule that matches the collection name or it'll default to the wildcard * for any other file or unmatched collection. If there's no global rule or matching collection, it'll skip creating the permalink for the file.

I think collection based permalinks may be better as a separate plugin, but I'll leave it up to @ianstormtaylor to decide that :)

from permalinks.

patdavid avatar patdavid commented on June 12, 2024

Just came here on a somewhat related issue and noticed this. I had problems with it for a while, but the solution I went with was to use metalsmith-branch to branch my blog posts separately (they're nested under a different src/ folder. relevant section:

.use( branch('blog/posts/**')
    .use( permalinks({
        pattern: 'blog/:date/:title',
        date: 'YYYY/MM',
    }))
)

My problem now is how to handle relative files to bring them over in nested folders, but I'll open another issue for that.

from permalinks.

totocaster avatar totocaster commented on June 12, 2024

Hello, so it's been a while since I asked that question and digging deeper into Metalsmith just gave me indication that I didn't treat it as it supposed to be. Here is what I've done to solve my problem.

  .use(copy({
    pattern: 'pages/*',
    directory: '/'
  }))
  .use(ignore(['pages/*',".DS_Store"]))
  .use(permalinks({
    pattern: ':date/:title',
    date: 'YYYY/MM'
  }))

Thus, this plugins does it's job correctly, and it is job of other similarly simple and straightforward plugins to do the rest. Simplicity is a king in Metalsmith, I'm loving it..

from permalinks.

Related Issues (20)

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.