0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-06 07:52:40 +00:00

add 'lang' as a brew metadata property

This commit is contained in:
Gazook89
2022-09-21 12:21:32 -05:00
parent 8c6fd3086c
commit bce7cf41af
4 changed files with 6 additions and 2 deletions

View File

@@ -21,7 +21,7 @@ const splitTextStyleAndMetadata = (brew)=>{
const index = brew.text.indexOf('```\n\n'); const index = brew.text.indexOf('```\n\n');
const metadataSection = brew.text.slice(12, index - 1); const metadataSection = brew.text.slice(12, index - 1);
const metadata = yaml.load(metadataSection); const metadata = yaml.load(metadataSection);
Object.assign(brew, _.pick(metadata, ['title', 'description', 'tags', 'systems', 'renderer', 'theme'])); Object.assign(brew, _.pick(metadata, ['title', 'description', 'tags', 'systems', 'renderer', 'theme', 'lang']));
brew.text = brew.text.slice(index + 5); brew.text = brew.text.slice(index + 5);
} }
if(brew.text.startsWith('```css')) { if(brew.text.startsWith('```css')) {
@@ -173,6 +173,7 @@ app.get('/user/:username', async (req, res, next)=>{
'pageCount', 'pageCount',
'description', 'description',
'authors', 'authors',
'lang',
'published', 'published',
'views', 'views',
'shareId', 'shareId',

View File

@@ -126,6 +126,7 @@ const GoogleActions = {
views : parseInt(file.properties.views), views : parseInt(file.properties.views),
published : file.properties.published ? file.properties.published == 'true' : false, published : file.properties.published ? file.properties.published == 'true' : false,
systems : [], systems : [],
lang : file.properties.lang,
thumbnail : file.properties.thumbnail thumbnail : file.properties.thumbnail
}; };
}); });
@@ -255,6 +256,7 @@ const GoogleActions = {
tags : obj.data.properties.tags ? obj.data.properties.tags : '', tags : obj.data.properties.tags ? obj.data.properties.tags : '',
systems : obj.data.properties.systems ? obj.data.properties.systems.split(',') : [], systems : obj.data.properties.systems ? obj.data.properties.systems.split(',') : [],
authors : [], authors : [],
lang : obj.data.properties.lang,
published : obj.data.properties.published ? obj.data.properties.published == 'true' : false, published : obj.data.properties.published ? obj.data.properties.published == 'true' : false,
trashed : obj.data.trashed, trashed : obj.data.trashed,

View File

@@ -80,7 +80,7 @@ const mergeBrewText = (brew)=>{
`\`\`\`\n\n` + `\`\`\`\n\n` +
`${text}`; `${text}`;
} }
const metadata = _.pick(brew, ['title', 'description', 'tags', 'systems', 'renderer', 'theme']); const metadata = _.pick(brew, ['title', 'description', 'tags', 'systems', 'renderer', 'theme', 'lang']);
text = `\`\`\`metadata\n` + text = `\`\`\`metadata\n` +
`${yaml.dump(metadata)}\n` + `${yaml.dump(metadata)}\n` +
`\`\`\`\n\n` + `\`\`\`\n\n` +

View File

@@ -15,6 +15,7 @@ const HomebrewSchema = mongoose.Schema({
description : { type: String, default: '' }, description : { type: String, default: '' },
tags : [String], tags : [String],
systems : [String], systems : [String],
lang : { type: String, default: 'en' },
renderer : { type: String, default: '' }, renderer : { type: String, default: '' },
authors : [String], authors : [String],
published : { type: Boolean, default: false }, published : { type: Boolean, default: false },