将数据文件复制到"

编程入门 行业动态 更新时间:2024-10-25 16:30:44
本文介绍了将数据文件复制到"_sites"在Jekyll项目中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个在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.

等等!

更多推荐

将数据文件复制到"

本文发布于:2023-07-25 09:08:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1208999.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   数据   quot

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!