Zum Hauptinhalt springen

Recipe: Discover Project Branding

For AI agents: Find and use project-level branding configuration.

Goal

Locate color/branding files in a project to use consistent colors and styles.

Projekt-Strukturen

Variante A: Minimal (nur Styleguide-Farben)

docs/
├── _colors.d2 # Styleguide-Farben
└── *.d2 # Diagramme

Variante B: Mit Projekt-Farben

docs/
├── .branding/
│ ├── _colors.d2 # Styleguide-Farben
│ └── _project-colors.d2 # Projekt-spezifisch
└── *.d2

Discovery Script (Bash)

# Find color files - checks both variants
find_colors() {
local git_root=$(git rev-parse --show-toplevel 2>/dev/null)
[ -z "$git_root" ] && echo "NOT_FOUND" && return 1

# Variante B: .branding/ Ordner
if [ -f "$git_root/docs/.branding/_colors.d2" ]; then
echo "$git_root/docs/.branding"
return 0
fi

# Variante A: flat
if [ -f "$git_root/docs/_colors.d2" ]; then
echo "$git_root/docs"
return 0
fi

echo "NOT_FOUND"
return 1
}

BRANDING=$(find_colors)

What's Inside

FilePurposeUsed by
_colors.d2Styleguide System-Farben (kopiert)D2 diagrams
_project-colors.d2Projekt-spezifische Komponenten-FarbenD2 diagrams
metadata.yamlPDF branding (title color, fonts, headers)pandoc/pdf-publisher

Setup

Variante A (minimal):

cp path/to/tis-cca.styleguide/v2/assets/colors/_colors.d2 docs/

Variante B (mit Projekt-Farben):

mkdir -p docs/.branding
cp path/to/tis-cca.styleguide/v2/assets/colors/_colors.d2 docs/.branding/

Using in D2 Diagrams

# Variante A: flat (docs/_colors.d2)
...@_colors.d2

# Variante B: .branding/ (Quotes erforderlich!)
...@".branding/_colors.d2"
...@".branding/_project-colors.d2"

my-service: {
style.fill: ${soa-gfx} # defined in _project-colors.d2
}

Hinweis: D2 interpretiert . als Targeting-Operator. Pfade mit Punkt-Ordnern muessen in Quotes stehen.

Fallback

If docs/.branding/ doesn't exist:

  • For diagrams: use system colors only, or create the folder
  • For PDFs: build without --meta flag (no branding)

Migration

If project has docs/templates/metadata.yaml:

mkdir -p docs/.branding
mv docs/templates/metadata.yaml docs/.branding/
# Update any scripts referencing the old path