Skip to content

Commit

Permalink
external links
Browse files Browse the repository at this point in the history
  • Loading branch information
recrwplay committed Mar 5, 2024
1 parent 4e15b8f commit d0e9442
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 1 deletion.
39 changes: 39 additions & 0 deletions preview-src/links.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
= Links
:nofooter:
:neo4j-docs-base-uri: https://neo4j.com/docs

== angle brackets

<<to-docs, to docs!>>


== xref

xref:labs.adoc[]


[[to-docs]]
== link to neo4j.com/docs

internal: link:https://neo4j.com/docs[neo4j.com/docs]

external: link:https://neo4j.com/docs[neo4j.com/docs^]

attribute: link:{neo4j-docs-base-uri}[neo4j.com/docs]

attribute (external): link:{neo4j-docs-base-uri}[neo4j.com/docs^]


== link to neo4j.com

internal: link:https://neo4j.com[neo4j.com]

external: link:https://neo4j.com[neo4j.com^]


== link to example.com

internal: link:https://example.com[example.com]

external: link:https://example.com[example.com^]

3 changes: 3 additions & 0 deletions preview-src/ui-model.yml
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ page:
- content: Feedback disabled
url: feedback-disabled.html
urlType: internal
- content: Links
url: links.html
urlType: internal
- content: Docs roles
url: docs-roles.html
urlType: internal
Expand Down
19 changes: 18 additions & 1 deletion src/js/14-external-links.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
// external links
// link:https://example.com[text^] - add class external and aria-label (already has target="_blank")
// link:https://example.com[text] - do nothing
// links to other docs pages are not external
// link:https://neo4j.com/docs/...[] - do nothing
// link:{neo4j-docs-bas-uri}/...[] - do nothing

;(function () {
'use strict'

document.querySelectorAll('.doc a[href^="http"], .doc a[target="_blank"]')
// open all non neo4j.com/docs links in a new tab
// document.querySelectorAll('.doc a[href^="http"]')
// .forEach(function (el) {
// if (!el.href.includes('neo4j.com/docs')) {
// // el.setAttribute('target', '_blank');
// // el.classList.add('external')
// }
// })

// add class and aria-label to all links that open in a new tab
document.querySelectorAll('.doc a[target="_blank"]')
.forEach(function (el) {
el.classList.add('external')
el.setAttribute('aria-label', 'Link label (opens in new tab)')
Expand Down

0 comments on commit d0e9442

Please sign in to comment.