@@ -46,6 +46,7 @@ const useCitationStyle = () => {
4646
4747 const getCitation = ( paper ) => {
4848 // format derived from the example JSON: https://citation.js.org/demo/
49+ // full list of parameters: node_modules/@citation -js/core/lib/plugins/input/csl.js
4950 const cite = new Cite ( {
5051 id : paper . safe_id ,
5152 title : paper . title ,
@@ -56,8 +57,9 @@ const useCitationStyle = () => {
5657 issued : [ { "date-parts" : paper . year . split ( "-" ) } ] ,
5758 "container-title" : paper . published_in ,
5859 DOI : paper . list_link . isDoi ? paper . list_link . address : undefined ,
59- url : paper . list_link . isDoi ? undefined : paper . list_link . address ,
60- // other possible attributes: "type", "volume", "issue", "page", ???
60+ URL : paper . list_link . isDoi ? undefined : paper . list_link . address ,
61+ source : "Open Knowledge Maps" ,
62+ type : getType ( paper ) ,
6163 } ) ;
6264
6365 return cite . format ( "bibliography" , {
@@ -69,3 +71,41 @@ const useCitationStyle = () => {
6971} ;
7072
7173export default useCitationStyle ;
74+
75+ // mapping of BASE type to CSL type
76+ const TYPE_TO_TYPE = [
77+ [ "Journal/newspaper article" , "article-journal" ] ,
78+ [ "Journal/newspaper other content" , "article-journal" ] ,
79+ [ "Journal/newspaper" , "periodical" ] ,
80+ [ "Book" , "book" ] ,
81+ [ "Book part" , "chapter" ] ,
82+ [ "Conference object" , "paper-conference" ] ,
83+ [ "Dataset" , "dataset" ] ,
84+ [ "Manuscript" , "manuscript" ] ,
85+ [ "Map" , "map" ] ,
86+ [ "Moving image/video" , "motion_picture" ] ,
87+ [ "Patent" , "patent" ] ,
88+ [ "Report" , "report" ] ,
89+ [ "Review" , "review" ] ,
90+ [ "Software" , "software" ] ,
91+ [ "Still image" , "graphic" ] ,
92+ [ "Thesis" , "thesis" ] ,
93+ [ "Thesis: bachelor" , "thesis" ] ,
94+ [ "Thesis: doctoral and postdoctoral" , "thesis" ] ,
95+ [ "Thesis: master" , "thesis" ] ,
96+ ] ;
97+
98+ const getType = ( paper ) => {
99+ const types = paper . resulttype ;
100+ if ( ! types || types . length === 0 ) {
101+ return undefined ;
102+ }
103+
104+ for ( const entry of TYPE_TO_TYPE ) {
105+ if ( types . includes ( entry [ 0 ] ) ) {
106+ return entry [ 1 ] ;
107+ }
108+ }
109+
110+ return undefined ;
111+ } ;
0 commit comments