Skip to content

Commit b1a3289

Browse files
authored
Merge pull request #4050 from ClickHouse/Blargian-patch-57
Generate list of pages with community maintained vs ClickHouse maintained badges
2 parents 4f02764 + 71805ea commit b1a3289

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

scripts/list-integrations-badges.sh

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/bash
2+
# This script is used to generate a list of integration badges in use in docs/integrations
3+
4+
# Default to 'docs/integrations' directory if no argument provided
5+
DOCS_DIR="${1:-docs/integrations}"
6+
7+
# Check if directory exists
8+
if [ ! -d "$DOCS_DIR" ]; then
9+
echo "Error: Directory '$DOCS_DIR' does not exist"
10+
exit 1
11+
fi
12+
13+
# Components to search for
14+
components=(
15+
"ClickHouseSupportedBadge"
16+
"CommunityMaintainedBadge"
17+
)
18+
19+
# Custom display names (must match order of components array)
20+
display_names=(
21+
"ClickHouse Supported Integrations"
22+
"Community Maintained Integrations"
23+
)
24+
25+
# Function to extract slug from a file's frontmatter
26+
extract_slug_from_file() {
27+
local filepath="$1"
28+
local slug=""
29+
# Look for "slug: some/path/slug" in the file
30+
slug=$(grep -m 1 "^slug:" "$filepath" 2>/dev/null | sed 's/^slug:[[:space:]]*//' | tr -d '"' | tr -d "'")
31+
# If no slug found, return the filepath as fallback
32+
if [ -z "$slug" ]; then
33+
slug="[no slug] $filepath"
34+
fi
35+
echo "$slug"
36+
}
37+
38+
# Search for each component and collect all slugs
39+
for i in "${!components[@]}"; do
40+
component="${components[$i]}"
41+
display_name="${display_names[$i]}"
42+
43+
echo "$display_name:"
44+
# Get unique files containing the component
45+
files=$(grep -rl --include="*.md" --include="*.mdx" --include="*.jsx" --include="*.tsx" \
46+
-E "<$component[[:space:]/>]|</$component>" "$DOCS_DIR" 2>/dev/null | sort -u)
47+
48+
if [ -z "$files" ]; then
49+
echo " (none)"
50+
else
51+
while IFS= read -r file; do
52+
if [ -n "$file" ]; then
53+
slug=$(extract_slug_from_file "$file")
54+
if [[ "$slug" == \[no\ slug\]* ]]; then
55+
echo "$slug"
56+
else
57+
echo "/docs$slug"
58+
fi
59+
fi
60+
done <<< "$files"
61+
fi
62+
echo
63+
done

0 commit comments

Comments
 (0)