Skip to content

Commit 5f4477a

Browse files
authored
Link style for external and anchor links (#254)
* Use internal link style also for external and anchor links * Remove console.log * Adjust new line of code from .link-internal to .link * Exclude external links when handling versions/aliases in links
1 parent 5ec5d94 commit 5f4477a

File tree

7 files changed

+24
-21
lines changed

7 files changed

+24
-21
lines changed

site/themes/arangodb-docs-theme/layouts/_default/_markup/render-link.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
{{- end }}
99

1010
{{- $permalink := "" }}
11-
{{- $class := "" }}
1211
{{- $isRemote := ne $url.Scheme "" }}
1312

1413
{{ if $isRemote -}}
@@ -21,7 +20,6 @@
2120
{{ $page := .Page.GetPage $path -}}
2221
{{ with $page -}}
2322
{{ $permalink = printf "%s%s" $page.RelPermalink $fragment -}}
24-
{{ $class = "link-internal" }}
2523
{{ else -}}
2624
{{ if ne $currentPage "/" -}}
2725
{{ $currentFile := .Page.File.Path -}}
@@ -37,7 +35,8 @@
3735

3836
<a href="{{ $permalink | safeURL }}"
3937
{{- with .Title }} title="{{ . }}"{{ end }}
40-
{{- if $isRemote }} target="_blank" rel="noopener noreferrer"{{ else }} class="{{ $class }}"{{ end }}>
38+
{{- if $isRemote }} target="_blank" rel="noopener noreferrer"{{ end }} class="link">
4139
{{- .Text | safeHTML -}}
4240
</a>
41+
{{- if $isRemote }}&nbsp;<i class="fas fa-external-link-alt"></i>{{ end }}
4342
{{- /* whitespace control */ -}}

site/themes/arangodb-docs-theme/layouts/partials/breadcrumbs.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{{ if not .IsHome }}
66
<li itemscope itemtype="https://schema.org/ListItem" itemprop="itemListElement">
77
<meta itemprop="position" content="{{ .Params.menuTitle }}" />
8-
<a itemprop="item" class="link-internal" href="{{ .RelPermalink }}">
8+
<a itemprop="item" class="link" href="{{ .RelPermalink }}">
99
<span itemprop="name" class="breadcrumb-entry">{{- if eq (len .Ancestors) 1 }}{{ template "getVersionLong" dict "page" .Page }}{{ else }}{{ .Params.menuTitle | markdownify }}{{ end }}</span>
1010
</a>
1111
<i class="fas fa-chevron-right fa-fw"></i>
@@ -15,7 +15,7 @@
1515
{{ if not .IsHome }}
1616
<li itemscope itemtype="https://schema.org/ListItem" itemprop="itemListElement">
1717
<meta itemprop="position" content="{{ .Params.menuTitle }}" />
18-
<a itemprop="item" class="link-internal" href="{{ .RelPermalink }}">
18+
<a itemprop="item" class="link" href="{{ .RelPermalink }}">
1919
<span itemprop="name" class="breadcrumb-entry">{{- if eq (len .Ancestors) 1 }}{{ template "getVersionLong" dict "page" .Page }}{{ else }}{{ .Params.menuTitle | markdownify }}{{ end }}</span>
2020
</a>
2121
</li>

site/themes/arangodb-docs-theme/layouts/partials/content-footer.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@
6262
<span class="prev">
6363
{{ with $prev }}
6464
{{- if eq (len .Ancestors) 1 }}
65-
<a class="nav nav-prev link-internal" href="" title="">
65+
<a class="nav nav-prev link" href="" title="">
6666
</a>
6767
{{ else }}
68-
<a class="nav nav-prev link-internal" href="{{.RelPermalink}}" title="{{.Params.menuTitle}}">
68+
<a class="nav nav-prev link" href="{{.RelPermalink}}" title="{{.Params.menuTitle}}">
6969
<i class="fas fa-chevron-left fa-fw"></i><p>{{.Params.menuTitle | markdownify}}</p></a>
7070
{{- end}}
7171
{{ end }}
@@ -74,7 +74,7 @@
7474

7575
<span class="next">
7676
{{ with $next }}
77-
<a class="nav nav-next link-internal" href="{{.RelPermalink}}" title="{{.Params.menuTitle}}">
77+
<a class="nav nav-next link" href="{{.RelPermalink}}" title="{{.Params.menuTitle}}">
7878
<p>{{.Params.menuTitle | markdownify}}</p><i class="fas fa-chevron-right fa-fw"></i></a>
7979
{{- end }}
8080
</span>

site/themes/arangodb-docs-theme/layouts/partials/shortcodes/card.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
{{ $destinationPage = $context.Page.GetPage $link -}}
99
{{ end }}
1010

11-
<a href="{{ $destinationPage.RelPermalink }}" class="link-internal">
11+
<a href="{{ $destinationPage.RelPermalink }}" class="link">
1212
<div class="card">
1313
<div class="card-head">
1414
{{ with $image }}<img

site/themes/arangodb-docs-theme/layouts/shortcodes/cloudbanner.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<div>
44
<div class="ag-info">
55
Experience the shortest time to value for a hosted graph DB.</div>
6-
<a class="link-internal" href="https://cloud.arangodb.com/home" target="_agCloud">
6+
<a class="link" href="https://cloud.arangodb.com/home" target="_agCloud">
77
Get Started Today!
88
</a>
99
</div>

site/themes/arangodb-docs-theme/static/css/theme.css

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -189,27 +189,27 @@ ul ul, ul ol, ol ul, ol ol {
189189
margin-bottom: .5rem;
190190
}
191191

192-
.link-internal {
192+
.link {
193193
text-decoration: none;
194194
border-bottom: 2px solid var(--green-600);
195195
}
196196

197-
.link-internal:hover{
197+
.link:hover{
198198
border-bottom: 2px solid var(--green-600);
199199
color: var(--gray-950);
200200
}
201201

202-
.link-internal > * {
202+
.link > * {
203203
text-decoration: none;
204204
pointer-events: none;
205205
}
206206

207-
.link-internal > p {
207+
.link > p {
208208
border-bottom: 2px solid var(--green-600);
209209
color: var(--gray-950);
210210
}
211211

212-
.link-internal:has(code) {
212+
.link:has(code) {
213213
border-bottom: 2px solid var(--green-600);
214214
font-size: 14px;
215215
overflow: auto;
@@ -222,12 +222,12 @@ ul ul, ul ol, ol ul, ol ol {
222222
box-shadow: none;
223223
color: var(--gray-950);
224224
}
225-
.link-internal > code {
225+
.link > code {
226226
background-color: transparent;
227227
border: none;
228228
}
229229

230-
.link-internal > i {
230+
.link > i {
231231
color: var(--gray-950);
232232
text-decoration: none;
233233
}
@@ -390,7 +390,7 @@ table.fixed code {
390390
box-shadow: rgb(149 157 165 / 20%) 0px 8px 24px;
391391
} */
392392

393-
.cards > a.link-internal {
393+
.cards > a.link {
394394
border-bottom: 0px;
395395
}
396396

@@ -1990,7 +1990,7 @@ nav.pagination .next {
19901990
.nav-prev {
19911991
display: inherit;
19921992
}
1993-
.nav-prev.link-internal, .nav-next.link-internal {
1993+
.nav-prev.link, .nav-next.link {
19941994
border-bottom: 0;
19951995
}
19961996

site/themes/arangodb-docs-theme/static/js/theme.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,11 @@ function loadPage(target) {
175175
}
176176

177177
function internalLinkListener() {
178-
$('.link-internal').click(function(event) {
178+
$('.link').click(function(event) {
179+
if (event.target.getAttribute("target")) {
180+
// external link
181+
return;
182+
}
179183
event.preventDefault();
180184
updateHistory("", event.target.getAttribute('href'))
181185
})
@@ -199,7 +203,7 @@ function initArticle(url) {
199203
styleImages();
200204
internalLinkListener();
201205
codeShowMoreListener();
202-
aliazeLinks('article', 'a.link-internal');
206+
aliazeLinks('article', 'a.link:not([target])');
203207
aliazeLinks('article', 'a.header-link');
204208
aliazeLinks('#breadcrumbs', 'a')
205209
}

0 commit comments

Comments
 (0)