我有一个在Jekyll模板中使用的数据文件:
I have a data file which is being used inside a Jekyll template:
/{project}/_data/mydata.json我还希望可以通过JavaScript在实时网站上获得这些数据:
I also want this data to be available on the live website from a JavaScript:
/{project}/_site/mydata.json我希望以下列方式之一:
Somehow I want one of the following:
-
每当进行更改时,自动将其自身从"_data"复制到"_sites".
Automatically copy itself from "_data" to "_sites" whenever changes are made.
已使模板从/{project}/mydata.json读取数据文件,因为该文件已被复制到"_sites"文件夹中.
Have the template read the data file from /{project}/mydata.json since this file will already get copied to the "_sites" folder.
在Jekyll模板和JavaScript中维护数据文件的单个版本的最简单方法是什么?
What is the easiest way to maintain a single version of the data file inside both Jekyll templates and JavaScripts?
推荐答案文件/{project}/mydata.json
--- layout: null --- {{ site.data.mydata | jsonify }}在jekyll serve或github上,每次更新/{project}/_data/mydata.json时都会更新.
With jekyll serve or on github, this will be updated each time your /{project}/_data/mydata.json is updated.
等等!
更多推荐
将数据文件复制到"
发布评论