0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 18:32:41 +00:00

Convert storage of snippets in Brew to yaml by request.

This commit is contained in:
David Bolack
2024-11-24 18:13:32 -06:00
parent c5935ec262
commit b6e445c445
2 changed files with 52 additions and 28 deletions

View File

@@ -8,9 +8,11 @@ import Markdown from '../shared/naturalcrit/markdown.js';
import yaml from 'js-yaml';
import asyncHandler from 'express-async-handler';
import { nanoid } from 'nanoid';
import { splitTextStyleAndMetadata } from '../shared/helpers.js';
import { splitTextStyleAndMetadata,
brewSnippetsToJSON } from '../shared/helpers.js';
import checkClientVersion from './middleware/check-client-version.js';
const router = express.Router();
import { DEFAULT_BREW, DEFAULT_BREW_LOAD } from './brewDefaults.js';
@@ -176,15 +178,15 @@ const api = {
mergeBrewText : (brew)=>{
let text = brew.text;
if(brew.style !== undefined) {
text = `\`\`\`css\n` +
`${brew.style || ''}\n` +
if(brew.snippets !== undefined) {
text = `\`\`\`snippets\n` +
`${yaml.dump(brewSnippetsToJSON('brew_snippets', brew.snippets, null, false))}` +
`\`\`\`\n\n` +
`${text}`;
}
if(brew.snippets !== undefined) {
text = `\`\`\`snippets\n` +
`${brew.snippets || ''}\n` +
if(brew.style !== undefined) {
text = `\`\`\`css\n` +
`${brew.style || ''}\n` +
`\`\`\`\n\n` +
`${text}`;
}