mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-15 04:02:38 +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:
@@ -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
|
||||||
|
|||||||
@@ -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)=>{
|
||||||
|
|||||||
Reference in New Issue
Block a user