add toast and bgraham
This commit is contained in:
parent
19b4da3d42
commit
b531ec40dc
2 changed files with 33 additions and 18 deletions
|
@ -508,6 +508,15 @@ export const authors: Readonly<{ [key: string]: Author }> = {
|
||||||
image: '/img/profiles/cbordalo.jpg',
|
image: '/img/profiles/cbordalo.jpg',
|
||||||
nationality: ['phl', 'usa'],
|
nationality: ['phl', 'usa'],
|
||||||
},
|
},
|
||||||
|
bgraham: {
|
||||||
|
name: {
|
||||||
|
first: 'Benjamin',
|
||||||
|
last: 'Graham',
|
||||||
|
},
|
||||||
|
affiliation: ['Student@srvhs'],
|
||||||
|
image: '/img/profiles/bgraham.jpg',
|
||||||
|
nationality: ['usa'],
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Affiliation {
|
export interface Affiliation {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import Link from 'next/link'
|
||||||
import { loadAuthors } from '@/app/db/loaders'
|
import { loadAuthors } from '@/app/db/loaders'
|
||||||
import { useSuspenseQuery } from '@tanstack/react-query'
|
import { useSuspenseQuery } from '@tanstack/react-query'
|
||||||
import { epoch2date } from '@/app/utils/epoch2datestring'
|
import { epoch2date } from '@/app/utils/epoch2datestring'
|
||||||
|
import { toast } from 'react-toastify'
|
||||||
|
|
||||||
const VersionChooser = ({
|
const VersionChooser = ({
|
||||||
doc,
|
doc,
|
||||||
|
@ -25,6 +26,28 @@ const VersionChooser = ({
|
||||||
|
|
||||||
const fileEnding = file === 'other' ? '' : `.${file}`
|
const fileEnding = file === 'other' ? '' : `.${file}`
|
||||||
const [selectedRevision, setSelectedRevision] = useState<number>(latest) // Initialize the selected revision with the latest revision
|
const [selectedRevision, setSelectedRevision] = useState<number>(latest) // Initialize the selected revision with the latest revision
|
||||||
|
const notifyCopied = () =>
|
||||||
|
toast('BibTeX copied to clipboard!', { type: 'success' })
|
||||||
|
|
||||||
|
const handleClick = () => {
|
||||||
|
const bibtex = `@article{
|
||||||
|
author={${authors
|
||||||
|
.map((a: string, i) => {
|
||||||
|
const author = data[a].name.first + ' ' + data[a].name.last
|
||||||
|
if (i === 0) return author
|
||||||
|
else if (i === authors.length - 1) return ` and ${author}`
|
||||||
|
else return `, ${author}`
|
||||||
|
})
|
||||||
|
.join('')}},
|
||||||
|
title={${doc.manifest.title}},
|
||||||
|
journal={eeXiv journal},
|
||||||
|
year={${date.getFullYear()}},
|
||||||
|
month={${date.toLocaleString('default', { month: 'short' })}},
|
||||||
|
url={${window.location.href}}
|
||||||
|
}`
|
||||||
|
navigator.clipboard.writeText(bibtex)
|
||||||
|
notifyCopied()
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
@ -46,24 +69,7 @@ const VersionChooser = ({
|
||||||
</Link>
|
</Link>
|
||||||
<button
|
<button
|
||||||
className='ml-2 h-10 px-2.5 bg-slate-300 rounded-md'
|
className='ml-2 h-10 px-2.5 bg-slate-300 rounded-md'
|
||||||
onClick={() => {
|
onClick={handleClick}
|
||||||
const bibtex = `@article{
|
|
||||||
author={${authors
|
|
||||||
.map((a: string, i) => {
|
|
||||||
const author = data[a].name.first + ' ' + data[a].name.last
|
|
||||||
if (i === 0) return author
|
|
||||||
else if (i === authors.length - 1) return ` and ${author}`
|
|
||||||
else return `, ${author}`
|
|
||||||
})
|
|
||||||
.join('')}},
|
|
||||||
title={${doc.manifest.title}},
|
|
||||||
journal={eeXiv journal},
|
|
||||||
year={${date.getFullYear()}},
|
|
||||||
month={${date.toLocaleString('default', { month: 'short' })}},
|
|
||||||
url={${window.location.href}}
|
|
||||||
}`
|
|
||||||
navigator.clipboard.writeText(bibtex)
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
Export BibTeX
|
Export BibTeX
|
||||||
</button>
|
</button>
|
||||||
|
|
Loading…
Reference in a new issue