<%* try { // Get current file const currentFile = tp.file.find_tfile(tp.file.title); if (!currentFile) throw new Error("Current file not found"); // Read existing content const existingContent = await app.vault.read(currentFile); // Extract existing tags if they exist const tagsMatch = existingContent.match(/tags:\s*(.*?)(?:\r?\n|$)/); const tags = tagsMatch ? tagsMatch[1].trim() : ''; // Split content to preserve non-frontmatter content const contentParts = existingContent.split(/---\s*\n/); const mainContent = contentParts.length > 2 ? contentParts[2] : existingContent; // Create new properties-style frontmatter const frontmatter = `--- title: ${tp.file.title} author: Jon Marien created: ${tp.date.now("YYYY-MM-DD")} published: ${tp.date.now("YYYY-MM-DD")} tags: ${tags} ---`; // Combine frontmatter with preserved content const newContent = `${frontmatter}\n\n${mainContent.trim()}`; // Write to file await app.vault.modify(currentFile, newContent); new Notice("Properties updated successfully"); } catch (error) { console.error("Template Error:", error); new Notice("Failed to update properties: " + error.message); } _%>