我想寫一個生成器插件來添加一些類似帖子的項目到我的博客。這些項目應該出現在博客索引中,但他們沒有與他們關聯的頁面(您不能點擊它們)。將帖子添加到Jekyll索引頁面,沒有.md文件
我知道我需要像
class QuoteGenerator < Generator
safe true
def generate(site)
# add a single post
site.posts << QuotePost.new(site, site.source, "Blub")
end
end
但我不明白的是如何實現我的Post
子類。我發現,其他插件(如this one to embed Flickr photos)寫任何他們想要減價+ YAML文件中的數據,然後引用此文件:
class QuotePost < Post
def initialize(site, base, title)
# Nooo, I don't want to create a .md file for this
name = "2016-05-13-test.md"
dir = ""
# (write out .md file here)
super(site, base, dir, name)
end
end
但後來,我很難需要一個插件在首位。我可以自己生成降價文件(使用外部腳本)。
我想要做的就是在Post子類中設置幾個變量,並將它們放在博客索引的模板中。我怎樣才能做到這一點?
爲什麼不使用'output:false'的集合?數據來自哪裏? –