mirror of
https://github.com/tcsenpai/obsidiangarden_netlify.git
synced 2025-06-04 12:00:02 +00:00
support for hide in filetree (#106)
This commit is contained in:
parent
71fc4b8d37
commit
80d8ce1463
@ -46,6 +46,7 @@ function getPermalinkMeta(path, key) {
|
||||
let permalink = "/";
|
||||
let name = key.replace(".md", "");
|
||||
let noteIcon = process.env.NOTE_ICON_DEFAULT;
|
||||
let hide = false;
|
||||
try {
|
||||
const file = fs.readFileSync(`${path}`, "utf8");
|
||||
const frontMatter = matter(file);
|
||||
@ -61,11 +62,16 @@ function getPermalinkMeta(path, key) {
|
||||
if (frontMatter.data.noteIcon) {
|
||||
noteIcon = frontMatter.data.noteIcon;
|
||||
}
|
||||
// Reason for adding the hide flag instead of removing completely from file tree is to
|
||||
// allow users to use the filetree data elsewhere without the fear of losing any data.
|
||||
if (frontMatter.data.hide) {
|
||||
hide = frontMatter.data.hide;
|
||||
}
|
||||
} catch {
|
||||
//ignore
|
||||
}
|
||||
|
||||
return { permalink, name, noteIcon };
|
||||
return { permalink, name, noteIcon, hide };
|
||||
}
|
||||
|
||||
function populateWithPermalink(tree) {
|
||||
@ -74,13 +80,8 @@ function populateWithPermalink(tree) {
|
||||
const isNote = tree[key].path.endsWith(".md");
|
||||
tree[key].isNote = isNote;
|
||||
if (isNote) {
|
||||
let { permalink, name, noteIcon } = getPermalinkMeta(
|
||||
tree[key].path,
|
||||
key
|
||||
);
|
||||
tree[key].permalink = permalink;
|
||||
tree[key].name = name;
|
||||
tree[key].noteIcon = noteIcon;
|
||||
let meta = getPermalinkMeta(tree[key].path, key);
|
||||
Object.assign(tree[key], meta);
|
||||
}
|
||||
} else {
|
||||
tree[key].isFolder = true;
|
||||
|
@ -1,7 +1,7 @@
|
||||
{% macro menuItem(fileOrFolderName, fileOrFolder, step, currentPath) %}
|
||||
{%if fileOrFolder.isNote or fileOrFolder.isFolder%}
|
||||
<div x-show="isOpen" style="display:none" class="{{'filelist' if step>0}}">
|
||||
{%if fileOrFolder.isNote %}
|
||||
{%if fileOrFolder.isNote and not fileOrFolder.hide %}
|
||||
<div @click.stop class="notelink {{ 'active-note' if fileOrFolder.permalink === permalink}}">
|
||||
{%- if not meta.noteIconsSettings.filetree -%}<i icon-name="sticky-note" aria-hidden="true"></i>{%- endif -%}
|
||||
<a data-note-icon="{{fileOrFolder.noteIcon}}" style="text-decoration: none;" class="filename" href="{{fileOrFolder.permalink}}">{{fileOrFolder.name}} </a>
|
||||
|
Loading…
x
Reference in New Issue
Block a user