referator/test/footnotes.json.erb
2023-09-30 01:12:59 +04:00

33 lines
1.2 KiB
Text

<% self_notes = notes.select { |note| note['kind'] == 'self' } -%>
<% link_notes = notes.select { |note| note['kind'] == 'link' } -%>
<%# -%>
{
"self": [
<%- self_notes.each_with_index do |note, index| -%>
{
"index": <%= Integer(note['index']).to_json %>,
"kind": "self",
"id": <%= String(note['id']).to_json %>,
"slug": <%= String(note['slug']).to_json %>,
"anchor": <%= String(note['anchor']).to_json %>,
"fragment": <%= String(note['fragment']).to_json %>,
"url": <%= "#{note['id']}.html".to_json %>,
"text": <%= String(note['text']).to_json %>
}<%= ',' unless index == self_notes.count - 1 %>
<%- end -%>
],
"link": [
<%- link_notes.each_with_index do |note, index| -%>
{
"index": <%= Integer(note['index']).to_json %>,
"kind": "link",
"id": <%= String(note['id']).to_json %>,
"slug": <%= String(note['slug']).to_json %>,
"anchor": <%= String(note['anchor']).to_json %>,
"fragment": <%= String(note['fragment']).to_json %>,
"url": <%= String(note['url']).to_json %>,
"text": <%= String(note['text']).to_json %>
}<%= ',' unless index == link_notes.count - 1 %>
<%- end -%>
]
}