Hide dataview variable (#54)

* hide dataview variable

* Update note.njk

---------

Co-authored-by: Ole Eskild Steensen <oleeskild@users.noreply.github.com>
This commit is contained in:
Utsob Roy 2023-02-04 18:45:57 +06:00 committed by GitHub
parent 6f876c9246
commit db6d4bb79b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 33 deletions

View File

@ -195,22 +195,15 @@ module.exports = function (eleventyConfig) {
eleventyConfig.addFilter("taggify", function (str) {
return (
str &&
str.replace(
tagRegex,
function (match, precede, tag) {
str.replace(tagRegex, function (match, precede, tag) {
return `${precede}<a class="tag" onclick="toggleTagSearch(this)">${tag}</a>`;
}
)
})
);
});
eleventyConfig.addFilter("searchableTags", function (str) {
let tags;
let match =
str &&
str.match(
tagRegex,
);
let match = str && str.match(tagRegex);
if (match) {
tags = match
.map((m) => {
@ -225,6 +218,15 @@ module.exports = function (eleventyConfig) {
}
});
eleventyConfig.addFilter("hideDataview", function (str) {
return (
str &&
str.replace(/\(\S+\:\:(.*)\)/g, function (_, value) {
return value.trim();
})
);
});
eleventyConfig.addTransform("callout-block", function (str) {
const parsed = parse(str);
@ -290,10 +292,10 @@ module.exports = function (eleventyConfig) {
return JSON.stringify(variable) || '""';
});
eleventyConfig.addFilter('validJson', function (variable) {
if(Array.isArray((variable))){
return variable.map(x=>x.replaceAll("\\", "\\\\")).join(",");
}else if(typeof(variable) === 'string'){
eleventyConfig.addFilter("validJson", function (variable) {
if (Array.isArray(variable)) {
return variable.map((x) => x.replaceAll("\\", "\\\\")).join(",");
} else if (typeof variable === "string") {
return variable.replaceAll("\\", "\\\\");
}
return variable;

View File

@ -39,7 +39,7 @@ permalink: "notes/{{ page.fileSlug | slugify }}/"
{% endif %}
</div>
</header>
{{ content | link | taggify | highlight | safe}}
{{ content | hideDataview | link | taggify | highlight | safe}}
</main>
{% if settings.dgShowBacklinks === true or settings.dgShowLocalGraph === true or settings.dgShowToc === true%}

View File

@ -35,7 +35,7 @@
</div>
</header>
{%- for garden in collections.gardenEntry -%}
{{garden.templateContent | link | taggify | highlight | safe }}
{{garden.templateContent | hideDataview | link | taggify | highlight | safe }}
{%- endfor -%}
</main>