Commit 2fdeddef authored by Marien Fressinaud's avatar Marien Fressinaud

Accept "filesystem" as a value for SITE_URL

When building a generic template, we may need to use absolute URLs. If
we can use `SITE_URL` in production, it can cause problems when building
in development.

By setting `SITE_URL` to `filesystem`, the URL will be replaced by the
filesystem output directory (e.g. `file://path/to/output`) so the
browser will open the correct file.
parent fa2f5f47
......@@ -186,7 +186,8 @@ timezone: Europe/Paris
```
You can declare as many variables as you want, they all will be accessible in
the article template, uppercased and prepended by `SITE_`.
the article template, uppercased and prepended by `SITE_`. `url` can be set to
`filesystem` for development (it will generate paths to the output directory).
You might find yourself limited by the article-only system. If you want to
create additional pages, just put HTML files under a `pages` folder. The
......
......@@ -179,7 +179,7 @@ def main():
# Load the configuration (it can be overidden by a configuration.yml file)
configuration = {
"SITE_URL": "http://localhost",
"SITE_URL": "filesystem",
"SITE_TITLE": "A website",
"SITE_TIMEZONE": "UTC",
}
......@@ -197,6 +197,8 @@ def main():
)
if "SITE_AUTHOR" not in configuration:
configuration["SITE_AUTHOR"] = f"{configuration['SITE_TITLE']}'s author"
if configuration["SITE_URL"] == "filesystem":
configuration["SITE_URL"] = f"file://{os.path.abspath(output_path)}/"
# List files from ./articles
articles = []
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment