53 lines
2.1 KiB
Bash
Executable File
53 lines
2.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Скрипт добавляет categories в frontmatter статей
|
|
|
|
# Функция добавления категорий
|
|
add_categories() {
|
|
local file=$1
|
|
local categories=$2
|
|
|
|
echo "Обрабатываю: $file"
|
|
|
|
# Проверяем есть ли уже categories
|
|
if grep -q "^categories:" "$file"; then
|
|
echo " → Уже есть categories, заменяю"
|
|
# Удаляем старую строку categories
|
|
sed -i '/^categories:/d' "$file"
|
|
fi
|
|
|
|
# Вставляем categories после tags
|
|
awk -v cats="$categories" '
|
|
/^tags:/ {
|
|
print
|
|
getline
|
|
while ($0 ~ /^ -/ || $0 ~ /^\[/) {
|
|
print
|
|
if (getline <= 0) break
|
|
}
|
|
print cats
|
|
print
|
|
next
|
|
}
|
|
{ print }
|
|
' "$file" > "$file.tmp" && mv "$file.tmp" "$file"
|
|
|
|
echo " ✓ Добавлены категории"
|
|
}
|
|
|
|
# K3s статьи
|
|
add_categories "content/posts/k3s-part1-architecture/index.md" 'categories: ["Kubernetes", "Homelab"]'
|
|
add_categories "content/posts/k3s-part2-infrastructure/index.md" 'categories: ["Kubernetes", "Homelab"]'
|
|
add_categories "content/posts/k3s-part3-installation/index.md" 'categories: ["Kubernetes", "Homelab", "DevOps практики"]'
|
|
|
|
# Blog статьи
|
|
add_categories "content/posts/blog-part-1-architecture/index.md" 'categories: ["Веб-разработка"]'
|
|
add_categories "content/posts/blog-part-2-k8s-deployment/index.md" 'categories: ["Kubernetes", "Веб-разработка"]'
|
|
add_categories "content/posts/blog-part-3-dev-environment/index.md" 'categories: ["Веб-разработка", "DevOps практики"]'
|
|
add_categories "content/posts/blog-part-4-git-workflow/index.md" 'categories: ["Веб-разработка", "DevOps практики"]'
|
|
add_categories "content/posts/blog-part-5-debugging/index.md" 'categories: ["Kubernetes", "DevOps практики"]'
|
|
add_categories "content/posts/blog-part-6-namespace-migration/index.md" 'categories: ["Kubernetes", "DevOps практики"]'
|
|
|
|
echo ""
|
|
echo "Готово! Проверь изменения:"
|
|
echo "git diff content/posts/" |