diff --git a/scripts/validate-links.ts b/scripts/validate-links.ts index 430868946..7c38bb557 100644 --- a/scripts/validate-links.ts +++ b/scripts/validate-links.ts @@ -42,6 +42,24 @@ function buildValidPaths(): Set { paths.add(p) } + // App routes (behind auth / mobile-ui) — content may link to these + for (const p of [ + '/profile', + '/profile/backup', + '/profile/edit', + '/profile/exchange-rate', + '/profile/identity-verification', + '/home', + '/send', + '/request', + '/settings', + '/history', + '/points', + '/recover-funds', + ]) { + paths.add(p) + } + const countrySlugs = listDirs(path.join(CONTENT_DIR, 'countries')) const competitorSlugs = listDirs(path.join(CONTENT_DIR, 'compare')) const payWithSlugs = listDirs(path.join(CONTENT_DIR, 'pay-with')) @@ -187,6 +205,30 @@ function isInternalLink(url: string): boolean { return true } +// --- Frontmatter parsing --- + +function parseFrontmatter(content: string): Record { + const match = content.match(/^---\n([\s\S]*?)\n---/) + if (!match) return {} + const frontmatter: Record = {} + for (const line of match[1].split('\n')) { + const colonIdx = line.indexOf(':') + if (colonIdx === -1) continue + const key = line.slice(0, colonIdx).trim() + const value = line.slice(colonIdx + 1).trim() + if (value === 'true') frontmatter[key] = true + else if (value === 'false') frontmatter[key] = false + else frontmatter[key] = value + } + return frontmatter +} + +function isPublished(content: string): boolean { + const fm = parseFrontmatter(content) + // If published is explicitly false, skip the file + return fm.published !== false +} + // --- Scan content files --- function getAllMdFiles(dir: string): string[] { @@ -225,8 +267,17 @@ function main() { const broken: BrokenLink[] = [] let totalLinks = 0 + let skippedUnpublished = 0 + for (const file of files) { const content = fs.readFileSync(file, 'utf-8') + + // Skip unpublished/draft content — links to not-yet-built routes are expected + if (!isPublished(content)) { + skippedUnpublished++ + continue + } + const links = extractLinks(content) totalLinks += links.length @@ -246,7 +297,10 @@ function main() { } // --- Report --- - console.log(`Checked ${totalLinks} internal links across ${files.length} files\n`) + if (skippedUnpublished > 0) { + console.log(` Skipped ${skippedUnpublished} unpublished files\n`) + } + console.log(`Checked ${totalLinks} internal links across ${files.length - skippedUnpublished} published files\n`) if (broken.length === 0) { console.log('✓ No broken internal links found!') diff --git a/src/content b/src/content index ffc4bdd8a..35cd834a4 160000 --- a/src/content +++ b/src/content @@ -1 +1 @@ -Subproject commit ffc4bdd8ac3925b9f80d77bb5bb6e5f85a3d45b4 +Subproject commit 35cd834a4494e11136099b739fadff1aea4c06ce