我有一个名为的脚本import.rb,它将从 url 导入 json 内容到 jekyll 中的草稿目录。下面是我的代码。
require 'fileutils'
require 'json'
require 'open-uri'
# Load JSON data from source
# (Assuming the data source is a json file on your file system)
data = JSON.parse(open('https://script.google.com/macros/s/AKfycbyHFt1Yz96q91-D6eP4uWtRCcF_lzG2WM-sjrpZIr3s02HrICBQ/exec'))
# Proceed to create post files if the value array is not empty
array = data["user"]
if array && !array.empty?
# create the `_drafts` directory if it doesn't exist already
drafts_dir = File.expand_path('./_drafts', __dir__)
FileUtils.mkdir_p(drafts_dir) unless Dir.exist?(drafts_dir)
# iterate through the array and …Run Code Online (Sandbox Code Playgroud)