From be78c532cae22c6f9aeda0ea5b9a78ceabbcf4a7 Mon Sep 17 00:00:00 2001 From: Neko Nekowazarashi Date: Tue, 30 May 2023 21:24:39 +0700 Subject: [PATCH] penambahan fitur untuk sub-jalur --- conf/.env.local | 2 +- scripts/change_url | 12 +++++++++++- scripts/install | 10 ++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/conf/.env.local b/conf/.env.local index ecf0d15..575945f 100644 --- a/conf/.env.local +++ b/conf/.env.local @@ -1 +1 @@ -NEXT_PUBLIC_SITE_DOMAIN=__DOMAIN__ +NEXT_PUBLIC_SITE_DOMAIN=__DOMAIN____PATH__ diff --git a/scripts/change_url b/scripts/change_url index 76feaf2..2994e1d 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -33,7 +33,7 @@ ynh_script_progression --message="Setting the new URL..." --weight=1 if [ $change_domain -eq 1 ] then - ynh_replace_string --match_string="NEXT_PUBLIC_SITE_DOMAIN=$old_domain" --replace_string="NEXT_PUBLIC_SITE_DOMAIN=$new_domain" --target_file="$install_dir/.env.local" + ynh_replace_string --match_string="NEXT_PUBLIC_SITE_DOMAIN=$old_domain$old_path" --replace_string="NEXT_PUBLIC_SITE_DOMAIN=$new_domain$new_path" --target_file="$install_dir/.env.local" fi if [ $change_path -eq 1 ] @@ -53,6 +53,16 @@ then ynh_replace_string --match_string="module.exports = { basePath: '$old_next_path', };" --replace_string="module.exports = { basePath: '$new_next_path', };" --target_file="$install_dir/next.config.js" ynh_replace_string --match_string="src={useColorModeValue(\"$old_next_path/banner_light.svg\", \"$old_next_path/banner_dark.svg\")}" --replace_string="src={useColorModeValue(\"$new_next_path/banner_light.svg\", \"$new_next_path/banner_dark.svg\")}" --target_file="$install_dir/components/Header.tsx" + + ynh_replace_string --match_string="href=\"$old_next_path/favicon" --replace_string="href=\"$new_next_path/favicon" --target_file="$install_dir/components/CustomHead.tsx" + + ynh_replace_string --match_string="href=\"$old_next_path/apple" --replace_string="href=\"$new_next_path/apple" --target_file="$install_dir/components/CustomHead.tsx" + + ynh_replace_string --match_string="start_url\": \"$old_next_path/" --replace_string="start_url\": \"$new_next_path/" --target_file="$install_dir/public/manifest.json" + + ynh_replace_string --match_string="scope\": \"$old_next_path/" --replace_string="scope\": \"$new_next_path/" --target_file="$install_dir/public/manifest.json" + + ynh_replace_string --match_string="src\": \"$old_next_path/favicon" --replace_string="src\": \"$new_next_path/favicon" --target_file="$install_dir/public/manifest.json" fi #================================================= diff --git a/scripts/install b/scripts/install index 541d214..bb537d5 100755 --- a/scripts/install +++ b/scripts/install @@ -58,6 +58,16 @@ echo "module.exports = { basePath: '$next_path', };" >> "$install_dir/next.confi ynh_replace_string --match_string="src={useColorModeValue(\"/banner_light.svg\", \"/banner_dark.svg\")}" --replace_string="src={useColorModeValue(\"$next_path/banner_light.svg\", \"$next_path/banner_dark.svg\")}" --target_file="$install_dir/components/Header.tsx" +ynh_replace_string --match_string="href=\"/favicon" --replace_string="href=\"$next_path/favicon" --target_file="$install_dir/components/CustomHead.tsx" + +ynh_replace_string --match_string="href=\"/apple" --replace_string="href=\"$next_path/apple" --target_file="$install_dir/components/CustomHead.tsx" + +ynh_replace_string --match_string="start_url\": \"/" --replace_string="start_url\": \"$next_path/" --target_file="$install_dir/public/manifest.json" + +ynh_replace_string --match_string="scope\": \"/" --replace_string="scope\": \"$next_path/" --target_file="$install_dir/public/manifest.json" + +ynh_replace_string --match_string="src\": \"/favicon" --replace_string="src\": \"$next_path/favicon" --target_file="$install_dir/public/manifest.json" + #================================================= # BUILD AND INSTALL THE APP #=================================================