cloudcannon-hugo
Advanced tools
Comparing version 0.13.3 to 0.13.4
{ | ||
"name": "cloudcannon-hugo", | ||
"type": "module", | ||
"version": "0.13.3", | ||
"version": "0.13.4", | ||
"description": "Generates the files necessary for a hugo site to integrate with CloudCannon CMS", | ||
@@ -6,0 +6,0 @@ "main": "src/index.js", |
@@ -44,2 +44,14 @@ import { basename, dirname, extname } from 'path'; | ||
export function getDefinedCollectionName(itemPath, definedCollections) { | ||
let collectionKey, prevDirectory; | ||
let itemDirectory = itemPath; | ||
do { | ||
prevDirectory = itemDirectory; | ||
itemDirectory = dirname(prevDirectory); | ||
collectionKey = definedCollections[itemDirectory]; | ||
} while (!collectionKey && itemDirectory !== prevDirectory); | ||
return collectionKey; | ||
} | ||
export function getPageUrl(path, hugoUrls = {}, contentDir) { | ||
@@ -154,3 +166,5 @@ if (hugoUrls[path]) { | ||
if (initialCollectionsConfig[collectionKey].path) { | ||
definedCollections[initialCollectionsConfig[collectionKey].path] = collectionKey; | ||
// remove trailing slash | ||
const collectionPath = initialCollectionsConfig[collectionKey].path.replace(/\/$/, ''); | ||
definedCollections[collectionPath] = collectionKey; | ||
} | ||
@@ -183,3 +197,3 @@ }); | ||
await Promise.all(slice.map(async (itemPath) => { | ||
const collectionKey = definedCollections[dirname(itemPath)] | ||
const collectionKey = getDefinedCollectionName(itemPath, definedCollections) | ||
|| getCollectionKey(itemPath, paths.content, paths.archetypes); | ||
@@ -186,0 +200,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40508
1069