File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ interface FrontMatter {
2626 title ?: string ;
2727 date ?: string ;
2828 collections ?: string [ ] ;
29+ description ?: string ;
2930 } ;
3031 body : string ;
3132}
@@ -95,11 +96,19 @@ interface FrontMatter {
9596
9697 const mdPath = path . join ( contentDir , `${ piece . slug } .md` ) ;
9798 let content = '' ;
99+ let description = '' ;
98100
99101 if ( fs . existsSync ( mdPath ) ) {
100102 const mdFile = fs . readFileSync ( mdPath , 'utf-8' ) ;
101103 const parsed = fm < FrontMatter [ 'attributes' ] > ( mdFile ) ;
102104 content = await marked . parse ( parsed . body . trim ( ) ) ;
105+
106+ if ( parsed . attributes . description ) {
107+ description = parsed . attributes . description ;
108+ } else {
109+ const firstLine = parsed . body . trim ( ) . split ( '\n' ) [ 0 ] ;
110+ description = `A piece from ${ siteTitle } | ${ firstLine } ` ;
111+ }
103112 }
104113
105114 rssLines . push ( ' <item>' ) ;
@@ -120,6 +129,10 @@ interface FrontMatter {
120129 rssLines . push ( ` <guid isPermaLink="true">${ pieceUrl } </guid>` ) ;
121130 rssLines . push ( '' ) ;
122131
132+ if ( description ) {
133+ rssLines . push ( ` <description><![CDATA[${ description } ]]></description>` ) ;
134+ }
135+
123136 if ( content ) {
124137 rssLines . push ( ` <content:encoded><![CDATA[${ content } ]]></content:encoded>` ) ;
125138 }
You can’t perform that action at this time.
0 commit comments