hugo/commands
Bjørn Erik Pedersen 029d1e0ced Add some more server options/improvements
New options:

* `FromHeaders`: Server header matching for redirects
* `FromRe`: Regexp with group support, i.e. it replaces $1, $2 in To with the group matches.

Note that if both `From` and `FromRe` is set, both must match.

Also

* Allow redirects to non HTML URLs as long as the Sec-Fetch-Mode is set to navigate on the request.
* Detect and stop redirect loops.

This was all done while testing out InertiaJS with Hugo. So, after this commit, this setup will support the main parts of the protocol that Inertia uses:

```toml
[server]
    [[server.headers]]
        for = '/**/inertia.json'
        [server.headers.values]
            Content-Type = 'text/html'
            X-Inertia    = 'true'
            Vary         = 'Accept'

    [[server.redirects]]
        force       = true
        from        = '/**/'
        fromRe      = "^/(.*)/$"
        fromHeaders = { "X-Inertia" = "true" }
        status      = 301
        to          = '/$1/inertia.json'
```

Unfortunately, a provider like Netlify does not support redirects matching by request headers. It should be possible with some edge function, but then again, I'm not sure that InertiaJS is a very good fit with the common Hugo use cases.

But this commit should be generally useful.
2025-02-05 18:14:15 +01:00
..
commandeer.go commands: Fix spelling in comment 2025-01-15 22:31:52 +01:00
commands.go commands: Add "hugo build" as an alias for "hugo" 2024-09-30 10:36:29 +02:00
config.go commands: Add --printZero to the config command 2025-01-15 22:48:14 +02:00
convert.go commands: Use consistent style when describing subcommands 2024-10-15 08:51:53 +02:00
deploy.go commands: Print the "deploy not available" error message even if flags provided 2024-11-05 11:40:42 +01:00
deploy_flags.go commands: Print the "deploy not available" error message even if flags provided 2024-11-05 11:40:42 +01:00
deploy_off.go commands: Print the "deploy not available" error message even if flags provided 2024-11-05 11:40:42 +01:00
env.go commands: Use consistent style when describing subcommands 2024-10-15 08:51:53 +02:00
gen.go Print cli usage of hugo gen chromastyles alongside css 2024-12-30 15:06:35 +01:00
helpers.go all: Rework page store, add a dynacache, improve partial rebuilds, and some general spring cleaning 2024-01-27 16:28:14 +01:00
hugo_windows.go all: Rework page store, add a dynacache, improve partial rebuilds, and some general spring cleaning 2024-01-27 16:28:14 +01:00
hugobuilder.go Fix some server rebuild issues for non-HTML custom output formats 2025-01-24 17:27:02 +01:00
import.go commands: Use consistent style when describing subcommands 2024-10-15 08:51:53 +02:00
list.go Write all logging (INFO, WARN, ERROR) to stderr 2024-12-13 09:23:09 +01:00
mod.go commands: Use consistent style when describing subcommands 2024-10-15 08:51:53 +02:00
new.go commands: Use consistent style when describing subcommands 2024-10-15 08:51:53 +02:00
release.go completion: Improve existing argument completions, add many more 2024-04-11 15:34:26 +02:00
server.go Add some more server options/improvements 2025-02-05 18:14:15 +01:00