nixos/docs/scripts/create_readme.sh
2024-10-07 10:13:21 +02:00

21 lines
761 B
Bash

#!/usr/bin/env bash
# Create the README.md file from the docs/src/README_template.md file
[[ -d "./docs" ]] || (echo "Folder ./docs not found" && exit 1)
README_FILE="./README.md"
table_of_content=$(md-table-of-contents ./docs/src/README_template.md) # https://github.com/anotherhadi/md-table-of-contents
readme_content=$(cat "./docs/src/README_template.md")
# Replace variables
readme_content=${readme_content//\{primarycolor\}/89b4fa}
readme_content=${readme_content//\{backgroundcolor\}/181825}
readme_content=${readme_content//\{md_table_of_content\}/$table_of_content}
echo "[//]: # (This file is autogenerated)" >"$README_FILE"
echo "$readme_content" >>"$README_FILE"
sed 's/\r//' "$README_FILE" >"/tmp/readme.md"
mv "/tmp/readme.md" "$README_FILE"