Skip to content

Commit 3a47640

Browse files
committed
Finish refactoring Link
1 parent eb4edc2 commit 3a47640

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/MultiDocumenter.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ All `DropdownComponent`s go in [`Column`](@ref)s, which go in [`MegaDropdownNav`
3636
Any subtype of `DropdownComponent` must implement that `render` method.
3737
3838
The main subtype is [`MultiDocRef`](@ref), which refers to external documentation
39-
and adds it to the search index. However, there are others like [`ExternalLink`](@ref)
39+
and adds it to the search index. However, there are others like [`Link`](@ref)
4040
which is used to link to external sites without making them searchable, and
4141
users can implement their own custom components.
4242
"""
@@ -81,7 +81,11 @@ function MultiDocRef(;
8181
MultiDocRef(upstream, path, name, fix_canonical_url, giturl, branch)
8282
end
8383

84+
"""
85+
Link([text::String], link::String) <: DropdownComponent
8486
87+
Represents a link to an external site.
88+
"""
8589
struct Link <: MultiDocumenter.DropdownComponent
8690
text::String
8791
link::String

src/renderers.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,13 @@ function render(doc::MultiDocRef, dir, thispagepath, prettyurls)
3737
end
3838

3939
function render(c::Link, doc, thispage, prettyurls)
40+
# class nav-link nav-item makes the formatting correct
41+
# _target="blank" opens the link in a new tab
42+
# TODO: add "external link" icon after, either chain or arrow exiting box.
43+
# TODO: allow internal links
4044
return @htl """
41-
<a href=$(c.link) class="nav-link nav-item">$(c.text)</a>
42-
""" # TODO: add "external link" icon after, either chain or arrow exiting box.
45+
<a href=$(c.link) class="nav-link nav-item" _target="blank">$(c.text)</a>
46+
"""
4347
end
4448

4549
function render(doc::DropdownNav, dir, thispagepath, prettyurls)

0 commit comments

Comments
 (0)