#!/bin/bash
cd $REPO_DIR/cdn/public/all_in_one

############################# Javascript

rm all.min.js all.defer.min.js
touch all.min.js all.defer.min.js

# jquery does not defer well at all, even nested as is
# wget -O - https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js >> all.min.js
# echo "" >> all.min.js
# echo "" >> all.min.js

wget -O - https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.2/js/bootstrap.bundle.min.js | grep -v '^//' >> all.min.js
echo "" >> all.min.js
echo "" >> all.min.js

wget -O - https://cdnjs.cloudflare.com/ajax/libs/algoliasearch/3.34.0/algoliasearch.min.js | grep -v '^//' >> all.defer.min.js
echo "" >> all.defer.min.js
echo "" >> all.defer.min.js

wget -O - https://cdnjs.cloudflare.com/ajax/libs/autocomplete.js/0.38.0/autocomplete.min.js | grep -v '^//' >> all.min.js
echo "" >> all.min.js
echo "" >> all.min.js

wget -O - https://cdnjs.cloudflare.com/ajax/libs/smooth-scroll/16.1.3/smooth-scroll.min.js | grep -v '^//' >> all.defer.min.js
echo "" >> all.defer.min.js
echo "" >> all.defer.min.js

wget -O - https://legalio-cdn.imgix.net/around-3.0.0/assets/js/theme.min.js >> all.defer.min.js
echo "" >> all.defer.min.js
echo "" >> all.defer.min.js

cat ~/cdn/public/js/js_nav_active.js | grep -v '^//' >> all.defer.min.js
echo "" >> all.defer.min.js
echo "" >> all.defer.min.js

############################# CSS

# rm all.min.css
# touch all.min.css
#

# This is duplicated in around-2.4.0 theme.min.css
# wget -O - https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.2/css/bootstrap.min.css >> all.min.css
# echo "" >> all.min.css
# echo "" >> all.min.css

# Relative URL's don't work out.
# wget -O - https://pro.fontawesome.com/releases/v5.15.4/css/all.css >> all.min.css
# https://pro.fontawesome.com/releases/v5.15.4/webfonts/fa-regular-400.woff2
# url(../webfonts/fa-solid-900.woff2
# cat ~/cdn/public/all_in_one/font-awesome.css >> all.min.css
# echo "" >> all.min.css
# echo "" >> all.min.css

# wget -O - https://legalio-cdn.imgix.net/around-2.4.0/css/theme.min.css >> all.min.css
# https://legalio-cdn.imgix.net/around-2.4.0/fonts/around-icons.ttf?enmnv5
#
#
#  Warning place the import at the top of the all.min.css file!
#
# @import
# echo "@import url(\"https://fonts.googleapis.com/css?family=Inter:300,400,500,600,700&display=swap\");" >> all.min.css
# echo "" >> all.min.css
#
#
# url("../fonts/around-icons.ttf?enmnv5"
# WARNING: First line has a @import see lines above
# cat ~/cdn/public/around-2.4.0/css/no-import-theme.min.css >> all.min.css
# echo "" >> all.min.css
# echo "" >> all.min.css

# variables in
# cat ~/cdn/public/css/variables.css >> all.min.css
# echo "" >> all.min.css
# echo "" >> all.min.css
