diff options
| author | Mhykol <mchaeldonald62@pm.me> | 2024-07-18 02:18:58 -0400 |
|---|---|---|
| committer | Mhykol <mchaeldonald62@pm.me> | 2024-07-18 02:18:58 -0400 |
| commit | b2fbe215bcbd7d6fe82204fb30dc5b49420e4597 (patch) | |
| tree | 7a9b706ed570756684a747ff35a78911c4fe7a35 | |
| parent | 145e3e149a919a48856747bd0ca235805e4ec978 (diff) | |
Fixed meta tags for non async functions
| -rw-r--r-- | app.js | 6 | ||||
| -rw-r--r-- | source/readfile.js | 42 |
2 files changed, 15 insertions, 33 deletions
@@ -89,11 +89,9 @@ class App { if (this.path.string.endsWith('/') && this.path.string.length > 1) this.path.string = this.path.string.substring(0, this.path.string.length - 1) if (output.has(this.path.string)) { try { - output.get(this.path.string).then(output => { - res.send(this.readfile.GetMain(output.meta)) - }) + output.get(this.path.string).then(output => res.send(this.readfile.GetMain(output.meta))) } catch { - res.send(this.readfile.GetMain(output.get(this.path.string))) + res.send(this.readfile.GetMain(output.get(this.path.string).meta)) } } else { res.sendStatus(404) diff --git a/source/readfile.js b/source/readfile.js index f93add4..9310b8c 100644 --- a/source/readfile.js +++ b/source/readfile.js @@ -32,46 +32,30 @@ class ReadFile { GetMain(x) { const data = { - header: '', - footer: ` - </section> - <script src='/js/purify.js'></script> - <script src='/js/loading.js'></script> - <script src='/js/main.js'></script> - </body> - </html> - ` - } - try { - data.header = ` + header: ` <!DOCTYPE html> <html lang='en'> <head> - <title>${x.title}</title> - <meta name='description' content='${x.description}'> - <meta name='keywords' content='${x.keywords}'> - <meta name='viewport' content='width=device-width, initial-scale=1'> - <link rel='stylesheet' type='text/css' href='/css/loading.css'> - </head> - <body> - ${this.object.layouts.loading} - <section id='main'> - ` - } catch { - data.header = ` - <html> - <head> - <title>Undefined</title> - <meta name='description' content=''> - <meta name='keywords' content=''> + <title>${x.hasOwnProperty('title') ? x.title : 'Undefined'}</title> + <meta name='description' content='${x.hasOwnProperty('description') ? x.description : 'Undefined'}'> + <meta name='keywords' content='${x.hasOwnProperty('keywords') ? x.keywords : 'Undefined'}'> <meta name='viewport' content='width=device-width, initial-scale=1'> <link rel='stylesheet' type='text/css' href='/css/loading.css'> </head> <body> ${this.object.layouts.loading} <section id='main'> + `, + footer: ` + </section> + <script src='/js/purify.js'></script> + <script src='/js/loading.js'></script> + <script src='/js/main.js'></script> + </body> + </html> ` } + return this.#RemoveSpaces(data.header + data.footer) } async Create(x) { |
