Skip to content

Commit 8151835

Browse files
committed
Make assets/attachments linkable
1 parent e49212d commit 8151835

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

src/ssg/compiler/contentModel/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,13 @@ class ContentModel extends ContentModelEntryNode {
204204
}
205205

206206
const nodes = [
207+
...this.subtree.assets,
207208
...this.subtree.subpages,
208209
...this.subtree.collections,
209210
...flatMapDeepCategories(this.subtree.collections),
210-
..._.flatMap(this.subtree.collections, ({ subtree }) => subtree.posts)
211+
..._.flatMapDeep(this.subtree.collections, ({ subtree }) => {
212+
return subtree.posts.map(post => [post, post.subtree.attachments])
213+
})
211214
]
212215

213216
nodes.forEach(node => node.resolveLinks(nodes))

src/ssg/lib/ContentModelResourceNode.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ const { join } = require('path')
22
const _ = require('lodash')
33
const { makePermalink } = require('./contentModelHelpers')
44
const ContentModelNode = require('./ContentModelNode')
5+
const { addLinkBack, serializeLinks, resolveLinks } = require('./linking')
56

67
class ContentModelResourceNode extends ContentModelNode {
78
constructor(fsNode, context, settings = {}) {
89
super(fsNode, context, settings)
10+
this.slug = this.title
911
this.permalink = this.getPermalink()
1012
this.outputPath = this.getOutputPath()
1113
this.subtreeMatchers = this.getSubtreeMatchers()
@@ -38,6 +40,18 @@ class ContentModelResourceNode extends ContentModelNode {
3840
return {}
3941
}
4042

43+
addLinkBack(post, key) {
44+
addLinkBack(this, post, key)
45+
}
46+
47+
resolveLinks(nodes) {
48+
resolveLinks(this, nodes)
49+
}
50+
51+
serializeLinks() {
52+
return serializeLinks(this)
53+
}
54+
4155
afterEffects(contentModel) {}
4256

4357
render(renderer) {}

0 commit comments

Comments
 (0)