Skip to content

Commit

Permalink
Use filters, as transforms has memory issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Ole Eskild Steensen committed Apr 18, 2022
1 parent e4500a6 commit b9f2585
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions .eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ module.exports = function(eleventyConfig) {

eleventyConfig.setLibrary("md", markdownLib);

eleventyConfig.addTransform('link', function(str) {
eleventyConfig.addFilter('link', function(str) {
return str && str.replace(/\[\[(.*?\|.*?)\]\]/g, function(match, p1) {
//Check if it is an embedded excalidraw drawing or mathjax javascript
if (p1.indexOf("],[") > -1 || p1.indexOf('"$"') > -1) {
Expand Down Expand Up @@ -143,7 +143,7 @@ module.exports = function(eleventyConfig) {
});
})

eleventyConfig.addTransform('highlight', function(str) {
eleventyConfig.addFilter('highlight', function(str) {
return str && str.replace(/\=\=(.*?)\=\=/g, function(match, p1) {
return `<mark>${p1}</mark>`;
});
Expand All @@ -155,7 +155,7 @@ module.exports = function(eleventyConfig) {
let titleDiv = "";
let calloutType = "";
const calloutMeta = /\[!(\w*)\](\s?.*)/g;
if(!content.match(calloutMeta)){
if (!content.match(calloutMeta)) {
return match;
}

Expand Down
2 changes: 1 addition & 1 deletion src/site/_includes/layouts/note.njk
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ permalink: "notes/{{ page.fileSlug | slugify }}/"
{% if dgHomeLink !== false%}
<a href="/">🏡 Back Home</a>
{% endif %}
{{ content | safe}}
{{ content | link | highlight | safe}}
</div>
</body>
</html>
2 changes: 1 addition & 1 deletion src/site/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{%include "components/notegrowthhistory.njk"%}
<div class="content">
{%- for garden in collections.gardenEntry -%}
{{garden.templateContent | safe }}
{{garden.templateContent | link | highlight | safe }}
{%- endfor -%}
</div>
</body>
Expand Down

0 comments on commit b9f2585

Please sign in to comment.