From 7c99ec4ae67fbb44372534919bb76189b090c486 Mon Sep 17 00:00:00 2001 From: Helen Chong <119173961+helenclx@users.noreply.github.com> Date: Tue, 7 May 2024 09:53:49 +0800 Subject: [PATCH] Add Q&A accordion paired shortcode --- eleventy.config.md.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/eleventy.config.md.js b/eleventy.config.md.js index cdf9d80f..73a1a935 100644 --- a/eleventy.config.md.js +++ b/eleventy.config.md.js @@ -81,13 +81,22 @@ module.exports = function (eleventyConfig) { // Paired shorcode: Spoiler accordion eleventyConfig.addPairedShortcode('spoiler', (content, hint) => { - content = content.trim(); - const hintMarkUp = markdownLibrary.renderInline(hint); + const hintMarkup = markdownLibrary.renderInline(hint); const contentMarkup = markdownLibrary.render(content); return `
- ${hintMarkUp} -
${contentMarkup}
-
`; + ${hintMarkup} +
${contentMarkup}
+ `; + }); + + // Paired shorcode: Q&A accordion + eleventyConfig.addPairedShortcode('qna', (answer, question) => { + const questionMarkup = markdownLibrary.renderInline(question); + const answerMarkup = markdownLibrary.render(answer); + return `
+ ${questionMarkup} +
${answerMarkup}
+
`; }); /* This is the part that tells 11ty to swap to our custom config */