metalsmith / permalinks

A Metalsmith plugin for permalinks.
MIT License
62 stars 67 forks source link

[Question] Can date take alphabets and work same. #71

Closed gkumar9 closed 6 years ago

gkumar9 commented 7 years ago

just as date form this hierarchy,

---
date: 2017-11-12
---
this results in:

2017/
    11/
        12/
            index.html

I want something like below this:

---
date: usa-newyork-manhattan
---
this results in:

usa/
    newyork/
        manhattan/
                 index.html
gkumar9 commented 7 years ago

https://stackoverflow.com/questions/47386295/metalsmith-how-to-have-different-url-generated-for-my-output-pages Anybody respond please. is this repo even active ????

MegaJ commented 6 years ago

@gkumumar9 Feels a little dead doesn't it? The amount of unmerged PRs is also quite big for a project of this size.

It seems like from the readme, that you can't do this (source code reflects this too). This plugin uses moment.js to parse dates.

As an alternative, you can set metadata on your source files and have front matter like

---
country: usa
city: newyork
borough: manhattan
---

and in your options to permalinks can look like

.use(permalinks({
        pattern: ':country/:city/:borough/',
        relative: false
      }))

Alternatively you could have just one field like date, but maybe name it something else like location and have it set as usa-newyork-manhattan. Then you can use a plugin to to parse out a file's location field and add those properties as part of your file objects. Then you could use the permalink pattern option to look for those properties to set your file paths.

Also, you might have better luck asking in metalsmith slack channel; metalsmith users are more active there, imo.

gkumar9 commented 6 years ago

@MegaJ your suggestion is accurate. But, my requirement is quite dynamic i.e instead of just having 3 fields i might have 4 or 2 or 8 . You get my point right. Your alternative solution is interesting and useful in regards to dynamicity , but which plugin are you talking about here.

Then you can use a plugin to to parse out a file's location field and add those properties as part of your file objects. Then you could use the permalink pattern option to look for those properties to set your file paths