diff options
Added a script for generating head element titles
4 files changed, 22 insertions, 1 deletions
| -rwxr-xr-x | generate-dev.sh | 1 | ||||
| -rwxr-xr-x | generate.sh | 1 | ||||
| -rwxr-xr-x | make-titles.sh | 19 | ||||
| -rw-r--r-- | src/_header.html | 2 |
diff --git a/generate-dev.sh b/generate-dev.sh index c29f5b6..53aaec3 100755 --- a/generate-dev.sh +++ b/generate-dev.sh @@ -12,4 +12,5 @@ sudo rm -f /var/www/synd/.files # Generate files sudo ssg6 src /var/www/synd/ "Syndamia" "https://www.syndamia.com" +sudo ./make-titles.sh /var/www/synd sudo ./make-descriptions.sh /var/www/synd diff --git a/generate.sh b/generate.sh index 941a31d..7f577f8 100755 --- a/generate.sh +++ b/generate.sh @@ -11,4 +11,5 @@ sudo rm -f website/.files # Generate files sudo ssg6 src website "Syndamia" "https://www.syndamia.com" +sudo ./make-titles.sh website sudo ./make-descriptions.sh website diff --git a/make-titles.sh b/make-titles.sh new file mode 100755 index 0000000..bf739ff --- /dev/null +++ b/make-titles.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +if [ -z "$1" ]; then + echo First parameter must be a path + exit +fi + +# Loop through all HTML files in given directory +for file in $(find "$1" -type f -name "*.html"); do + # Get text that matches "h1>any amount of characters</h1" from current file + # remove the "h1>" and "</h1" from result + title=$(egrep -o "h1(.+)>(.+)<\/h1" $file | sed "s/h1[^>]\+>\|<\/h1//g") + + # Escape all non-acceptable characters (thanks https://www.unix.com/302989284-post3.html) + title=$(echo $title | sed 's/[^a-zA-Z 0-9]/\\&/g') + + # Replace all "[TITLE]" text in current file with what we selected (inside title) + sed -i "s/\[TITLE\]/$title/g" $file +done diff --git a/src/_header.html b/src/_header.html index fd19cd7..e30896d 100644 --- a/src/_header.html +++ b/src/_header.html @@ -12,7 +12,7 @@ <link rel="stylesheet" href="/styles.css"> <meta name="description" content="[DESCRIPTION]"> <meta property="og:type" content="website"> - <meta property="og:title" content="Syndamia - Kamen Mladenov"> + <meta property="og:title" content="[TITLE]"> <meta property="og:description" content="[DESCRIPTION]"> <meta property="og:image" content="https://syndamia.com/img/meta-banner.png"> <meta property="og:url" content="https://syndamia.com"> |