From 87df483f8b334913349f24a2a6ad567d5800e790 Mon Sep 17 00:00:00 2001 From: David Moulton Date: Fri, 27 Mar 2020 15:26:46 +0000 Subject: [PATCH] feat(Elife): Obtain article id & use in download menu links --- src/themes/elife/index.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/themes/elife/index.ts b/src/themes/elife/index.ts index f8dff2558..38491d9cd 100644 --- a/src/themes/elife/index.ts +++ b/src/themes/elife/index.ts @@ -1,4 +1,4 @@ -import { first, ready } from '../../util' +import {first, ready, select} from '../../util' import * as downloads from './downloads' import DateTimeFormat = Intl.DateTimeFormat @@ -15,11 +15,17 @@ const formatDate = (dateEl: Element | null): void => { } } +const getArticleId = (): string => { + const selector = + ':--identifier meta[content="https://registry.identifiers.org/registry/publisher-id"] ~ [itemprop="value"]' + return first(selector)?.innerHTML ?? '' +} + ready((): void => { formatDate(first(':--datePublished')) downloads.build( - 'TheArticleId', + getArticleId(), first(':--title')?.getAttribute('content') ?? '' ) })