#!/bin/sh

# This script will populate the content repository with the actual Astro website/template, so it can be run/previewd locally.


TEMPLATE_DOWNLOAD_URL=https://gitlab.fabcity.hamburg/fcos-suite/fcos-suite-astro/-/archive/main/fcos-suite-astro-main.zip
TEMPLATE_FILENAME=template.zip

echo "Downloading Astro template from $TEMPLATE_DOWNLOAD_URL to $TEMPLATE_FILENAME"
curl --progress-bar $TEMPLATE_DOWNLOAD_URL -o $TEMPLATE_FILENAME

echo "Extracting $TEMPLATE_FILENAME"
unzip -q -o $TEMPLATE_FILENAME

echo "Deleting archive $TEMPLATE_FILENAME"
rm $TEMPLATE_FILENAME

echo "Copying template files into root folder"
# Copy all files from the template repo, except Content Markdown files (already in working dir)
rsync -va --exclude="src/pages/**/*.md" --exclude="src/pages/**/*.mdx" --exclude="src/content/**/*.md" --exclude="src/content/**/*.mdx" --exclude="public" --exclude ".git" fcos-suite-astro-main/ .

echo "Deleting template folder"
rm -rf fcos-suite-astro-main