mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-05 21:02:43 +00:00
Reduced code change to one addition on a single line.
This commit is contained in:
@@ -15,10 +15,7 @@ const MAX_TITLE_LENGTH = 100;
|
|||||||
|
|
||||||
const getGoodBrewTitle = (text)=>{
|
const getGoodBrewTitle = (text)=>{
|
||||||
const tokens = Markdown.marked.lexer(text);
|
const tokens = Markdown.marked.lexer(text);
|
||||||
let title = (tokens.find((token)=>token.type == 'heading' || token.type == 'paragraph') || { text: 'No Title' }).text;
|
const title = (tokens.find((token)=>token.type == 'heading' || token.type == 'paragraph') || { text: 'No Title' }).text.substr(0,MAX_TITLE_LENGTH);
|
||||||
if(title.length > MAX_TITLE_LENGTH) {
|
|
||||||
title = title.substr(0, MAX_TITLE_LENGTH);
|
|
||||||
}
|
|
||||||
return title;
|
return title;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user