1
0
mirror of https://github.com/gohugoio/hugo.git synced 2024-05-11 05:54:58 +00:00

media, hugolib: Support extension-less media types

This change is motivated by Netlify's `_redirects` files, which is currently not possible to generate with Hugo.

This commit adds a `Delimiter` field to media type, which defaults to ".", but can be blanked out.

Fixes #3614
This commit is contained in:
Bjørn Erik Pedersen
2017-06-20 08:45:52 +02:00
parent 516e6c6dc5
commit 0f40e1fadf
7 changed files with 183 additions and 34 deletions

View File

@@ -18,6 +18,8 @@ import (
"strings"
"testing"
"github.com/gohugoio/hugo/media"
"fmt"
"github.com/gohugoio/hugo/output"
@@ -27,6 +29,17 @@ func TestPageTargetPath(t *testing.T) {
pathSpec := newTestDefaultPathSpec()
noExtNoDelimMediaType := media.TextType
noExtNoDelimMediaType.Suffix = ""
noExtNoDelimMediaType.Delimiter = ""
// Netlify style _redirects
noExtDelimFormat := output.Format{
Name: "NER",
MediaType: noExtNoDelimMediaType,
BaseName: "_redirects",
}
for _, langPrefix := range []string{"", "no"} {
for _, uglyURLs := range []bool{false, true} {
t.Run(fmt.Sprintf("langPrefix=%q,uglyURLs=%t", langPrefix, uglyURLs),
@@ -40,6 +53,7 @@ func TestPageTargetPath(t *testing.T) {
{"JSON home", targetPathDescriptor{Kind: KindHome, Type: output.JSONFormat}, "/index.json"},
{"AMP home", targetPathDescriptor{Kind: KindHome, Type: output.AMPFormat}, "/amp/index.html"},
{"HTML home", targetPathDescriptor{Kind: KindHome, BaseName: "_index", Type: output.HTMLFormat}, "/index.html"},
{"Netlify redirects", targetPathDescriptor{Kind: KindHome, BaseName: "_index", Type: noExtDelimFormat}, "/_redirects"},
{"HTML section list", targetPathDescriptor{
Kind: KindSection,
Sections: []string{"sect1"},