Leaf bundles: date and slug from filename

TLDR: Issue is #4558, proposed fix pull request #5267.

In brief, the problem is that single files and leaf bundles are currently not being handled the same way by the :filename frontmatter config.

I have implemented a simple fix by adding a ContentBaseName-field to the file data structure, and made sure that this is set to the file base name for single files and to the folder name for a leaf bundle. As far as I can tell, this solves the problem at hand without any adverse effects, so the only question is whether I have missed a more elegant solution.

Does anybody have a suggestion for a cleaner/more general implementation, or any suggestions for changes to the current implementation (my first go code ever)?

A related discussion seems to be this one on how to retrieve parent folder names in page bundles (which should also be handled by my fix).

Cheers
Janus

Input as leaf bundle: No date/slug from filename

.
└── blog
    └── 2018-03-02-FILE-name
        └── index.md

Input as single file: Date/slug from filename works ok.

.
└── blog
    └── 2018-03-02-FILE-name.md

This looks good to me; I have been one a “mini vacation” the last few days, so I have just watched the issues flow by, but I will look at the PR in more detail tomorrow.

Thanks, that sounds great!
I hope I haven’t been spamming too much – but I wanted to make sure this didn’t fall through the cracks.

1 Like