diff options
| author | Mhykol <mchaeldonald62@pm.me> | 2026-08-28 15:33:28 -0400 |
|---|---|---|
| committer | Mhykol <mchaeldonald62@pm.me> | 2026-08-28 15:33:28 -0400 |
| commit | 00c44e81c6f8e0ff9cff259ef96f945760db5e1c (patch) | |
| tree | 7873c8ec4725463ebb10dc745a9c3dfa19d168e9 /src | |
| parent | b632faab8f7e50d65aa6cc7dc4798d7cf3a18a5a (diff) | |
Update buildpages.js
Diffstat (limited to 'src')
| -rw-r--r-- | src/buildpages.js | 61 |
1 files changed, 43 insertions, 18 deletions
diff --git a/src/buildpages.js b/src/buildpages.js index 89409ec..082ca6c 100644 --- a/src/buildpages.js +++ b/src/buildpages.js @@ -2,18 +2,19 @@ const fs = require('fs') const path = require('path') const logger = require('./logger')() const template = require('../template/template') +const routesConfig = require('../config/routes') class BuildPages { constructor(x) { this.newTemplate = new Map() this.template = template({baseURL: x.baseURL}) - this.pages = this.#GetAllPages() + this.pages = typeof this.GetAllPages() !== 'undefined' ? this.GetAllPages() : new Map() this.path = [] this.pages.forEach((value, key) => { this.path.push(key) }) - this.routes = x.routes + this.routes = typeof x.routes !== 'undefined' ? x.routes : new Map() this.#AddTemplate({ name: 'start', @@ -36,15 +37,18 @@ class BuildPages { GetSitemap() {return this.path} Build(pageData) { - if (this.routes.has(pageData.path)) { - } else if (this.pages.has(pageData.path)) { - const pages = this.pages.get(pageData.path) - const data = pages({ - req: '', - res: '', - next: '', - baseURL: pageData.baseURL - }) + const split = pageData.path.split('/') + const string = `/${split[1]}` + + if (false) { + } else if (this.pages.has(string)) { + if (split[2] !== undefined && split[2] !== '') { + const newPath = `/${split[1]}/${split[2]}` + + + } else { + const pages = this.pages.get(string) + const data = pages (pageData) this.map = new Map() for (let i = 0; i < data.page.length; i++) { @@ -75,10 +79,10 @@ class BuildPages { return this.output } } + } } else { // ! 404 Not Found const notFound = this.template.NotFound() - //const css = notFound.css this.output = { html: { @@ -87,7 +91,8 @@ class BuildPages { footer: this.template.Footer() }, css: [], - js: ['loading.js'] + js: ['loading.js'], + pages: this.pages } notFound.css.forEach(file => this.output.css.push(file)) @@ -99,6 +104,16 @@ class BuildPages { } Template(pageData) { + const split = pageData.path.split('/') + const string = `/${split[1]}` + + if (this.routes.has(pageData.path)) { + } else if (this.pages.has(string)) { + if (split[2] !== undefined && split[2] !== '') { + + } + } + const html = { start: ` <!DOCTYPE html> @@ -146,12 +161,15 @@ class BuildPages { return this.#RemoveSpaces(fullHTML) } - - #AddTemplate() { - this.newTemplate.set() + FixRoutes() { + this.pages = typeof this.GetAllPages() !== 'undefined' ? this.GetAllPages() : new Map() + this.routes = typeof x.routes !== 'undefined' ? x.routes : new Map() } + IsAsync (fn) {fn.constructor.name === 'AsyncFunction'} + #AddTemplate() {this.newTemplate.set()} #RemoveSpaces(html) {return html.replace(/(\n)\s+/g, '$1')} - #GetAllPages() { + GetRoutes() {} + GetAllPages() { const object = { modulesDir: path.resolve(`${__dirname}/../pages`), map: new Map() @@ -174,5 +192,12 @@ class BuildPages { } } -module.exports = (x) => {return new BuildPages(x)} +module.exports = (x) => { + const build = new BuildPages(x) + const routes = build.GetAllPages() + return { + build: build, + routes: routes + } +} |
