-
-
{{ selectedNote?.title || 'Aucune page' }}
-
-
@if (selectedNote) {
-
+
} @else {
📄
diff --git a/src/app/shared/markdown/markdown-frontmatter.util.ts b/src/app/shared/markdown/markdown-frontmatter.util.ts
index 445a85b..fd8ce18 100644
--- a/src/app/shared/markdown/markdown-frontmatter.util.ts
+++ b/src/app/shared/markdown/markdown-frontmatter.util.ts
@@ -5,6 +5,92 @@ function normalizeTag(tag: string): string {
return tag.trim().replace(/\s+/g, ' ');
}
+/**
+ * Réécrit des clés booléennes dans le front-matter YAML.
+ * - Crée la section --- ... --- si absente
+ * - Met à jour/insère les clés fournies (value true/false)
+ * - Supprime la clé si la valeur est undefined
+ * - Préserve les autres propriétés et le corps
+ */
+export function rewriteBooleanFrontmatter(
+ rawMarkdown: string,
+ updates: Record
+): string {
+ const content = rawMarkdown.replace(/^\uFEFF/, '').replace(/\r\n?/g, '\n');
+
+ const fmMatch = content.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)/);
+
+ const normalizeKey = (k: string) => k.trim();
+ const toYamlBool = (v: boolean) => (v ? 'true' : 'false');
+
+ const applyUpdatesToText = (fmText: string): string => {
+ const lines = fmText.split('\n');
+ const kept: string[] = [];
+ const updatedKeys = new Set(Object.keys(updates).map(normalizeKey));
+
+ for (const line of lines) {
+ const trimmed = line.trim();
+ if (!trimmed || trimmed.startsWith('#')) {
+ kept.push(line);
+ continue;
+ }
+ const colonIndex = line.indexOf(':');
+ if (colonIndex === -1) {
+ kept.push(line);
+ continue;
+ }
+ const key = normalizeKey(line.slice(0, colonIndex));
+ if (!updatedKeys.has(key)) {
+ kept.push(line);
+ continue;
+ }
+ const next = updates[key];
+ if (next === undefined) {
+ // remove this key (skip)
+ continue;
+ }
+ kept.push(`${key}: ${toYamlBool(next)}`);
+ // Mark as handled
+ updatedKeys.delete(key);
+ }
+
+ // Append remaining keys that didn't exist
+ for (const key of Object.keys(updates)) {
+ const norm = normalizeKey(key);
+ const val = updates[key];
+ if (val === undefined) continue;
+ // If not already written (because it existed), append
+ if (!kept.some(l => normalizeKey(l.split(':')[0] || '') === norm)) {
+ kept.push(`${norm}: ${toYamlBool(val)}`);
+ }
+ }
+
+ // Clean multiple empty lines
+ let out = kept.join('\n').replace(/\n{2,}/g, '\n').trim();
+ return out;
+ };
+
+ if (!fmMatch) {
+ // No frontmatter: create one only if there is at least one defined update
+ const definedEntries = Object.entries(updates).filter(([, v]) => v !== undefined) as Array<[
+ string,
+ boolean
+ ]>;
+ if (!definedEntries.length) return content;
+ const lines = definedEntries.map(([k, v]) => `${normalizeKey(k)}: ${toYamlBool(v)}`).join('\n');
+ return `---\n${lines}\n---\n${content}`;
+ }
+
+ const fmText = fmMatch[1] || '';
+ const body = fmMatch[2] || '';
+ const updatedFm = applyUpdatesToText(fmText);
+ if (!updatedFm.trim()) {
+ // If frontmatter became empty, drop the section entirely
+ return body;
+ }
+ return `---\n${updatedFm}\n---\n${body}`;
+}
+
/**
* Déduplique les tags (case-insensitive) en préservant la première occurrence
*/
diff --git a/src/app/shared/tags/tag-editor-overlay/tag-editor-overlay.component.html b/src/app/shared/tags/tag-editor-overlay/tag-editor-overlay.component.html
index acc8078..5997fe3 100644
--- a/src/app/shared/tags/tag-editor-overlay/tag-editor-overlay.component.html
+++ b/src/app/shared/tags/tag-editor-overlay/tag-editor-overlay.component.html
@@ -1,6 +1,6 @@
-
+
diff --git a/src/app/shared/tags/tag-manager/tag-manager.component.html b/src/app/shared/tags/tag-manager/tag-manager.component.html
index 4908bda..823934c 100644
--- a/src/app/shared/tags/tag-manager/tag-manager.component.html
+++ b/src/app/shared/tags/tag-manager/tag-manager.component.html
@@ -9,7 +9,30 @@
-
+
+
+
+
+
+
+
+