|
| 1 | +import React, { useLayoutEffect } from 'react' |
| 2 | +import { Helmet } from 'react-helmet' |
| 3 | + |
| 4 | +const ArticleHelmet = ({ |
| 5 | + url='', |
| 6 | + imageUrl='', |
| 7 | + plainTitle='', |
| 8 | + excerpt='', |
| 9 | + plainContributor='', |
| 10 | + plainKeywords=[], |
| 11 | + issue, |
| 12 | + publicationDate = new Date() |
| 13 | +}) => { |
| 14 | + // apply zotero when the DOM is ready |
| 15 | + useLayoutEffect(() => { |
| 16 | + console.debug('[ArticleHelmet] @useLayoutEffect') |
| 17 | + document.dispatchEvent(new Event('ZoteroItemUpdated', { |
| 18 | + bubbles: true, |
| 19 | + cancelable: true |
| 20 | + })) |
| 21 | + }, [url]) |
| 22 | + |
| 23 | + return ( |
| 24 | + <Helmet> |
| 25 | + <meta property="og:site_name" content="Journal of Digital history" /> |
| 26 | + <meta property="og:title" content={plainTitle} /> |
| 27 | + <meta property="og:description" content={excerpt} /> |
| 28 | + <meta property="og:type" content="article" /> |
| 29 | + <meta property="og:image" content={imageUrl} /> |
| 30 | + <meta property="og:url" content={window.location} /> |
| 31 | + <meta property="article:author" content={plainContributor} /> |
| 32 | + <meta property="article:published_time" content={publicationDate.toISOString().split('T').shift()} /> |
| 33 | + <meta property="article:section" content={issue?.pid || ''} /> |
| 34 | + {plainKeywords.map((k,i) => ( |
| 35 | + <meta key={i} property="article:tag" content={k} /> |
| 36 | + ))} |
| 37 | + <meta name="dc.title" content={plainTitle} /> |
| 38 | + <meta name="dc.format" content="text/html" /> |
| 39 | + <meta name="dc.publisher" content="DeGruyter" /> |
| 40 | + <meta name="dc.type" content="OriginalPaper" /> |
| 41 | + <meta name="dc.language" content="En" /> |
| 42 | + {plainContributor.split(', ').map((d,i) => ( |
| 43 | + <meta key={i} name="dc.creator" content={d} /> |
| 44 | + ))} |
| 45 | + {/* |
| 46 | + dc:title Studying E-Journal User Behavior Using Log Files |
| 47 | + dc:creator Yu, L |
| 48 | + dc:creator Apps, A |
| 49 | + dc:subject http://purl.org/dc/terms/DDC 020 |
| 50 | + dc:subject http://purl.org/dc/terms/LCC Z671 |
| 51 | + dc:publisher Elsevier |
| 52 | + dc:type http://purl.org/dc/terms/DCMIType Text |
| 53 | + dcterms:issued http://purl.org/dc/terms/W3CDTF 2000 |
| 54 | + dcterms:isPartOf urn:ISSN:0740-8188 |
| 55 | + dcterms:bibliographicCitation |
| 56 | + */} |
| 57 | + {plainKeywords.map((k,i) => ( |
| 58 | + <meta key={i} property="dc.subject" content={k} /> |
| 59 | + ))} |
| 60 | + |
| 61 | + <meta name="citation_journal_title" content="Journal of Digital history"/> |
| 62 | + <meta name="citation_journal_abbrev" content="JDH"/> |
| 63 | + <meta name="citation_publisher" content="DeGruyter"/> |
| 64 | + <meta name="citation_title" content={plainTitle}/> |
| 65 | + <meta name="citation_issue" content={issue?.pid}/> |
| 66 | + |
| 67 | + </Helmet> |
| 68 | + ) |
| 69 | +} |
| 70 | + |
| 71 | +export default ArticleHelmet |
0 commit comments