This repository was archived by the owner on Mar 3, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -89,6 +89,22 @@ export function formatShortDescription(markdown: string): string {
8989 ) ;
9090}
9191
92+ export function formatShortDescriptionForAtom(markdown: string): string {
93+ const replaced = markdown
94+ . replace ( / + / g, '' )
95+ . replace ( / - - / g, '' )
96+ . replace ( / \| / g, '' )
97+ . replace ( / \n / g, ' ' )
98+ . replace ( / ` ` ` ( .* ) ` ` ` / g, '' )
99+ . replace ( / [ < > ] / g, '' ) ;
100+
101+ return (
102+ removeMd ( replaced . slice ( 0 , 700 ) )
103+ . slice ( 0 , 700 )
104+ . replace ( / # / g, '' ) + ( replaced . length > 500 ? '...' : '' )
105+ ) ;
106+ }
107+
92108export function generalHash(text: string) {
93109 const hashKey = process . env . HASH_KEY ;
94110 if ( ! hashKey ) return null ;
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import User from 'database/models/User';
44import UserProfile from 'database/models/UserProfile' ;
55
66import { Feed } from 'feed' ;
7- import { formatShortDescription } from 'lib/common' ;
7+ import { formatShortDescriptionForAtom } from 'lib/common' ;
88
99import type { Middleware } from 'koa' ;
1010
@@ -14,7 +14,7 @@ const convertToFeed = (post) => {
1414 return {
1515 link,
1616 title : post . title ,
17- description : post . short_description || formatShortDescription ( post . body ) ,
17+ description : formatShortDescriptionForAtom ( post . body ) ,
1818 id : link ,
1919 image : post . thumbnail ,
2020 date : post . released_at ,
You can’t perform that action at this time.
0 commit comments