Skip to content
This repository has been archived by the owner on Nov 17, 2021. It is now read-only.

Commit

Permalink
feat(eLife): Add target=“_parent” to download links
Browse files Browse the repository at this point in the history
  • Loading branch information
nlisgo committed Jul 6, 2020
2 parents adb8a0b + 02b0361 commit 79b427b
Showing 1 changed file with 13 additions and 29 deletions.
42 changes: 13 additions & 29 deletions src/themes/elife/lib/downloads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const deriveUrl = (type: string, id: string, title = ''): string => {
const buildLinkToFiguresPdf = (url: string): void => {
after(
select('[data-is-download-pdf-list-item]')[0],
create('li', null, create('a', { href: url }, 'Figures PDF'))
create('li', null, createSimpleLink(url, 'Figures PDF'))
)
}

Expand All @@ -32,6 +32,8 @@ const buildMenu = (
pdfUrl: string,
menuId: string
): void => {
const pdfLink = createSimpleLink(pdfUrl, 'Article PDF')
pdfLink.setAttribute('data-is-download-pdf-list-item', 'true')
after(
select(':--references')[0],
create(
Expand All @@ -40,29 +42,17 @@ const buildMenu = (

create('h2', null, 'Download links'),
create('h3', null, 'Downloads'),
create(
'ul',
null,
create(
'li',
{ 'data-is-download-pdf-list-item': true },
create('a', { href: pdfUrl }, 'Article PDF')
)
),
create('ul', null, create('li', null, pdfLink)),
create('h3', null, 'Download citations'),
create(
'ul',
null,
create(
'li',
null,
create('a', { href: `${deriveUrl('bibtex', articleId)}` }, 'BibTeX')
createSimpleLink(deriveUrl('bibtex', articleId), 'BibTeX')
),
create(
'li',
null,
create('a', { href: `${deriveUrl('ris', articleId)}` }, 'RIS')
)
create('li', null, createSimpleLink(deriveUrl('ris', articleId), 'RIS'))
),
create('h3', null, 'Open citations'),
create(
Expand All @@ -71,27 +61,18 @@ const buildMenu = (
create(
'li',
null,
create(
'a',
{ href: `${deriveUrl('mendeley', articleId)}` },
'Mendeley'
)
createSimpleLink(deriveUrl('mendeley', articleId), 'Mendeley')
),
create(
'li',
null,
create(
'a',
{ href: `${deriveUrl('readcube', articleId)}` },
'ReadCube'
)
createSimpleLink(deriveUrl('readcube', articleId), 'ReadCube')
),
create(
'li',
null,
create(
'a',
{ href: `${deriveUrl('papers', articleId, articleTitle)}` },
createSimpleLink(
deriveUrl('papers', articleId, articleTitle),
'Papers'
)
)
Expand Down Expand Up @@ -125,6 +106,9 @@ const buildLinkToMenu = (menuId: string): Promise<unknown> => {
return Promise.resolve()
}

const createSimpleLink = (href: string, text: string): Element =>
create('a', { href, target: '_parent' }, text)

export const build = (articleTitle: string, articleId: string): void => {
const menuId = 'downloadMenu'
try {
Expand Down

0 comments on commit 79b427b

Please sign in to comment.