diff --git a/api/apps/haxcms/views.js b/api/apps/haxcms/views.js index 22d2559986..f1998ef63b 100644 --- a/api/apps/haxcms/views.js +++ b/api/apps/haxcms/views.js @@ -5,7 +5,6 @@ import { parse } from 'node-html-parser'; // vercel to slice our data into views that we can remix at will export default async function handler(req, res) { let siteManifest = {}; - let items = []; // use this if POST data is what's being sent let body = {}; if (req.query.site) { @@ -49,96 +48,121 @@ export default async function handler(req, res) { siteData = null; } siteManifest = await resolveSiteData(base, siteData); - items = siteManifest.orderTree(siteManifest.items); - if (body.tag) { - items = items.filter((item) => { - if (item.metadata && item.metadata.tags && item.metadata.tags.includes(body.tag)) { + siteManifest.items = siteManifest.orderTree(siteManifest.items); + // filter by criteria matching one at a time as this is a intersection, not union query + if (body.tags) { + siteManifest.items = siteManifest.items.filter((item) => { + if (item.metadata && item.metadata.tags && item.metadata.tags.includes(body.tags)) { + return true; + } + return false; + }); + } + if (body.parent) { + siteManifest.items = siteManifest.items.filter((item) => { + if (item.parent === body.parent) { + return true; + } + return false; + }); + } + if (body.title) { + siteManifest.items = siteManifest.items.filter((item) => { + if (item.title.toLowerCase().indexOf(body.title.toLowerCase()) >= 0) { return true; } return false; }); - siteManifest.items = items; } // special support for media as we now need to take the items and load the content - if (body.display === "media") { - for (var i in items) { - let content = await siteManifest.getContentById(items[i].id, true); - siteManifest.items[i].media = {}; - let doc = parse(`
Try changing the filter criteria.
` : nothing} +${this.params.display === "list" ? this.listTemplate() : nothing} +${this.params.display === "table" ? this.tableTemplate() : nothing} +${this.params.display === "card" ? this.cardTemplate() : nothing} +${this.params.display === "contentplayer" ? this.contentplayerTemplate() : nothing} +Icon | +Type | +Title | +Tags | +Updated | +Created | +Status | +
---|---|---|---|---|---|---|
${item.metadata.pageType ? html` |
+ ${item.metadata.pageType ? item.metadata.pageType : nothing} | +${item.title} | +
+ ${item.metadata.tags && item.metadata.tags != "" ? item.metadata.tags
+ .split(",")
+ .map(
+ (tag) => html`
+ |
+
+ |
+
+ |
+ + ${item.metadata.published !== false ? `published` : `unpublished`} + | +
Icon | -Type | -Title | -Tags | -Updated | -Created | -Status | -
---|---|---|---|---|---|---|
${item.metadata.pageType ? html` |
- ${item.metadata.pageType ? item.metadata.pageType : nothing} | -${item.title} | -
- ${item.metadata.tags && item.metadata.tags != "" ? item.metadata.tags
- .split(",")
- .map(
- (tag) => html`
- |
-
- |
-
- |
- - ${item.metadata.published !== false ? `published` : `unpublished`} - | -