Skip to content

Commit

Permalink
Merge pull request #185 from MiyashitaLab/fix/layout_citation
Browse files Browse the repository at this point in the history
引用文に著者を追加
  • Loading branch information
HoorayTritium authored Sep 28, 2023
2 parents bf90dfe + 2a6cd7e commit 71daad2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/page/researchDetail/ResearchDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const ResearchDetail: FC<PaperModel> = ({
<AuthorTag
key={author.fullName}
name={author.fullName}
thumbnail={MemberDefaultImg} //TODO 仮
thumbnail={MemberDefaultImg} //TODO:
href={ROUTES.RESEARCH_AUTHOR_FILTERED(author.fullName)}
/>
))}
Expand Down
17 changes: 16 additions & 1 deletion src/models/transformer/transformPaper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,23 @@ const ipsjQuotation = (
publicationDate,
lastPage,
firstPage,
language
} = paper.fields;

const authors = paper.fields.author.map((e) => {
if (language === 'japanese') {
return e?.fields.fullName
} else if (language === 'english') {
return e?.fields.givenNameEn + ' ' + e?.fields.familyNameEn
}
})
const authorsStr = authors.reduce((accumulator, currentValue, currentIndex) => {
if (currentIndex === authors.length - 1 && language === 'english') {
const separater = authors.length > 2 ? ', and ' : ' and '
return accumulator + separater + currentValue
} else return accumulator + ', ' + currentValue
})

const pages = () => {
if (!firstPage || !lastPage) return undefined;
if (firstPage === lastPage) return `p.${firstPage}`;
Expand All @@ -186,7 +201,7 @@ const ipsjQuotation = (
const vol = volume ? `Vol.${volume}` : undefined;
const no = issue ? `No.${issue}` : undefined;

return [title, journalTitle, vol, no, pages(), year]
return authorsStr + ': ' + [title, journalTitle, vol, no, pages(), year]
.filter((item) => !!item)
.join(", ");
};
Expand Down

0 comments on commit 71daad2

Please sign in to comment.