@base-cms/canonical-path
Advanced tools
Comparing version 1.0.0-beta.5 to 1.0.0-beta.7
{ | ||
"name": "@base-cms/canonical-path", | ||
"version": "1.0.0-beta.5", | ||
"version": "1.0.0-beta.7", | ||
"description": "Canonical path library for BaseCMS projects.", | ||
@@ -14,3 +14,3 @@ "main": "src/index.js", | ||
"dependencies": { | ||
"@base-cms/db": "^1.0.0-beta.5", | ||
"@base-cms/db": "^1.0.0-beta.7", | ||
"@base-cms/inflector": "^1.0.0-beta.1", | ||
@@ -27,3 +27,3 @@ "@base-cms/object-path": "^1.0.0-beta.4", | ||
}, | ||
"gitHead": "bfe40af02b077c4d143195ca9e4d6c319f9ee4db" | ||
"gitHead": "53471127f4132cb4d86ba3604efab9e23ab9a30e" | ||
} |
@@ -25,2 +25,12 @@ const { isFunction: isFn, cleanPath } = require('@base-cms/utils'); | ||
}, | ||
primaryCategoryPath: async (content, { load }) => { | ||
const ref = BaseDB.get(content, 'mutations.Website.primaryCategory'); | ||
const id = BaseDB.extractRefId(ref); | ||
if (!id) return ''; | ||
// Load category and extract path. | ||
const query = { status: 1, type: 'Category' }; | ||
const category = await load('platformTaxonomy', id, { 'mutations.Website.urlPath': 1 }, query); | ||
return cleanPath(BaseDB.get(category, 'mutations.Website.urlPath')); | ||
}, | ||
}; | ||
@@ -27,0 +37,0 @@ |
@@ -16,4 +16,4 @@ const { parseDelimitedString } = require('@base-cms/utils'); | ||
const buildContentParts = (parts) => { | ||
const allowed = ['sectionAlias', 'type', 'id', 'slug']; | ||
const def = ['sectionAlias', 'type', 'id', 'slug']; | ||
const allowed = ['sectionAlias', 'primaryCategoryPath', 'type', 'id', 'slug']; | ||
const def = ['sectionAlias', 'primaryCategoryPath', 'type', 'id', 'slug']; | ||
@@ -20,0 +20,0 @@ const built = buildParts({ parts, allowed, def }); |
17315
407
Updated@base-cms/db@^1.0.0-beta.7