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) {
return `${precede}<a class="tag" onclick="toggleTagSearch(this)">${tag}</a>`;
}
)
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,11 +292,11 @@ 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'){
return variable.replaceAll("\\", "\\\\");
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

@ -22,24 +22,24 @@ permalink: "notes/{{ page.fileSlug | slugify }}/"
<main class="content cm-s-obsidian">
<header>
{% if settings.dgShowInlineTitle === true %}
<h1>{% if title %}{{ title }}{% else %}{{ page.fileSlug }}{% endif %}</h1>
{% endif %}
<div class="header-meta">
{% if settings.dgShowTags === true and tags %}
<div class="header-tags">
{% for tag in tags %}
{% if tag != 'gardenEntry' and tag !='note' %}
<a class="tag" onclick="toggleTagSearch(this)">
#{{tag}}
</a>
{% endif %}
{% endfor %}
</div>
{% if settings.dgShowInlineTitle === true %}
<h1>{% if title %}{{ title }}{% else %}{{ page.fileSlug }}{% endif %}</h1>
{% endif %}
</div>
<div class="header-meta">
{% if settings.dgShowTags === true and tags %}
<div class="header-tags">
{% for tag in tags %}
{% if tag != 'gardenEntry' and tag !='note' %}
<a class="tag" onclick="toggleTagSearch(this)">
#{{tag}}
</a>
{% endif %}
{% endfor %}
</div>
{% 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>