Skip to content

Commit 6d6377c

Browse files
committed
fix: remove failing citations
1 parent 8c6175c commit 6d6377c

File tree

2 files changed

+191
-187
lines changed

2 files changed

+191
-187
lines changed
Lines changed: 75 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,82 @@
1-
import { Container, Text } from '@mantine/core'
2-
import { definitions } from 'ojs-client'
3-
import useSWR from 'swr'
4-
import { Data as CSL } from 'csl-json'
1+
import { Container, Text } from "@mantine/core";
52
// @ts-expect-error no types for cites
6-
import Cite from 'citation-js'
3+
import Cite from "citation-js";
4+
import { Data as CSL } from "csl-json";
5+
import type { definitions } from "ojs-client";
6+
import useSWR from "swr";
77

88
export const Citations = ({
9-
value,
10-
extra,
9+
value,
10+
extra,
1111
}: {
12-
value: definitions['Publication']['citations']
13-
extra: string
12+
value: definitions["Publication"]["citations"];
13+
extra: string;
1414
}) => {
15-
const url =
16-
// process.env.NODE_ENV === 'production'
17-
// ? '/api/style'
18-
// :
19-
process.env.NEXT_PUBLIC_STYLE_DEV_URL || 'http://localhost:8000/api/style'
20-
const splitextra = extra
21-
?.replace(/\\r/g, '')
22-
?.replace(/\n([A-Z])/g, '\n\n\n$1')
23-
?.replace(/\n([^A-Z])/g, '$1')
24-
//console.log(splitextra)
25-
const { data, error } = useSWR(url, (resource: string, init: any) =>
26-
fetch(url, {
27-
method: 'post',
28-
body: splitextra,
29-
}).then((response) => response.json()),
30-
)
31-
if (error || !data) {
32-
return (
33-
<Container sx={{ overflow: 'scroll', maxHeight: 500 }}>
34-
{value?.map((cite) => (
35-
<Text key={cite} dangerouslySetInnerHTML={{ __html: cite }} />
36-
))}
37-
</Container>
38-
)
39-
}
15+
const url =
16+
// process.env.NODE_ENV === 'production'
17+
// ? '/api/style'
18+
// :
19+
process.env.NEXT_PUBLIC_STYLE_DEV_URL || "http://localhost:8000/api/style";
20+
const splitextra = extra
21+
?.replace(/\\r/g, "")
22+
?.replace(/\n([A-Z])/g, "\n\n\n$1")
23+
?.replace(/\n([^A-Z])/g, "$1");
24+
//console.log(splitextra)
25+
const { data, error } = useSWR(url, (resource: string, init: any) =>
26+
fetch(url, {
27+
method: "post",
28+
body: splitextra,
29+
}).then((response) => response.json()),
30+
);
31+
if (error || !data) {
32+
return (
33+
<Container sx={{ overflow: "scroll", maxHeight: 500 }}>
34+
{value?.map((cite) => (
35+
<Text key={cite} dangerouslySetInnerHTML={{ __html: cite }} />
36+
))}
37+
</Container>
38+
);
39+
}
4040

41-
const cite = new Cite(
42-
data.map((data: CSL) => {
43-
if (!data.type) {
44-
data.type = 'article'
45-
}
46-
return data
47-
}),
48-
)
49-
const biblatex = cite.format('biblatex')
50-
const bibtex = cite.format('bibtex')
51-
const ris = cite.format('ris')
52-
const csl = data
41+
// const cite = new Cite(
42+
// data.map((data: CSL) => {
43+
// if (!data.type) {
44+
// data.type = 'article'
45+
// }
46+
// return data
47+
// }),
48+
// )
49+
// const biblatex = cite.format('biblatex')
50+
// const bibtex = cite.format('bibtex')
51+
// const ris = cite.format('ris')
52+
// const csl = data
5353

54-
return (
55-
// <Prism.Tabs defaultValue="Rich Text">
56-
// <Prism.Tab
57-
// withLineNumbers
58-
// language="actionscript"
59-
// value="Rich Text"
60-
// sx={{ whiteSpace: 'pre-wrap', maxWidth: '70vw' }}
61-
// >
62-
// {value?.join('\n') ?? ' '}
63-
// {/* {value?.map((cite) => (
64-
// <Text key={cite} dangerouslySetInnerHTML={{ __html: cite }} />
65-
// ))} */}
66-
// </Prism.Tab>
67-
// <Prism.Tab withLineNumbers language="clike" value="biblatex">
68-
// {biblatex ?? ' '}
69-
// </Prism.Tab>
70-
// <Prism.Tab withLineNumbers language="clike" value="bibtex">
71-
// {bibtex ?? ' '}
72-
// </Prism.Tab>
73-
// <Prism.Tab withLineNumbers language="jsx" value="ris">
74-
// {ris ?? ' '}
75-
// </Prism.Tab>
76-
// <Prism.Tab withLineNumbers language="json" value="csl">
77-
// {JSON.stringify(csl, null, 2) ?? ' '}
78-
// </Prism.Tab>
79-
// </Prism.Tabs>
80-
<div />
81-
)
82-
}
54+
return (
55+
// <Prism.Tabs defaultValue="Rich Text">
56+
// <Prism.Tab
57+
// withLineNumbers
58+
// language="actionscript"
59+
// value="Rich Text"
60+
// sx={{ whiteSpace: 'pre-wrap', maxWidth: '70vw' }}
61+
// >
62+
// {value?.join('\n') ?? ' '}
63+
// {/* {value?.map((cite) => (
64+
// <Text key={cite} dangerouslySetInnerHTML={{ __html: cite }} />
65+
// ))} */}
66+
// </Prism.Tab>
67+
// <Prism.Tab withLineNumbers language="clike" value="biblatex">
68+
// {biblatex ?? ' '}
69+
// </Prism.Tab>
70+
// <Prism.Tab withLineNumbers language="clike" value="bibtex">
71+
// {bibtex ?? ' '}
72+
// </Prism.Tab>
73+
// <Prism.Tab withLineNumbers language="jsx" value="ris">
74+
// {ris ?? ' '}
75+
// </Prism.Tab>
76+
// <Prism.Tab withLineNumbers language="json" value="csl">
77+
// {JSON.stringify(csl, null, 2) ?? ' '}
78+
// </Prism.Tab>
79+
// </Prism.Tabs>
80+
<div />
81+
);
82+
};
Lines changed: 116 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,121 @@
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";
88

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];
1111
export const RenderPubMeta = ({
12-
datakey,
13-
value,
14-
extra,
15-
options,
12+
datakey,
13+
value,
14+
extra,
15+
options,
1616
}: {
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 };
2121
}) => {
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+
};
7577

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

Comments
 (0)