Style invalid bracket links (grey them out)

This commit is contained in:
Maxime Vaillancourt 2020-10-15 07:25:03 -04:00
parent 385ef3a852
commit 1a0a706556
2 changed files with 25 additions and 0 deletions

View File

@ -18,6 +18,19 @@ class BidirectionalLinksGenerator < Jekyll::Generator
"<a class='internal-link' href='#{note_potentially_linked_to.url}'>#{note_potentially_linked_to.data['title']}</a>"
)
end
# At this point, all remaining double-bracket-wrapped words are
# pointing to non-existing pages, so let's turn them into disabled
# links by greying them out and changing the cursor
current_note.content = current_note.content.gsub(
/\[\[?(.*)\]\]/i, # match on the remaining double-bracket links
<<~HTML.chomp # replace with this HTML (\\1 is what was inside the brackets)
<span title='There is no note that matches this title.' class='invalid-link'>
<span class='invalid-link-brackets'>[[</span>
\\1
<span class='invalid-link-brackets'>]]</span></span>
HTML
)
end
# Identify note backlinks and add them to each note

View File

@ -128,3 +128,15 @@ code {
padding: 0.1em 0.2em;
border-radius: 4px;
}
.invalid-link {
color: #444444;
cursor: help;
background: #fafafa;
padding: 0 0.1em;
}
.invalid-link-brackets {
color: #ccc;
cursor: help;
}