parent
8303d31d79
commit
54d37a8396
|
@ -87,8 +87,13 @@ module Jekyll
|
|||
alias_method :mainEntityOfPage, :main_entity
|
||||
private :main_entity
|
||||
|
||||
def to_json
|
||||
to_h.compact.to_json
|
||||
# Returns a JSON-encoded object containing the JSON-LD data.
|
||||
# Keys are sorted.
|
||||
def to_json(state = nil)
|
||||
keys.sort.each_with_object({}) do |(key, _), result|
|
||||
v = self[key]
|
||||
result[key] = v unless v.nil?
|
||||
end.to_json(state)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -30,6 +30,10 @@ RSpec.describe Jekyll::SeoTag do
|
|||
expect(output).to match(%r!Jekyll v#{version}!i)
|
||||
end
|
||||
|
||||
it "outputs JSON sorted by key" do
|
||||
expect(json.strip).to eql('{"@context":"https://schema.org","@type":"WebPage","url":"/page.html"}')
|
||||
end
|
||||
|
||||
it "outputs valid HTML" do
|
||||
site.process
|
||||
options = {
|
||||
|
|
Loading…
Reference in New Issue