Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[build] Add a script that updates social tags for examples #4684

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
40 changes: 40 additions & 0 deletions src/update-example-tags.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash

set -Eeuo pipefail

# allow for simple recursive file globs
shopt -s globstar

# the left entries will be replaced by the right entries
# the following variables can be used in the replacement: \$filename, \$title, \$imgname, \$category
declare -A replacements=(
"<title>raylib web game</title>" "<title>\$title</title>"
"<meta name=\"title\" content=\"raylib web game\">" "<meta name=\"title\" content=\"\$title\">"
"New raylib web videogame\, developed using raylib videogames library" "raylib [\$category] example - \$title"
"raylib - example" "raylib - \$title"
"https://www.raylib.com/common/raylib_logo.png" "https://raw.githubusercontent.com/raysan5/raylib/master/examples/\$category/\$imgname"
"https://www.raylib.com/games.html" "https://www.raylib.com/examples/\$category/\$filename"
"raylib web game" "\$title"
)

function update_tags {
echo "update tags for: $1"
export filename=$(basename $1)
noext="${filename%.*}"
export title="${noext//_/ }"
export imgname="${noext}.png"
parts=($title)
export category="${parts[0]}"

for key in "${!replacements[@]}"; do
r=${replacements[$key]}
r=$(envsubst <<< "$r")
bash -c "sed -i 's,$key,$r,g' $1"
done
}

pushd ../examples

for i in **/*.html; do
update_tags "$i"
done
Loading