Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
list-marker-space: false
no-inline-html: false
no-bare-urls: false
single-h1: false # Temporary
1 change: 1 addition & 0 deletions analyses/0001-contour.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
title: Docs assessment
cSpell:ignore: Horgan celestehorgan hashlinks
---

Expand Down
1 change: 1 addition & 0 deletions analyses/0002-notary-project.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
title: Notary Project Docs Assessment
cSpell:ignore: docset notaryproject celestehorgan
---

Expand Down
1 change: 1 addition & 0 deletions analyses/0003-krator.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
title: Krator Docs assessment
cSpell:ignore: Krator celestehorgan CODEOWNERS
---

Expand Down
1 change: 1 addition & 0 deletions analyses/0004-tremor.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
title: 'Assessment: Project Tremor'
cSpell:ignore: Horgan onramps offramps LLDB Wayfair
---

Expand Down
1 change: 1 addition & 0 deletions analyses/0005-fluxcd.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
title: Assessment template
cSpell:ignore: celestehorgan Horgan
---

Expand Down
1 change: 1 addition & 0 deletions analyses/0006-gateway-api.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
title: 'Assessment: Project Kubernetes Gateway API'
cSpell:ignore: Meha Bhalodiya mehabhalodiya kubernetes
---

Expand Down
1 change: 1 addition & 0 deletions analyses/0007-porter.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
title: Porter Docs Analysis
cSpell:ignore: Uchechukwu Obasi
---

Expand Down
4 changes: 4 additions & 0 deletions analyses/0008-backstage/backstage-glossary.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
title: Backstage Glossary
---

# Backstage Glossary

## API
Expand Down
1 change: 1 addition & 0 deletions analyses/0008-backstage/backstage-insights-summary.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
title: Backstage Insights
cSpell:ignore: flipside
---

Expand Down
4 changes: 4 additions & 0 deletions analyses/0008-backstage/backstage-issues.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
title: Backstage umbrella issue
---

# Backstage umbrella issue

## Overview
Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions analyses/0008-backstage/user-roles.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
title: Backstage User Roles for Doc
---

# Backstage User Roles for Doc

This document provides recommendations for user roles, or personas, for
Expand Down
4 changes: 4 additions & 0 deletions analyses/0009-in-toto/in-toto-analysis.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
title: Analysis of Existing Documentation
---

# Analysis of Existing Documentation

This document characterizes the effectiveness and completeness of the in-toto
Expand Down
4 changes: 4 additions & 0 deletions analyses/0009-in-toto/in-toto-doc-issues.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
title: Documentation Issues
---

# Documentation Issues

These issues identify and classify tasks that contributors can undertake to
Expand Down
1 change: 1 addition & 0 deletions analyses/0009-in-toto/in-toto-implementation.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
title: Implementation
cSpell:ignore: roadmaps Cappos
---

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
title: README
---

# README

These documents are intended to recommend a direction for the ongoing
Expand Down
4 changes: 4 additions & 0 deletions analyses/0009-in-toto/survey-of-existing-doc.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
title: Survey of existing documentation as of 09/2023
---

# Survey of existing documentation as of 09/2023

The following links are loosely sorted into conceptual categories.
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions analyses/0012-TUF/README.md → analyses/0012-TUF/index.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
title: TUF Documentation Analysis
cSpell:ignore: theupdateframework
---

Expand Down
4 changes: 4 additions & 0 deletions analyses/README.md → analyses/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
title: TechDocs Analysis for CNCF Projects
---

<!-- cSpell:ignore projectname -->

# TechDocs Analysis for CNCF Projects
Expand Down
4 changes: 4 additions & 0 deletions docs/analysis/criteria.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
title: Assessment criteria and examples
---

# Assessment criteria and examples

We recommend reading the
Expand Down
6 changes: 5 additions & 1 deletion docs/analysis/howto.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
title: CNCF TechDocs Analysis How-To
---

# CNCF TechDocs Analysis How-To

## Audience
Expand Down Expand Up @@ -217,5 +221,5 @@ Create issues in the project documentation GitHub repository for:
[analyses]: ../../analyses/
[criteria]: ./criteria.md
[project maturity level]: https://www.cncf.io/project-metrics
[templates]: ./templates/README.md
[templates]: ./templates/index.md
[issues list]: ./templates/issues-list.md
4 changes: 4 additions & 0 deletions docs/analysis/README.md → docs/analysis/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
title: TechDoc Analysis
---

# TechDoc Analysis

This section contains instructions and criteria for completing a documentation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
title: TechDoc Analysis Templates
---

# TechDoc Analysis Templates

This section contains templates for analyzing a CNCF project's documentation.
Expand Down
4 changes: 4 additions & 0 deletions docs/analytics/README.md → docs/analytics/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
title: Analytics
---

# Analytics

## Google Analytics
Expand Down
1 change: 1 addition & 0 deletions docs/analytics/ua-to-ga4.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
title: Migrating Universal to Google Analytics 4
cSpell:ignore: gtag kubernetes
---

Expand Down
4 changes: 4 additions & 0 deletions docs/assistance.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
title: Assistance program for technical documentation
---

# Assistance program for technical documentation

This document outlines the Cloud Native Computing Foundation (CNCF) Technical
Expand Down
4 changes: 4 additions & 0 deletions docs/hugo-and-docsy.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
title: Hugo and Docsy
---

# Hugo and Docsy

Tips:
Expand Down
5 changes: 5 additions & 0 deletions docs/README.md → docs/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
title: CNCF Techdocs how-tos
sidebar_position: 1
---

# CNCF Techdocs how-tos

This directory contains documentation on how the CNCF TechDocs team does things.
Expand Down
4 changes: 4 additions & 0 deletions docs/localization/README.md → docs/localization/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
title: CNCF Localization Guides
---

# CNCF Localization Guides

This directory contains a growing collection of localization guides that CNCF
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
title: CNCF日本語ローカライゼーション向けガイドライン
---

# CNCF日本語ローカライゼーション向けガイドライン

このドキュメントでは、CNCFのプロジェクトをローカライズする際に参考になる一般的なガイドラインを提供します。
Expand Down
1 change: 1 addition & 0 deletions docs/netlify-domains-setup.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
title: Netlify and domain setup
cSpell:ignore: caniszczyk
---

Expand Down
1 change: 1 addition & 0 deletions docs/repo-setup.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
title: Repository setup
cSpell:ignore: cncf
---

Expand Down
4 changes: 4 additions & 0 deletions docs/sandbox-doc-primer.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
title: CNCF sandbox project documentation primer
---

# CNCF sandbox project documentation primer

This document is a quick primer for CNCF project maintainers and contributors
Expand Down
4 changes: 4 additions & 0 deletions docs/searching-documentation.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
title: Documentation Search
---

# Documentation Search

<!-- markdownlint-disable no-duplicate-heading -->
Expand Down
4 changes: 4 additions & 0 deletions docs/services.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
title: Services for projects
---

# Services for projects

The CNCF provides technical writing and documentation website services for all
Expand Down
1 change: 1 addition & 0 deletions docs/versioning-documentation.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
title: prettier-ignore
# prettier-ignore
cSpell:ignore: Batard Brubaker Pursley velero fullversion githubbranch docsbranch Tanzu Rosland Horgan Takahashi
---
Expand Down
4 changes: 4 additions & 0 deletions docs/website-guidelines-checklist.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
title: CNCF website guidelines checklist
---

# CNCF website guidelines checklist

As per the
Expand Down
100 changes: 100 additions & 0 deletions scripts/add-frontmatter.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import { readFile, writeFile } from 'fs/promises';
import { glob } from 'glob';
import path from 'path';

// Regular expression to match frontmatter
const frontmatterRegex = /^---\s*\n([\s\S]*?)\n---\s*\n/;

// Regular expression to match first heading
const headingRegex = /^#\s+(.+)$/m;

// Regular expression to match title in frontmatter
const titleRegex = /^title:\s*(.+)$/m;

async function processFile(filePath) {
try {
const content = await readFile(filePath, 'utf-8');
const headingMatch = content.match(headingRegex);

if (!headingMatch) {
console.log(`Warning: ${filePath} has no heading to use as title`);
return;
}

const headingTitle = headingMatch[1].trim();
let hasFrontmatter = false;
let existingTitle = null;
let contentWithoutFrontmatter = content;
let existingFrontmatter = '';

// Check for existing frontmatter
const frontmatterMatch = content.match(frontmatterRegex);
if (frontmatterMatch) {
hasFrontmatter = true;
existingFrontmatter = frontmatterMatch[1];
contentWithoutFrontmatter = content.slice(frontmatterMatch[0].length);

// Check if title already exists
const titleMatch = existingFrontmatter.match(titleRegex);
if (titleMatch) {
existingTitle = titleMatch[1].trim();
}
}

// Only update if:
// 1. No frontmatter exists, or
// 2. Frontmatter exists but has no title, or
// 3. Frontmatter title doesn't match the heading
const needsUpdate = !hasFrontmatter || !existingTitle;
// || existingTitle !== headingTitle
if (needsUpdate) {
let newFrontmatter;
const formattedTitle = headingTitle.includes(':')
? `'${headingTitle}'`
: headingTitle;
if (hasFrontmatter) {
// Remove existing title if it exists
const frontmatterWithoutTitle = existingFrontmatter
.replace(titleRegex, '')
.trim();
newFrontmatter = `title: ${formattedTitle}${frontmatterWithoutTitle ? '\n' + frontmatterWithoutTitle : ''}`;
} else {
newFrontmatter = `title: ${formattedTitle}`;
}

const newContent = `---
${newFrontmatter}
---\n
${contentWithoutFrontmatter}`;

await writeFile(filePath, newContent);
console.log(
`${hasFrontmatter ? 'Updated' : 'Added'} frontmatter to ${filePath}`,
);
} else {
console.log(`Skipping ${filePath} - frontmatter title matches heading`);
}
} catch (error) {
console.error(`Error processing ${filePath}:`, error);
}
}

async function main() {
try {
// Find all markdown files in docs directory
const files = await glob('{analyses,docs}/**/*.md');
console.log(`Found ${files.length} markdown files`);

// Process each file
for (const file of files) {
await processFile(file);
}

console.log('Done!');
} catch (error) {
console.error('Error:', error);
process.exit(1);
}
}

main();