Changed post_url shortcode
Changed so it doesn't need a collection passed in. Should probably have a second option that does
This commit is contained in:
parent
61809329ec
commit
27b514e9bd
18
.eleventy.js
18
.eleventy.js
|
@ -105,8 +105,8 @@ module.exports = function (eleventyConfig) {
|
||||||
collection.getFilteredByGlob("./src/_pages/**/*")
|
collection.getFilteredByGlob("./src/_pages/**/*")
|
||||||
);
|
);
|
||||||
|
|
||||||
eleventyConfig.addCollection("posts", (collection) =>
|
eleventyConfig.addCollection("posts", (collection) => {
|
||||||
collection
|
availablePages = collection
|
||||||
.getFilteredByGlob("./src/_posts/**/*")
|
.getFilteredByGlob("./src/_posts/**/*")
|
||||||
.filter(
|
.filter(
|
||||||
(item) => item.data.draft !== true && item.date <= new Date()
|
(item) => item.data.draft !== true && item.date <= new Date()
|
||||||
|
@ -118,8 +118,10 @@ module.exports = function (eleventyConfig) {
|
||||||
prev: all[i + 1],
|
prev: all[i + 1],
|
||||||
};
|
};
|
||||||
return cur;
|
return cur;
|
||||||
})
|
});
|
||||||
);
|
|
||||||
|
return availablePages;
|
||||||
|
});
|
||||||
|
|
||||||
eleventyConfig.addCollection("projects", (collection) =>
|
eleventyConfig.addCollection("projects", (collection) =>
|
||||||
collection
|
collection
|
||||||
|
@ -259,7 +261,11 @@ module.exports = function (eleventyConfig) {
|
||||||
eleventyConfig.addPassthroughCopy("src/assets");
|
eleventyConfig.addPassthroughCopy("src/assets");
|
||||||
// eleventyConfig.addPassthroughCopy({ "src/_sass": "assets/css" });
|
// eleventyConfig.addPassthroughCopy({ "src/_sass": "assets/css" });
|
||||||
|
|
||||||
eleventyConfig.addShortcode("post_url", (collection, slug) => {
|
let availablePages = [];
|
||||||
|
|
||||||
|
eleventyConfig.addShortcode("post_url", (slug) => {
|
||||||
|
let collection = availablePages;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (collection.length < 1) {
|
if (collection.length < 1) {
|
||||||
throw "Collection appears to be empty";
|
throw "Collection appears to be empty";
|
||||||
|
@ -279,7 +285,7 @@ module.exports = function (eleventyConfig) {
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(
|
console.error(
|
||||||
`RMCG:An error occured while searching for the url to ${slug}. Details:`,
|
`RMCG:An error occurred while searching for the url to ${slug}. Details:`,
|
||||||
e
|
e
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ gallery:
|
||||||
title: DevOps Roadmap
|
title: DevOps Roadmap
|
||||||
date: 2020-04-21 00:44:00 +01:00
|
date: 2020-04-21 00:44:00 +01:00
|
||||||
---
|
---
|
||||||
I mentioned in the [goals post]({% post_url collections.posts, "goals" %}), one of the things I am aiming to do is to start learning web development.
|
I mentioned in the [goals post]({% post_url "goals" %}), one of the things I am aiming to do is to start learning web development.
|
||||||
|
|
||||||
I was well aware that what falls under the banner of web development is massive, I just hadn't realised quite how large it was.
|
I was well aware that what falls under the banner of web development is massive, I just hadn't realised quite how large it was.
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,9 @@ pagination:
|
||||||
---
|
---
|
||||||
|
|
||||||
{%- for post in pagination.items -%}
|
{%- for post in pagination.items -%}
|
||||||
<h2><a href="{% post_url collections.posts, post.fileSlug %}">{{ post.data.title }}</a></h2>
|
<h2><a href="{% post_url post.fileSlug %}">{{ post.data.title }}</a></h2>
|
||||||
<em>{{ post.data.date | toUTCString}}</em>
|
<em>{{ post.data.date | toUTCString}}</em>
|
||||||
<p>{{ post.templateContent | description }} <a href="{% post_url collections.posts, post.fileSlug %}"><em>read more</em></a></p>
|
<p>{{ post.templateContent | description }} <a href="{% post_url post.fileSlug %}"><em>read more</em></a></p>
|
||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue