diff --git a/.static-pages.yml b/.static-pages.yml new file mode 100644 index 0000000..679bbe9 --- /dev/null +++ b/.static-pages.yml @@ -0,0 +1,4 @@ +site_name: frog-collective.com +build_command: nox -r -s build +build_directory: build + diff --git a/config/.htaccess b/config/.htaccess new file mode 100644 index 0000000..6920183 --- /dev/null +++ b/config/.htaccess @@ -0,0 +1,14 @@ +Options -Indexes -MultiViews + +# Rewrite urls depending on the Accept-Language header if present, except for +# assets. +RewriteEngine on + +RewriteRule \.(css|js|jpg|png|gif|woff|woff2)$ - [NC,L] + +RewriteCond %{HTTP:Accept-Language} ^(fr) [NC] +RewriteCond %{REQUEST_URI} !^/(fr|en)/ +RewriteRule (.*) /fr/$1 [L,R=301] + +RewriteCond %{REQUEST_URI} !^/(fr|en)/ +RewriteRule (.*) /en/$1 [L,R=301] diff --git a/noxfile.py b/noxfile.py index e9219fc..d9881eb 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,7 +1,7 @@ """Nox configuration file.""" from pathlib import Path from tempfile import TemporaryDirectory -from shutil import copytree +from shutil import copytree, copy from nox import Session, session @@ -38,6 +38,7 @@ def build(session: Session) -> None: session.log("Copying static files to build directory...") copytree("src/assets", "build", dirs_exist_ok=True) + copy("config/.htaccess", "build") with TemporaryDirectory() as locale_dir: for locale in _LOCALES: