|
1 | | -import { Box, Container, Text, Title } from '@mantine/core' |
2 | | -import Link from 'next/link' |
3 | | -import { definitions } from 'ojs-client' |
4 | | -import React from 'react' |
5 | | -import { FaOrcid } from 'react-icons/fa' |
6 | | -import { HStack } from '../stack/stack' |
7 | | -import { Citations } from './citations' |
| 1 | +import { Box, Container, Text, Title } from "@mantine/core"; |
| 2 | +import Link from "next/link"; |
| 3 | +import type { definitions } from "ojs-client"; |
| 4 | +import React from "react"; |
| 5 | +import { FaOrcid } from "react-icons/fa"; |
| 6 | +import { HStack } from "../stack/stack"; |
| 7 | +import { Citations } from "./citations"; |
8 | 8 |
|
9 | | -export type PublicationKeys = keyof definitions['Publication'] |
10 | | -export type PublicationTypes = definitions['Publication'][PublicationKeys] |
| 9 | +export type PublicationKeys = keyof definitions["Publication"]; |
| 10 | +export type PublicationTypes = definitions["Publication"][PublicationKeys]; |
11 | 11 | export const RenderPubMeta = ({ |
12 | | - datakey, |
13 | | - value, |
14 | | - extra, |
15 | | - options, |
| 12 | + datakey, |
| 13 | + value, |
| 14 | + extra, |
| 15 | + options, |
16 | 16 | }: { |
17 | | - datakey: PublicationKeys |
18 | | - value: definitions['Publication'][typeof datakey] |
19 | | - extra?: any |
20 | | - options?: { showEmpty?: boolean } |
| 17 | + datakey: PublicationKeys; |
| 18 | + value: definitions["Publication"][typeof datakey]; |
| 19 | + extra?: any; |
| 20 | + options?: { showEmpty?: boolean }; |
21 | 21 | }) => { |
22 | | - switch (datakey) { |
23 | | - case '_href': |
24 | | - return <></> |
25 | | - case 'abstract': |
26 | | - return ( |
27 | | - <Container |
28 | | - sx={{ overflow: 'scroll', maxHeight: 500 }} |
29 | | - //@ts-expect-error booo |
30 | | - dangerouslySetInnerHTML={{ __html: value?.en_US as string }} |
31 | | - /> |
32 | | - ) |
33 | | - case 'authors': |
34 | | - /* @ts-expect-error booo */ |
35 | | - return <AuthorsContainer authors={value} /> |
36 | | - case 'citations': |
37 | | - return <Citations {...{ value: value as any, extra: extra as any }} /> |
38 | | - case 'keywords': |
39 | | - return ( |
40 | | - <HStack> |
41 | | - {/*@ts-expect-error booo*/} |
42 | | - {(value as definitions['Publication']['keywords'])?.en_US?.map((keyw: string) => ( |
43 | | - <Box |
44 | | - sx={{ |
45 | | - borderRadius: 10, |
46 | | - borderWidth: 1, |
47 | | - padding: 4, |
48 | | - paddingLeft: 8, |
49 | | - paddingRight: 8, |
50 | | - backgroundColor: 'darkblue', |
51 | | - color: 'white', |
52 | | - fontWeight: 'bold', |
53 | | - }} |
54 | | - key={keyw} |
55 | | - > |
56 | | - <Text size="sm">{keyw}</Text> |
57 | | - </Box> |
58 | | - ))} |
59 | | - </HStack> |
60 | | - ) |
61 | | - case 'title': |
62 | | - /*@ts-expect-error booo*/ |
63 | | - return <Title sx={{ fontSize: '1.5em' }}>{value.en_US as string}</Title> |
64 | | - case 'subtitle': |
65 | | - return ( |
66 | | - <Text size="xl" sx={{ fontStyle: 'italic' }}> |
67 | | - {/*@ts-expect-error booo*/} |
68 | | - {value.en_US as string} |
69 | | - </Text> |
70 | | - ) |
71 | | - default: |
72 | | - return <></> |
73 | | - } |
74 | | -} |
| 22 | + switch (datakey) { |
| 23 | + case "_href": |
| 24 | + return <></>; |
| 25 | + case "abstract": |
| 26 | + return ( |
| 27 | + <Container |
| 28 | + sx={{ overflow: "scroll", maxHeight: 500 }} |
| 29 | + //@ts-expect-error booo |
| 30 | + dangerouslySetInnerHTML={{ __html: value?.en_US as string }} |
| 31 | + /> |
| 32 | + ); |
| 33 | + case "authors": |
| 34 | + /* @ts-expect-error booo */ |
| 35 | + return <AuthorsContainer authors={value} />; |
| 36 | + // case 'citations': |
| 37 | + // return <Citations {...{ value: value as any, extra: extra as any }} /> |
| 38 | + case "keywords": |
| 39 | + return ( |
| 40 | + <HStack> |
| 41 | + {/*@ts-expect-error booo*/} |
| 42 | + {(value as definitions["Publication"]["keywords"])?.en_US?.map( |
| 43 | + (keyw: string) => ( |
| 44 | + <Box |
| 45 | + sx={{ |
| 46 | + borderRadius: 10, |
| 47 | + borderWidth: 1, |
| 48 | + padding: 4, |
| 49 | + paddingLeft: 8, |
| 50 | + paddingRight: 8, |
| 51 | + backgroundColor: "darkblue", |
| 52 | + color: "white", |
| 53 | + fontWeight: "bold", |
| 54 | + }} |
| 55 | + key={keyw} |
| 56 | + > |
| 57 | + <Text size="sm">{keyw}</Text> |
| 58 | + </Box> |
| 59 | + ), |
| 60 | + )} |
| 61 | + </HStack> |
| 62 | + ); |
| 63 | + case "title": |
| 64 | + /*@ts-expect-error booo*/ |
| 65 | + return <Title sx={{ fontSize: "1.5em" }}>{value.en_US as string}</Title>; |
| 66 | + case "subtitle": |
| 67 | + return ( |
| 68 | + <Text size="xl" sx={{ fontStyle: "italic" }}> |
| 69 | + {/*@ts-expect-error booo*/} |
| 70 | + {value.en_US as string} |
| 71 | + </Text> |
| 72 | + ); |
| 73 | + default: |
| 74 | + return <></>; |
| 75 | + } |
| 76 | +}; |
75 | 77 |
|
76 | | -export const AuthorsContainer = (props: { authors: definitions['Publication']['authors'] }) => { |
77 | | - const { authors } = props |
78 | | - return ( |
79 | | - <Container |
80 | | - sx={{ |
81 | | - display: 'flex', |
82 | | - alignItems: 'flex-start', |
83 | | - flexDirection: 'column', |
84 | | - marginLeft: 0, |
85 | | - }} |
86 | | - > |
87 | | - {authors?.map((author) => { |
88 | | - return ( |
89 | | - <Box key={author.id}> |
90 | | - <HStack spacing={5} sx={{ fontWeight: 'bold' }}> |
91 | | - {/* @ts-expect-error booo */} |
92 | | - <Text>{author?.familyName?.en_US},</Text> |
93 | | - {/* @ts-expect-error booo */} |
94 | | - <Text>{author?.givenName?.en_US}</Text> |
95 | | - {author?.orcid && ( |
96 | | - <Link href={author.orcid}> |
97 | | - <FaOrcid /> |
98 | | - </Link> |
99 | | - )} |
100 | | - </HStack> |
101 | | - <Text sx={{ fontStyle: 'italic' }}> |
102 | | - {/* @ts-expect-error booo */} |
103 | | - {author?.affiliation?.en_US} |
104 | | - </Text> |
105 | | - <Link href={`mailto:${author?.email}}`}>{author?.email}</Link> |
106 | | - {author?.biography && <Text>{author?.biography}</Text>} |
107 | | - {author?.orcid && ( |
108 | | - <Link href={author.orcid} passHref> |
109 | | - <Text>{author?.orcid}</Text> |
110 | | - </Link> |
111 | | - )} |
112 | | - </Box> |
113 | | - ) |
114 | | - })} |
115 | | - </Container> |
116 | | - ) |
117 | | -} |
| 78 | +export const AuthorsContainer = (props: { |
| 79 | + authors: definitions["Publication"]["authors"]; |
| 80 | +}) => { |
| 81 | + const { authors } = props; |
| 82 | + return ( |
| 83 | + <Container |
| 84 | + sx={{ |
| 85 | + display: "flex", |
| 86 | + alignItems: "flex-start", |
| 87 | + flexDirection: "column", |
| 88 | + marginLeft: 0, |
| 89 | + }} |
| 90 | + > |
| 91 | + {authors?.map((author) => { |
| 92 | + return ( |
| 93 | + <Box key={author.id}> |
| 94 | + <HStack spacing={5} sx={{ fontWeight: "bold" }}> |
| 95 | + {/* @ts-expect-error booo */} |
| 96 | + <Text>{author?.familyName?.en_US},</Text> |
| 97 | + {/* @ts-expect-error booo */} |
| 98 | + <Text>{author?.givenName?.en_US}</Text> |
| 99 | + {author?.orcid && ( |
| 100 | + <Link href={author.orcid}> |
| 101 | + <FaOrcid /> |
| 102 | + </Link> |
| 103 | + )} |
| 104 | + </HStack> |
| 105 | + <Text sx={{ fontStyle: "italic" }}> |
| 106 | + {/* @ts-expect-error booo */} |
| 107 | + {author?.affiliation?.en_US} |
| 108 | + </Text> |
| 109 | + <Link href={`mailto:${author?.email}}`}>{author?.email}</Link> |
| 110 | + {author?.biography && <Text>{author?.biography}</Text>} |
| 111 | + {author?.orcid && ( |
| 112 | + <Link href={author.orcid} passHref> |
| 113 | + <Text>{author?.orcid}</Text> |
| 114 | + </Link> |
| 115 | + )} |
| 116 | + </Box> |
| 117 | + ); |
| 118 | + })} |
| 119 | + </Container> |
| 120 | + ); |
| 121 | +}; |
0 commit comments