diff --git a/server.js b/server.js index 0c42116..2de7c65 100644 --- a/server.js +++ b/server.js @@ -83,29 +83,28 @@ app.get('/:id', (req, res) => { fileStorage.get(key, (data) => { if (data) { // Paste found, render it with dynamic SEO tags - const title = `Paste ${key} - unknownBIN`; - const description = data.substring(0, 160).replace(/\n/g, ' '); res.render('index', { - paste: { - key: key, - data: data, - title: title, - description: description - } + title: `Paste ${key} - unknownBIN`, + description: data.substring(0, 160).replace(/\n/g, ' ').trim(), + content: data }); } else { - // Paste not found, render the homepage - res.render('index', { - paste: null + // Paste not found, render the homepage with 404 status + res.status(404).render('index', { + title: '404 Not Found - unknownBIN', + description: 'The paste you were looking for could not be found.', + content: null }); } }); }); app.get('/', (req, res) => { - // Render the homepage + // Render the homepage with static SEO tags res.render('index', { - paste: null + title: 'unknownBIN - A Secure & Modern Pastebin', + description: 'unknownBIN is a secure and modern open-source Pastebin software written in Node.js. Easily share code, logs, and text snippets.', + content: null }); }); diff --git a/views/index.ejs b/views/index.ejs index fa42e19..5de6d19 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -2,17 +2,10 @@ - <% if (paste) { %> - <%= paste.title %> - - - - <% } else { %> - unknownBIN - A Secure Pastebin - - - - <% } %> + <%= title %> + + + @@ -29,7 +22,7 @@
Raw
- +