From 12359144cbf51761a6f3198e6cbedd45d2e2d1ad Mon Sep 17 00:00:00 2001 From: Aran Roig Date: Sat, 18 Jul 2026 15:00:19 +0200 Subject: [PATCH] Test --- template/.gitignore | 2 +- template/Dockerfile | 4 +-- template/app/components/TreeNode.vue | 51 +++++++++++++++++++++++++--- template/content/index.md | 6 +++- template/convert.js | 44 ++++++++++++++++++++---- 5 files changed, 93 insertions(+), 14 deletions(-) diff --git a/template/.gitignore b/template/.gitignore index 31f99cf..9436ad2 100644 --- a/template/.gitignore +++ b/template/.gitignore @@ -23,5 +23,5 @@ logs .env.* !.env.example -content +content/ vault \ No newline at end of file diff --git a/template/Dockerfile b/template/Dockerfile index 5c7f3c0..7b322d5 100644 --- a/template/Dockerfile +++ b/template/Dockerfile @@ -1,5 +1,5 @@ # ---------- Build Stage ---------- -FROM node:20-alpine AS builder +FROM node:24-alpine AS builder WORKDIR /app @@ -23,7 +23,7 @@ RUN node convert.js --vault ./vault --out ./content --img-prefix https://cdn.ara RUN npm run build # ---------- Production Stage ---------- -FROM node:20-alpine +FROM node:24-alpine WORKDIR /app diff --git a/template/app/components/TreeNode.vue b/template/app/components/TreeNode.vue index 3ea5c6a..cf91452 100644 --- a/template/app/components/TreeNode.vue +++ b/template/app/components/TreeNode.vue @@ -1,11 +1,13 @@ - @@ -46,6 +59,36 @@ li { } a { + color: var(--text-link); +} + +.folder-toggle { + display: flex; + align-items: center; + gap: 0.35rem; + background: none; + border: none; + padding: 0; + cursor: pointer; + color: inherit; + font: inherit; + width: 100%; + text-align: left; + + &:hover { color: var(--text-link); + } +} + +.chevron { + display: inline-block; + font-style: normal; + transition: transform 0.15s ease; + transform: rotate(0deg); + line-height: 1; + + &.open { + transform: rotate(90deg); + } } \ No newline at end of file diff --git a/template/content/index.md b/template/content/index.md index e4f5e57..08a564b 100644 --- a/template/content/index.md +++ b/template/content/index.md @@ -1,5 +1,9 @@ -# index +--- +visible: true +--- +# Millor campana + Hola que tal! Hauria de funcionar Test diff --git a/template/convert.js b/template/convert.js index aee945f..64c0985 100644 --- a/template/convert.js +++ b/template/convert.js @@ -17,6 +17,10 @@ * 9. Inline #tags → stripped (kept in frontmatter.tags) * 10. Frontmatter → passed through; tags array merged * + * VISIBILITY GATE: + * Only notes whose frontmatter contains `visible: true` are converted. + * Any note missing the field, or with `visible: false`, is silently skipped. + * * Usage: * node obsidian-to-nuxt.js --vault ./my-vault --out ./content --base-path /notes * @@ -171,12 +175,23 @@ function parseFrontmatter(content) { if (kv) { currentKey = kv[1]; const val = kv[2].trim(); - fm[currentKey] = val === "" ? [] : val.replace(/^["']|["']$/g, ""); + // Coerce boolean-like values so `visible: true` becomes the boolean true + if (val === "true") fm[currentKey] = true; + else if (val === "false") fm[currentKey] = false; + else fm[currentKey] = val === "" ? [] : val.replace(/^["']|["']$/g, ""); } } return { frontmatter: fm, body }; } +/** + * Returns true only when the frontmatter contains `visible: true` (boolean). + * Missing field, `visible: false`, or any other value → false. + */ +function isVisible(frontmatter) { + return frontmatter.visible === true; +} + function serializeFrontmatter(fm) { const lines = ["---"]; for (const [key, val] of Object.entries(fm)) { @@ -350,7 +365,9 @@ function convertFile(content, noteIndex, filename) { const hasTitle = /^#[^#]/.test(trimmed); if (!hasTitle) { const title = frontmatter.title || path.basename(filename, ".md"); - body = "# " + title + "\n\n" + trimmed; + if (title != "index") { + body = "# " + title + "\n\n" + trimmed; + } } const fmString = Object.keys(frontmatter).length @@ -373,10 +390,23 @@ function main() { console.log("Found " + files.length + " markdown file(s) in " + VAULT_DIR); - let doneCount = 0, skipCount = 0; + let doneCount = 0, skipCount = 0, hiddenCount = 0; for (const file of files) { const rel = path.relative(VAULT_DIR, file); + const content = fs.readFileSync(file, "utf8"); + + // ── Visibility gate ────────────────────────────────────────────────────── + // Parse frontmatter just enough to check the `visible` field. + // Notes without `visible: true` are skipped entirely. + const { frontmatter: fm } = parseFrontmatter(content); + if (!isVisible(fm)) { + console.log(" \u23ED " + rel + " (skipped — no visible: true)"); + hiddenCount++; + continue; + } + // ───────────────────────────────────────────────────────────────────────── + const outPath = path.join( OUT_DIR, rel.split(path.sep) @@ -384,9 +414,7 @@ function main() { .join(path.sep) ); - const content = fs.readFileSync(file, "utf8"); let result; - try { result = convertFile(content, noteIndex, path.basename(file)); } catch (err) { @@ -408,7 +436,11 @@ function main() { doneCount++; } - console.log("\nDone. " + doneCount + " file(s) converted, " + skipCount + " skipped."); + console.log( + "\nDone. " + doneCount + " file(s) converted, " + + hiddenCount + " hidden (no visible: true), " + + skipCount + " skipped (error)." + ); } main(); \ No newline at end of file