diff --git a/lib/apiRoutes.js b/lib/apiRoutes.js index ad87a24f..8bc2d2d9 100644 --- a/lib/apiRoutes.js +++ b/lib/apiRoutes.js @@ -28,13 +28,19 @@ module.exports = self => { return [ ...new Set(relatedTypes) ]; - // TODO: do not include types that have the `relatedDocument = false` // option in their module configuration function searchRelationships(obj) { const shouldRecurse = recursions <= maxRecursions; if (obj.type === 'relationship') { - return obj.withType; + // Filter out types that has the `relatedDocument` option set to `false` in their module. + // Use `default-page` because this option is set on the page-type module, + // which does not actually exist inside `apos.modules`: + const module = obj.withType === '@apostrophecms/page' + ? 'default-page' + : obj.withType; + + return self.apos.modules[module].options.relatedDocument === false && obj.withType; } else if (obj.type === 'array' || obj.type === 'object') { recursions++; return shouldRecurse && obj.schema.flatMap(searchRelationships); diff --git a/lib/methods/export.js b/lib/methods/export.js index e50c4c14..59b2d49b 100644 --- a/lib/methods/export.js +++ b/lib/methods/export.js @@ -164,7 +164,7 @@ module.exports = self => { // never be considered "related" to other pages simply because // of navigation links, the feature is meant for pieces that feel more like // part of the document being localized) - return related.filter(doc => self.apos.modules[doc.type].relatedDocument !== false); + return related.filter(doc => self.apos.modules[doc.type].options.relatedDocument !== false); } }; };