问题
I'm using a data page generator for my Jekyll website to create pages based on a folder of JSON files. I want the generator to use the names of the json files as the page title, but I can't figure out the right syntax to tell it to use the file name instead of one of the fields in the json.
I can access the file name in one of the layout pages with:
for file in site.data.drinks
file[0]
But file[0] doesn't work in the config (neither does record[0] or record):
- data: drinks
template: drink
name: name
title: name
dir: drinks
extension: html
where it seems to be just looking for the name of one of the fields in the json. I've been using the actual name of the page "Gin and Tonic" and usually that's fine because it matches the name of the file "gin-and-tonic.json", but in the cases where it doesn't, the website breaks.
So what's the right way to tell it to use the actual filename, and for the future, where should I look to figure out this kind of thing. Any help is greatly appreciated!
来源:https://stackoverflow.com/questions/65620610/key-for-name-of-json-file-rather-than-just-its-fields-for-use-in-jekyll-page-g