Add collections dedicated to pdf template

This commit is contained in:
TheThomaas 2025-06-09 18:31:31 +02:00
parent 39a9ec10ca
commit 3d230cdd6a
2 changed files with 9 additions and 6 deletions

View file

@ -16,6 +16,12 @@ export default async function (eleventyConfig) {
process.env.DEBUG && console.log(inspect(sections)); process.env.DEBUG && console.log(inspect(sections));
return sections; return sections;
}); });
eleventyConfig.addCollection("pdfSections", (collectionApi) => {
const sections = collectionApi.getFilteredByGlob("./src/pages/sections/**")
.sort((a, b) => (a.data?.pdf?.order ?? a.data.order) - (b.data?.pdf?.order ?? b.data.order));
process.env.DEBUG && console.log(inspect(sections));
return sections;
});
eleventyConfig.addCollection("projects", (collectionApi) => { eleventyConfig.addCollection("projects", (collectionApi) => {
const projects = collectionApi.getFilteredByGlob("./src/projects/**") const projects = collectionApi.getFilteredByGlob("./src/projects/**")
.sort((a, b) => a.data.order - b.data.order); .sort((a, b) => a.data.order - b.data.order);

View file

@ -25,13 +25,10 @@ links:
</ul> </ul>
</section> </section>
<p> <p style="margin-bottom: 1ch;">{{ author.about }}</p>
The time is {{ "now" | date: "%Y-%m-%d %H:%M" }}
</p> {% for section in collections.pdfSections %}
{% if section.data.pdf.exclude != true %}
{% for section in collections.sections %}
{% if section.data.excludeFromPdf != true %}
{% assign items = collections[section.data.collection] %} {% assign items = collections[section.data.collection] %}
{% include 'partials/components/pdf/section' %} {% include 'partials/components/pdf/section' %}
{% endif %} {% endif %}