@@ -13,6 +13,7 @@ import {
1313 loadProject ,
1414 parseMyst ,
1515 processProject ,
16+ resolveFrontmatterParts ,
1617 selectors ,
1718} from 'myst-cli' ;
1819import type { ISession } from 'myst-cli' ;
@@ -85,7 +86,9 @@ export async function depositArticleFromSource(session: ISession, depositSource:
8586 } else {
8687 fileContents . forEach ( ( { mdast } ) => {
8788 if ( abstractPart ) return ;
88- abstractPart = extractPart ( mdast , 'abstract' ) ;
89+ abstractPart = extractPart ( mdast , 'abstract' , {
90+ frontmatterParts : resolveFrontmatterParts ( session , projectFrontmatter ) ,
91+ } ) ;
8992 } ) ;
9093 }
9194 fileContents . forEach ( ( { references } ) => {
@@ -108,7 +111,9 @@ export async function depositArticleFromSource(session: ISession, depositSource:
108111 ? projectFrontmatter ?. subtitle ?? undefined
109112 : frontmatter ?. subtitle ;
110113 frontmatter = { ...fileContent . frontmatter , title, subtitle } ;
111- abstractPart = extractPart ( fileContent . mdast , 'abstract' ) ;
114+ abstractPart = extractPart ( fileContent . mdast , 'abstract' , {
115+ frontmatterParts : resolveFrontmatterParts ( session , frontmatter ) ,
116+ } ) ;
112117 fileContent . references . cite ?. order . forEach ( ( key ) => {
113118 const value = fileContent . references . cite ?. data [ key ] . doi ;
114119 if ( value ) dois [ key ] = value ;
@@ -117,6 +122,7 @@ export async function depositArticleFromSource(session: ISession, depositSource:
117122 }
118123
119124 let abstract : Element | undefined ;
125+ const description = ( frontmatter ?. description || projectFrontmatter ?. description ) ?. trim ( ) ;
120126 if ( abstractPart ) {
121127 transformXrefToLink ( abstractPart ) ;
122128 transformCiteToText ( abstractPart ) ;
@@ -128,6 +134,20 @@ export async function depositArticleFromSource(session: ISession, depositSource:
128134 { name : 'jats:abstract' } ,
129135 jats . map ( ( e ) => element2JatsUnist ( e ) ) ,
130136 ) as Element ;
137+ } else if ( description ) {
138+ // Use the project description as the fallback for the abstract
139+ abstractPart = {
140+ type : 'root' ,
141+ children : [ { type : 'paragraph' , children : [ { type : 'text' , value : description } ] } ] ,
142+ } ;
143+ transformNewlineToSpace ( abstractPart ) ;
144+ const serializer = new JatsSerializer ( new VFile ( ) , abstractPart as any ) ;
145+ const jats = serializer . render ( true ) . elements ( ) ;
146+ abstract = u (
147+ 'element' ,
148+ { name : 'jats:abstract' } ,
149+ jats . map ( ( e ) => element2JatsUnist ( e ) ) ,
150+ ) as Element ;
131151 }
132152 return { frontmatter : frontmatter ?? { } , dois, abstract, configFile } ;
133153}
@@ -612,7 +632,7 @@ export async function deposit(session: ISession, opts: DepositOptions) {
612632 throw new Error ( 'preprint deposit may only use a single article' ) ;
613633 }
614634 const { frontmatter, dois, abstract } = depositArticles [ 0 ] ;
615- body = preprintFromMyst ( frontmatter , dois , abstract ) ;
635+ body = preprintFromMyst ( session , frontmatter , dois , abstract ) ;
616636 }
617637 const batch = new DoiBatch (
618638 { id : opts . id ?? uuid ( ) , depositor : { name, email } , registrant } ,
0 commit comments