From 4638c3e1d9a6eb94f769f297c5f05a48b9770d4f Mon Sep 17 00:00:00 2001 From: Sean Robertson Date: Fri, 18 Jun 2021 11:24:20 +1200 Subject: [PATCH] Update server.js Initial commit of incorporating `brew.style` into /source and /download pages --- server.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/server.js b/server.js index 1d93e5401..2258dc074 100644 --- a/server.js +++ b/server.js @@ -113,7 +113,7 @@ app.get('/source/:id', asyncHandler(async (req, res)=>{ const brew = await getBrewFromId(req.params.id, 'share'); const replaceStrings = { '&': '&', '<': '<', '>': '>' }; - let text = brew.text; + let text = `\`\`\`css\n${brew.style}\n\`\`\`\n\n${brew.text}`; for (const replaceStr in replaceStrings) { text = text.replaceAll(replaceStr, replaceStrings[replaceStr]); } @@ -132,8 +132,9 @@ app.get('/download/:id', asyncHandler(async (req, res)=>{ 'Cache-Control' : 'no-cache', 'Content-Type' : 'text/plain', 'Content-Disposition' : `attachment; filename="${fileName}.txt"` - }); - res.status(200).send(brew.text); + }); + let text = `\`\`\`css\n${brew.style}\n\`\`\`\n\n${brew.text}`; + res.status(200).send(text); })); //User Page