0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-14 23:42:41 +00:00

Fix title issue (#1251)

* Maximum title length set to 100 characters.

* Reverse unnecessary change that was incorrectly included in previous commit.

* Reduced code change to one addition on a single line.

* Revert "Reduced code change to one addition on a single line."

This reverts commit 2a355cf115.

* Use newer syntax to shorten

Co-authored-by: Trevor Buckner <calculuschild@gmail.com>
This commit is contained in:
G.Ambatte
2021-02-27 11:47:29 +13:00
committed by GitHub
parent 1e64e49dc3
commit 481c9f067c
2 changed files with 5 additions and 2 deletions

View File

@@ -1,7 +1,7 @@
module.exports = { module.exports = {
root : true, root : true,
parserOptions : { parserOptions : {
ecmaVersion : 9, ecmaVersion : 2021,
sourceType : 'module', sourceType : 'module',
ecmaFeatures : { ecmaFeatures : {
jsx : true jsx : true

View File

@@ -11,9 +11,12 @@ const Markdown = require('../shared/naturalcrit/markdown.js');
// }); // });
// }; // };
const MAX_TITLE_LENGTH = 100;
const getGoodBrewTitle = (text)=>{ const getGoodBrewTitle = (text)=>{
const tokens = Markdown.marked.lexer(text); const tokens = Markdown.marked.lexer(text);
return title = (tokens.find((token)=>token.type == 'heading' || token.type == 'paragraph') || { text: 'No Title' }).text; return (tokens.find((token)=>token.type == 'heading' || token.type == 'paragraph')?.text || 'No Title')
.slice(0, MAX_TITLE_LENGTH);
}; };
const newBrew = (req, res)=>{ const newBrew = (req, res)=>{