diff --git a/.eleventy.js b/.eleventy.js
index 8f0ced3..2fd7491 100644
--- a/.eleventy.js
+++ b/.eleventy.js
@@ -99,25 +99,25 @@ module.exports = function (eleventyConfig) {
let icon;
let color;
let nbLinesToSkip = 0
- for (let i = 0; i<4; i++) {
+ for (let i = 0; i < 4; i++) {
if (parts[i] && parts[i].trim()) {
let line = parts[i] && parts[i].trim().toLowerCase()
if (line.startsWith("title:")) {
titleLine = line.substring(6);
- nbLinesToSkip ++;
+ nbLinesToSkip++;
} else if (line.startsWith("icon:")) {
icon = line.substring(5);
- nbLinesToSkip ++;
+ nbLinesToSkip++;
} else if (line.startsWith("collapse:")) {
collapsible = true
collapse = line.substring(9);
if (collapse && collapse.trim().toLowerCase() == 'open') {
collapsed = false
}
- nbLinesToSkip ++;
+ nbLinesToSkip++;
} else if (line.startsWith("color:")) {
color = line.substring(6);
- nbLinesToSkip ++;
+ nbLinesToSkip++;
}
}
}
@@ -127,18 +127,17 @@ module.exports = function (eleventyConfig) {
` : "";
const titleDiv = titleLine
- ? `
`
- : "";
+ ? ``
+ : "";
let collapseClasses = titleLine && collapsible ? 'is-collapsible' : ''
if (collapsible && collapsed) {
collapseClasses += " is-collapsed"
}
- let res = `${titleDiv}\n
${md.render(
- parts.slice(nbLinesToSkip).join("\n")
- )}
`;
+ let res = `${titleDiv}\n
${md.render(
+ parts.slice(nbLinesToSkip).join("\n")
+ )}
`;
return res
}
@@ -153,7 +152,21 @@ module.exports = function (eleventyConfig) {
};
md.renderer.rules.image = (tokens, idx, options, env, self) => {
const imageName = tokens[idx].content;
- const [fileName, width] = imageName.split("|");
+ //"image.png|metadata?|width"
+ const [fileName, ...widthAndMetaData] = imageName.split("|");
+ const lastValue = widthAndMetaData[widthAndMetaData.length - 1];
+ const lastValueIsNumber = !isNaN(lastValue);
+ const width = lastValueIsNumber ? lastValue : null;
+
+ let metaData = "";
+ if (widthAndMetaData.length > 1) {
+ metaData = widthAndMetaData.slice(0, widthAndMetaData.length - 1).join(" ");
+ }
+
+ if (!lastValueIsNumber) {
+ metaData += ` ${lastValue}`;
+ }
+
if (width) {
const widthIndex = tokens[idx].attrIndex("width");
const widthAttr = `${width}px`;
@@ -246,7 +259,7 @@ module.exports = function (eleventyConfig) {
deadLink = true;
}
- if(deadLink){
+ if (deadLink) {
return `${title}`;
}
return `${title}`;
@@ -302,28 +315,30 @@ module.exports = function (eleventyConfig) {
let titleDiv = "";
let calloutType = "";
+ let calloutMetaData = "";
let isCollapsable;
let isCollapsed;
- const calloutMeta = /\[!([\w-]*)\](\+|\-){0,1}(\s?.*)/;
+ const calloutMeta = /\[!([\w-]*)\|?(\s?.*)\](\+|\-){0,1}(\s?.*)/;
if (!content.match(calloutMeta)) {
continue;
}
content = content.replace(
calloutMeta,
- function (metaInfoMatch, callout, collapse, title) {
+ function (metaInfoMatch, callout, metaData, collapse, title) {
isCollapsable = Boolean(collapse);
isCollapsed = collapse === "-";
const titleText = title.replace(/(<\/{0,1}\w+>)/, "")
? title
: `${callout.charAt(0).toUpperCase()}${callout
- .substring(1)
- .toLowerCase()}`;
+ .substring(1)
+ .toLowerCase()}`;
const fold = isCollapsable
? `
`
: ``;
calloutType = callout;
+ calloutMetaData = metaData;
titleDiv = ``;
return "";
}
@@ -334,6 +349,7 @@ module.exports = function (eleventyConfig) {
blockquote.classList.add(isCollapsable ? "is-collapsible" : "");
blockquote.classList.add(isCollapsed ? "is-collapsed" : "");
blockquote.setAttribute("data-callout", calloutType.toLowerCase());
+ calloutMetaData && blockquote.setAttribute("data-callout-metadata", calloutMetaData);
blockquote.innerHTML = `${titleDiv}\n${content}
`;
}
};
@@ -344,8 +360,8 @@ module.exports = function (eleventyConfig) {
});
function fillPictureSourceSets(src, cls, alt, meta, width, imageTag) {
- imageTag.tagName = "picture";
- let html = `
`
- if (meta.webp && meta.webp[1] && meta.webp[1].url) {
- html += ``
- }
- if (meta.jpeg && meta.jpeg[1] && meta.jpeg[1].url) {
- html += ``
- }
- html += `
`;
- imageTag.innerHTML = html;
- }
-
+ imageTag.innerHTML = html;
+ }
+
eleventyConfig.addTransform("picture", function (str) {
const parsed = parse(str);
@@ -458,7 +474,7 @@ module.exports = function (eleventyConfig) {
ul: true,
tags: ["h1", "h2", "h3", "h4", "h5", "h6"],
});
-
+
eleventyConfig.addFilter("dateToZulu", function (date) {
if (!date) return "";
@@ -477,7 +493,7 @@ module.exports = function (eleventyConfig) {
return variable;
});
- eleventyConfig.addPlugin(pluginRss, {
+ eleventyConfig.addPlugin(pluginRss, {
posthtmlRenderOptions: {
closingSingleTag: "slash",
singleTags: ["link"],