-
I have a several paginating templates. Currently they all have similar (note: no I don't really use these directory/file/data/alias names. they're for the demo)
---
# paginateds/dir1/template.njk
pagination:
alias: myalias
data: data1 # every item has a `permalink`
size: 1
--- ---
# paginateds/dir2/template.njk
pagination:
alias: myalias
data: data2 # every item has a `permalink`
size: 1
--- // paginateds.11tydata.js
export default {
eleventyComputed: {
permalink: ({ pagination }) => pagination.items[0].permalink,
}
} To reduce boilerplate I'd like to move the overlapping parts of the ---
# paginateds/dir1/template.njk
paginationData: data1 # every item has a `permalink`
--- ---
# paginateds/dir2/template.njk
paginationData: data2 # every item has a `permalink`
--- // paginateds.11tydata.js
export default { // I'm using ESM with the latest v3 canary (3.0.0-alpha.14)
eleventyComputed: {
pagination: ({ paginationData }) => ({
alias: "myalias",
data: paginationData,
size: 1,
}),
permalink: ({ pagination }) => pagination.items[0].permalink,
}
}
expand for side quest: why a new frontmatter key
This
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Got it Non- ---
pagination:
data: # …
--- export default { // I'm using ESM with the latest v3 canary (3.0.0-alpha.14)
eleventyComputed: {
permalink: ({ pagination }) => pagination.items[0].permalink,
},
pagination: {
alias: "myalias",
size: 1,
}),
} |
Beta Was this translation helpful? Give feedback.
Got it
Non-
eleventyComputed
data file data must be read earlier because this works