How to save the folding state of each heading

I have a note with some headings, in this case two. (This file is made by templater plugin, but I have others that don’t.)

Is there a way to store the folding state of each heading? I want to always have heading 1 unfolded and heading 2 folded.

I tried creases plugin but it does not work as expected.

Remember file state plugin does not support this.

---
tags:
  - daily
  - note
  - täglich
filename: 2024-08-25-Sonntag-KW34
uid: e70d1937-5c87-479e-a4c7-e63d95e02ad8
erstellt: 2024-08-25T19:27:15+02:00
geändert: 2024-08-25T19:27:14+02:00
cssclasses:
  - clean-embeds
Info: 
Wiedervorlage: 
draft: true
prefer-view: edit-source

---

## 1 Neue Aufgaben vom 2024-08-25

- [x] Task A
- [ ] Task B

## 2 Aufgabenquellen %% fold %%

> [!NOTE]- Am `= (dateformat(this.erstellt, "yyyy-MM-dd"))` erstellte oder am `= dateformat(this.geändert, "yyyy-MM-dd")` geänderte Dateien
>
>  ```dataview
> TABLE WITHOUT ID
> file.link AS "Datei(en)",
> geändert,
> Info
> FROM ""
> WHERE 
> (dateformat(erstellt, "yyyy-MM-dd") = dateformat(this.erstellt, "yyyy-MM-dd") OR
> dateformat(geändert, "yyyy-MM-dd") = dateformat(this.geändert, "yyyy-MM-dd")) AND
> file.name != this.file.name
> SORT geändert DESC
> ```

[[MarkorQuickNote]] [[MarkorToDo]] [[ReadItLater]]

[[daily notes]] [[Alle Aufgaben nur aus den daily notes]]

[[KA Handhabung|KA]]

```dataviewjs
// Vault-Name als Parameter
const VAULT_NAME = "Obsidian";

const currentFile = dv.current().file.name;
const fileDate = dv.date(dv.current().file.frontmatter.erstellt);
const todayDate = dv.date('today');

// Debugging: Ausgabe der aktuellen Datei und des Datums
console.log("Aktuelle Datei:", currentFile);
console.log("Datum aus Frontmatter:", fileDate);
console.log("Heutiges Datum:", todayDate);

// Vorherige Datei
const previousFile = dv.pages('"Privat/daily notes"')
    .where(p => p.file.name != currentFile)
    .where(p => p.file.name.includes("KW"))
    .where(p => dv.date(p.file.frontmatter.erstellt) < fileDate)
    .sort(p => dv.date(p.file.frontmatter.erstellt), 'desc')
    .limit(1)
    .first();

// Debugging: Ausgabe der vorherigen Datei
console.log("Vorherige Datei:", previousFile);

// Nächste Datei
const nextFile = dv.pages('"Privat/daily notes"')
    .where(p => p.file.name != currentFile)
    .where(p => p.file.name.includes("KW"))
    .where(p => dv.date(p.file.frontmatter.erstellt) > fileDate)
    .where(p => dv.date(p.file.frontmatter.erstellt).toFormat('yyyy-MM-dd') <= todayDate.toFormat('yyyy-MM-dd'))
    .sort(p => dv.date(p.file.frontmatter.erstellt), 'asc')
    .limit(1)
    .first();

// Debugging: Ausgabe der nächsten Datei
console.log("Nächste Datei:", nextFile);

// Heute Datei
const todayFile = dv.pages('"Privat/daily notes"')
    .where(p => dv.date(p.file.frontmatter.erstellt).toFormat('yyyy-MM-dd') === todayDate.toFormat('yyyy-MM-dd'))
    .first();

// Debugging: Ausgabe der heutigen Datei
console.log("Heutige Datei:", todayFile);

// Ausgabe als Links
let output = '<div style="display: flex; justify-content: space-between;">';

if (previousFile) {
    output += `<span style="text-align: left;"><a href="obsidian://open?vault=${VAULT_NAME}&file=${encodeURIComponent(previousFile.file.path)}">Vorherige</a></span>`;
} else {
    output += '<span style="text-align: left;">Keine Vorherige</span>';
}

if (todayFile) {
    output += `<span style="text-align: center;"><a href="obsidian://open?vault=${VAULT_NAME}&file=${encodeURIComponent(todayFile.file.path)}">Heute</a></span>`;
} else {
    output += '<span style="text-align: center;">Keine Heute</span>';
}

if (nextFile) {
    output += `<span style="text-align: right;"><a href="obsidian://open?vault=${VAULT_NAME}&file=${encodeURIComponent(nextFile.file.path)}">Nächste</a></span>`;
} else {
    output += '<span style="text-align: right;">Keine Nächste</span>';
}

output += '</div>';

dv.container.innerHTML = output;
```

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.