Skip to content

Commit e1fdacf

Browse files
committed
Include category attachments to linkableNodes
1 parent 8151835 commit e1fdacf

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

src/ssg/compiler/contentModel/index.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@ class ContentModel extends ContentModelEntryNode {
191191
}
192192

193193
linkNodes() {
194+
const withAttachments = (node) => {
195+
return [node, ...node.subtree.attachments]
196+
}
197+
194198
const flatMapDeepCategories = (container) => {
195199
return _.flatMapDeep(container, ({ subtree }) => {
196200
if (subtree.categories.length) {
@@ -205,11 +209,14 @@ class ContentModel extends ContentModelEntryNode {
205209

206210
const nodes = [
207211
...this.subtree.assets,
208-
...this.subtree.subpages,
209-
...this.subtree.collections,
210-
...flatMapDeepCategories(this.subtree.collections),
212+
..._.flatMap(this.subtree.subpages.map(withAttachments)),
213+
..._.flatMap(this.subtree.collections.map(withAttachments)),
214+
..._.flatMap(
215+
flatMapDeepCategories(this.subtree.collections),
216+
withAttachments
217+
),
211218
..._.flatMapDeep(this.subtree.collections, ({ subtree }) => {
212-
return subtree.posts.map(post => [post, post.subtree.attachments])
219+
return subtree.posts.map(withAttachments)
213220
})
214221
]
215222

@@ -286,4 +293,4 @@ class ContentModel extends ContentModelEntryNode {
286293
}
287294
}
288295

289-
module.exports = ContentModel
296+
module.exports = ContentModel

0 commit comments

Comments
 (0)