Remove anchors
This commit is contained in:
parent
fa0c87ce13
commit
c10668a64f
4 changed files with 7 additions and 25 deletions
|
@ -12,11 +12,7 @@ module Referator
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_h
|
def to_h
|
||||||
@to_h ||= data.merge(category:, id:, slug:, anchor:).freeze
|
@to_h ||= data.merge(category:, id:, slug:).freeze
|
||||||
end
|
|
||||||
|
|
||||||
def anchor
|
|
||||||
@anchor ||= "#{category}-#{slug}".freeze
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
20
test.rb
20
test.rb
|
@ -41,20 +41,12 @@ RAW_REFS = {
|
||||||
|
|
||||||
REFS = {
|
REFS = {
|
||||||
self: {
|
self: {
|
||||||
foo: RAW_REFS[:self][:foo].merge(
|
foo: RAW_REFS[:self][:foo],
|
||||||
'anchor' => 'self-blog-foo',
|
bar: RAW_REFS[:self][:bar],
|
||||||
).freeze,
|
|
||||||
bar: RAW_REFS[:self][:bar].merge(
|
|
||||||
'anchor' => 'self-blog-bar',
|
|
||||||
).freeze,
|
|
||||||
}.freeze,
|
}.freeze,
|
||||||
link: {
|
link: {
|
||||||
example_com: RAW_REFS[:link][:example_com].merge(
|
example_com: RAW_REFS[:link][:example_com],
|
||||||
'anchor' => 'link-example-com',
|
causa_arcana_com: RAW_REFS[:link][:causa_arcana_com],
|
||||||
).freeze,
|
|
||||||
causa_arcana_com: RAW_REFS[:link][:causa_arcana_com].merge(
|
|
||||||
'anchor' => 'link-causa-arcana-com',
|
|
||||||
).freeze,
|
|
||||||
}.freeze,
|
}.freeze,
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
|
@ -251,7 +243,6 @@ cmd :RENDER_FOOTNOTES, :json do |result|
|
||||||
"category": "self",
|
"category": "self",
|
||||||
"id": "/blog/foo",
|
"id": "/blog/foo",
|
||||||
"slug": "blog-foo",
|
"slug": "blog-foo",
|
||||||
"anchor": "self-blog-foo",
|
|
||||||
"url": "/blog/foo.html",
|
"url": "/blog/foo.html",
|
||||||
"text": "Foo"
|
"text": "Foo"
|
||||||
},
|
},
|
||||||
|
@ -260,7 +251,6 @@ cmd :RENDER_FOOTNOTES, :json do |result|
|
||||||
"category": "self",
|
"category": "self",
|
||||||
"id": "/blog/bar",
|
"id": "/blog/bar",
|
||||||
"slug": "blog-bar",
|
"slug": "blog-bar",
|
||||||
"anchor": "self-blog-bar",
|
|
||||||
"url": "/blog/bar.html",
|
"url": "/blog/bar.html",
|
||||||
"text": "Bar"
|
"text": "Bar"
|
||||||
}
|
}
|
||||||
|
@ -271,7 +261,6 @@ cmd :RENDER_FOOTNOTES, :json do |result|
|
||||||
"category": "link",
|
"category": "link",
|
||||||
"id": "example_com",
|
"id": "example_com",
|
||||||
"slug": "example-com",
|
"slug": "example-com",
|
||||||
"anchor": "link-example-com",
|
|
||||||
"url": "https://example.com",
|
"url": "https://example.com",
|
||||||
"text": "Example Domain"
|
"text": "Example Domain"
|
||||||
},
|
},
|
||||||
|
@ -280,7 +269,6 @@ cmd :RENDER_FOOTNOTES, :json do |result|
|
||||||
"category": "link",
|
"category": "link",
|
||||||
"id": "causa_arcana_com",
|
"id": "causa_arcana_com",
|
||||||
"slug": "causa-arcana-com",
|
"slug": "causa-arcana-com",
|
||||||
"anchor": "link-causa-arcana-com",
|
|
||||||
"url": "https://causa-arcana.com",
|
"url": "https://causa-arcana.com",
|
||||||
"text": "Causa Arcana"
|
"text": "Causa Arcana"
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
<ol>
|
<ol>
|
||||||
<% notes['self'].each do |note| -%>
|
<% notes['self'].each do |note| -%>
|
||||||
<li id="<%= note['anchor'] %>" value="<%= note['index'] %>">
|
<li id="<%= "#{note['category']}-#{note['slug']}" %>" value="<%= note['index'] %>">
|
||||||
<a href="<%= note['id'] %>.html"><%= note['text'] %></a>
|
<a href="<%= note['id'] %>.html"><%= note['text'] %></a>
|
||||||
</li>
|
</li>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
<ol>
|
<ol>
|
||||||
<% notes['link'].each do |note| -%>
|
<% notes['link'].each do |note| -%>
|
||||||
<li id="<%= note['anchor'] %>" value="<%= note['index'] %>">
|
<li id="<%= "#{note['category']}-#{note['slug']}" %>" value="<%= note['index'] %>">
|
||||||
<a href="<%= note['url'] %>"><%= note['text'] %></a>
|
<a href="<%= note['url'] %>"><%= note['text'] %></a>
|
||||||
</li>
|
</li>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
"category": "self",
|
"category": "self",
|
||||||
"id": <%= String(note['id']).to_json %>,
|
"id": <%= String(note['id']).to_json %>,
|
||||||
"slug": <%= String(note['slug']).to_json %>,
|
"slug": <%= String(note['slug']).to_json %>,
|
||||||
"anchor": <%= String(note['anchor']).to_json %>,
|
|
||||||
"url": <%= "#{note['id']}.html".to_json %>,
|
"url": <%= "#{note['id']}.html".to_json %>,
|
||||||
"text": <%= String(note['text']).to_json %>
|
"text": <%= String(note['text']).to_json %>
|
||||||
}<%= ',' unless index == notes['self'].count - 1 %>
|
}<%= ',' unless index == notes['self'].count - 1 %>
|
||||||
|
@ -19,7 +18,6 @@
|
||||||
"category": "link",
|
"category": "link",
|
||||||
"id": <%= String(note['id']).to_json %>,
|
"id": <%= String(note['id']).to_json %>,
|
||||||
"slug": <%= String(note['slug']).to_json %>,
|
"slug": <%= String(note['slug']).to_json %>,
|
||||||
"anchor": <%= String(note['anchor']).to_json %>,
|
|
||||||
"url": <%= String(note['url']).to_json %>,
|
"url": <%= String(note['url']).to_json %>,
|
||||||
"text": <%= String(note['text']).to_json %>
|
"text": <%= String(note['text']).to_json %>
|
||||||
}<%= ',' unless index == notes['link'].count - 1 %>
|
}<%= ',' unless index == notes['link'].count - 1 %>
|
||||||
|
|
Loading…
Add table
Reference in a new issue