Include file slug value in `Page.src` object
See original GitHub issueLume does some calculations behind the scenes to determine information about the source of a generated page. For example, given a file saved at /articles/2022-08-29_porto.md
, Lume provides the following data in Page.src
:
{
path: "/articles/2022-08-29_porto",
lastModified: 2022-10-01T17:46:49.762Z,
created: 2022-10-01T17:16:39.480Z,
remote: undefined,
ext: ".md"
}
Lume will also add a page.data.data
value if the base file name contains YYYY-MM-DD_
(so for the above this would be calculated to be 2022-10-01T00:00:00.000Z
).
However, there is one other piece of information that may be useful to site authors: the file slug. In the case of the above, this value would be porto
.
This value could be used in url()
functions:
export function url(page) {
return `./example/${page.src.fileSlug}/`;
}
It could also be used by page (pre)processors. This is my use case, where I am currently having to calculate this value myself to generate a new URL.
(Eleventy provides a similar fileSlug
value).
Issue Analytics
- State:
- Created a year ago
- Comments:9 (9 by maintainers)
Top GitHub Comments
This will be available in Lume 1.13.0. Closing this.
Thanks for this, that works for now (bit better than my regex!)
I do think this value should be exposed somewhere, after all it’s a user defined piece of data, much like the date in the file name.
I wouldn’t mind this value being provided as a default value for
page.data.slug
, or evenpage.src.path
, but you have a better idea of the overall architecture and project direction.