Skip to content

Commit

Permalink
feat: handle external link on sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
imyelo committed Jun 24, 2022
1 parent 902b085 commit 015a191
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions example/router-mode-history/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
- [Foo](/example/router-mode-history/foo.md#section-3)
- [Bar A Long Long Long Title](/example/router-mode-history/bar.md)
- [Baz](/example/router-mode-history/baz.md)
- [External](https://github.com/)
7 changes: 4 additions & 3 deletions src/pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ class Link {
return {
name: this.hyperlink.innerText,
href: this.hyperlink.getAttribute('href'),
chapterName: this.chapter && this.chapter.innerText || ''
chapterName: this.chapter && this.chapter.innerText || '',
isExternal: this.hyperlink.getAttribute('target') === '_blank',
}
}
}
Expand Down Expand Up @@ -100,7 +101,7 @@ const template = {
return [
data.prev && `
<div class="pagination-item pagination-item--previous">
<a href="${data.prev.href}">
<a href="${data.prev.href}" ${data.prev.isExternal ? 'target="_blank"' : ''}>
<div class="pagination-item-label">
<svg width="10" height="16" viewBox="0 0 10 16" xmlns="http://www.w3.org/2000/svg">
<polyline fill="none" vector-effect="non-scaling-stroke" points="8,2 2,8 8,14"/>
Expand All @@ -115,7 +116,7 @@ const template = {
`,
data.next && `
<div class="pagination-item pagination-item--next">
<a href="${data.next.href}">
<a href="${data.next.href}" ${data.next.isExternal ? 'target="_blank"' : ''}>
<div class="pagination-item-label">
<span>${nextText}</span>
<svg width="10" height="16" viewBox="0 0 10 16" xmlns="http://www.w3.org/2000/svg">
Expand Down

0 comments on commit 015a191

Please sign in to comment.