diff --git a/pug-sync.js b/pug-sync.js index dd18999..1c28119 100644 --- a/pug-sync.js +++ b/pug-sync.js @@ -70,9 +70,7 @@ function render(event, filename, locals) { pugCache.set(path, async (event, locals) => { const localAnd = params => and(event, params) // automatically generate locals required by included templates - console.log([...beforeIncludes.keys()]) for (const dep of dependencies) { - console.log(dep) const fn = beforeIncludes.get(dep) if (fn) Object.assign(locals, await fn(path, event, locals)) } diff --git a/routes/app.js b/routes/app.js index 2c32ff8..cb04152 100644 --- a/routes/app.js +++ b/routes/app.js @@ -3,6 +3,8 @@ const {z} = require("zod") const {defineEventHandler, getQuery, getValidatedQuery, sendRedirect, createError, getValidatedRouterParams, getCookie} = require("h3") const {router, db, sync, select, from} = require("../passthrough") + +/** @type {import("../pug-sync")} */ const pugSync = sync.require("../pug-sync") /** @type {import("./load-tags")} */ @@ -146,12 +148,16 @@ router.get("/:account/", defineEventHandler({ loadPreviews(locals, "band_name", 4, whereClause, account, filter_field, filter, filter_fuzzy) } else if (mode === "label_grid") { loadPreviews(locals, "band_url", 6, whereClause, account, filter_field, filter, filter_fuzzy) - } else if (arrange === "tag") { - locals.downloadManager = loadTags.downloadManager - locals.downloader = loadTags.downloadManager.check(account) } // if there are any untagged items then we don't have full track data locals.hasFullTrackData = !db.prepare("SELECT * FROM item LEFT JOIN item_tag USING (account, item_id) WHERE account = ? AND item_id = NULL").get(account) return pugSync.render(event, `${arrange}_${shape}.pug`, locals) } })) + +pugSync.beforeInclude("tag_grid.pug", async (from, event, {account}) => { + return { + downloadManager: loadTags.downloadManager, + downloader: loadTags.downloadManager.check(account) + } +})