-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hugo-script.sh
executable file
·33 lines (26 loc) · 921 Bytes
/
hugo-script.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env bash
# Helps migrate from Academic v4.1 to v4.2
#
# Refactors homepage sections named `content/home/X/index.md`
# as headless page bundles in Hugo.
#
# - E.g. Adds `headless = true` to `content/home/about.md`.
refactor_homepage_widget_bundles_as_headless()
{
# Check that the command was run from the site root.
if [ ! -d ./content/ ]; then
echo "Please run the script from the root of your Academic site" >&2
exit 1
fi
# Iterate over the homepage sections.
local files="$(find ./content/home/ -iname 'index.md')"
for file in ${files}; do
# Append new parameter after `widget` line using Mac and Unix friendly sed notation.
sed -e '/widget:/a\'$'\n''headless: true # This file represents a page section.' "${file}" > tmp && mv tmp "${file}"
done
}
# Bash Strict Mode
set -eu
# To debug, uncomment line below:
# set -x
refactor_homepage_widget_bundles_as_headless "$@"