style: format
This commit is contained in:
parent
17361b092a
commit
f7d3ec9a2e
2 changed files with 21 additions and 24 deletions
|
@ -8,16 +8,17 @@ interface DocumentWithSlug {
|
||||||
doc: Document
|
doc: Document
|
||||||
}
|
}
|
||||||
|
|
||||||
const findDocumentsByAuthor = (
|
const findDocumentsByAuthor = (authorId: string): DocumentWithSlug[] => {
|
||||||
authorId: string
|
|
||||||
): DocumentWithSlug[] => {
|
|
||||||
// Filter documents by author
|
// Filter documents by author
|
||||||
return Object.entries(documents)
|
return Object.entries(documents)
|
||||||
.filter(([_, doc]) => doc.manifest.authors.includes(authorId))
|
.filter(([_, doc]) => doc.manifest.authors.includes(authorId))
|
||||||
.map(([slug, doc]) => ({ slug, doc }))
|
.map(([slug, doc]) => ({ slug, doc }))
|
||||||
}
|
}
|
||||||
|
|
||||||
const checkAffiliation = (affiliationStr: string[], affiliationShort: string) => {
|
const checkAffiliation = (
|
||||||
|
affiliationStr: string[],
|
||||||
|
affiliationShort: string
|
||||||
|
) => {
|
||||||
for (const affiliation of affiliationStr) {
|
for (const affiliation of affiliationStr) {
|
||||||
if (affiliation.split('@')[1] === affiliationShort) {
|
if (affiliation.split('@')[1] === affiliationShort) {
|
||||||
return true
|
return true
|
||||||
|
@ -33,11 +34,9 @@ export default function findDocumentsByAffiliationSorted(
|
||||||
const results: DocumentWithSlug[] = []
|
const results: DocumentWithSlug[] = []
|
||||||
for (const [key, value] of Object.entries(authors)) {
|
for (const [key, value] of Object.entries(authors)) {
|
||||||
if (
|
if (
|
||||||
checkAffiliation(value.affiliation, affiliationShort)
|
checkAffiliation(value.affiliation, affiliationShort) ||
|
||||||
|| (
|
(value.formerAffiliations &&
|
||||||
value.formerAffiliations
|
checkAffiliation(value.formerAffiliations, affiliationShort))
|
||||||
&& checkAffiliation(value.formerAffiliations, affiliationShort)
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
// Check if document is already in results
|
// Check if document is already in results
|
||||||
const additions = findDocumentsByAuthor(key)
|
const additions = findDocumentsByAuthor(key)
|
||||||
|
|
|
@ -28,9 +28,7 @@ export default function Page({
|
||||||
<>
|
<>
|
||||||
{description.split('[linebreak]').map((d, i) => (
|
{description.split('[linebreak]').map((d, i) => (
|
||||||
<>
|
<>
|
||||||
<div className='text-lg sm:text-md font-serif'>
|
<div className='text-lg sm:text-md font-serif'>{d}</div>
|
||||||
{d}
|
|
||||||
</div>
|
|
||||||
<br className='m-1' />
|
<br className='m-1' />
|
||||||
</>
|
</>
|
||||||
))}
|
))}
|
||||||
|
@ -62,18 +60,18 @@ export default function Page({
|
||||||
<Description />
|
<Description />
|
||||||
</div>
|
</div>
|
||||||
{affiliationDocuments.length > 0 && (
|
{affiliationDocuments.length > 0 && (
|
||||||
<>
|
<>
|
||||||
<hr className='mx-auto w-full h-1 border-0 bg-slate-200 my-2 rounded-md mt-8' />
|
<hr className='mx-auto w-full h-1 border-0 bg-slate-200 my-2 rounded-md mt-8' />
|
||||||
<h1 className='text-3xl md:my-6 my-4 font-serif'>
|
<h1 className='text-3xl md:my-6 my-4 font-serif'>
|
||||||
Related documents {`(${affiliationDocuments.length})`}
|
Related documents {`(${affiliationDocuments.length})`}
|
||||||
</h1>
|
</h1>
|
||||||
{affiliationDocuments.map((d) => (
|
{affiliationDocuments.map((d) => (
|
||||||
<Fragment key={d.slug}>
|
<Fragment key={d.slug}>
|
||||||
<DocumentCard doc={d.doc} href={`/document/view/${d.slug}`} />
|
<DocumentCard doc={d.doc} href={`/document/view/${d.slug}`} />
|
||||||
</Fragment>
|
</Fragment>
|
||||||
))}
|
))}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue