From e3a2ff8cd4f3d01841205f4598d53a1146f16d50 Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Tue, 22 Aug 2023 14:20:19 +0700 Subject: [PATCH 1/2] inject sa script to rustdocs --- .maintain/rustdocs-release.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.maintain/rustdocs-release.sh b/.maintain/rustdocs-release.sh index 2a1e141e63ad2..32f896dfd77e2 100755 --- a/.maintain/rustdocs-release.sh +++ b/.maintain/rustdocs-release.sh @@ -91,6 +91,22 @@ build_rustdocs() { && echo "" > "${2}/index.html" } +inject_analytics_script() { + local path="$1" + local script_content="" + + # Define a function that injects our script into the head of an html file. + process_file() { + local file="$1" + echo "Adding Simple Analytics script to $file" + sed -i "s||$script_content|" "$file" + } + export -f process_file + + # Locate all .html files under the documentation root and use xargs to process in parallel. + find "$path" -name '*.html' | xargs -I {} -P "$(nproc)" bash -c 'process_file "$@"' _ {} +} + upsert_index_page() { # Check if `index-tpl-crud` exists which index-tpl-crud &> /dev/null || yarn global add @substrate/index-tpl-crud @@ -139,6 +155,7 @@ deploy_main() { git fetch --all git checkout -f ${BUILD_RUSTDOC_REF} || { echo "Checkout \`${BUILD_RUSTDOC_REF}\` error." && exit 1; } build_rustdocs "${BUILD_RUSTDOC_REF}" "${DOC_PATH}" + inject_analytic_script "${DOC_PATH}" # git checkout `gh-pages` branch git fetch "${GIT_REMOTE}" gh-pages From 21cc1059e304ba01a0c90f90b51ce2c0d5f2c61a Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Tue, 22 Aug 2023 14:27:02 +0700 Subject: [PATCH 2/2] typo --- .maintain/rustdocs-release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.maintain/rustdocs-release.sh b/.maintain/rustdocs-release.sh index 32f896dfd77e2..90202f2a821b2 100755 --- a/.maintain/rustdocs-release.sh +++ b/.maintain/rustdocs-release.sh @@ -155,7 +155,7 @@ deploy_main() { git fetch --all git checkout -f ${BUILD_RUSTDOC_REF} || { echo "Checkout \`${BUILD_RUSTDOC_REF}\` error." && exit 1; } build_rustdocs "${BUILD_RUSTDOC_REF}" "${DOC_PATH}" - inject_analytic_script "${DOC_PATH}" + inject_analytics_script "${DOC_PATH}" # git checkout `gh-pages` branch git fetch "${GIT_REMOTE}" gh-pages