mirror of
https://git.sr.ht/~adnano/kiln
synced 2024-10-30 01:13:08 +00:00
Allow specifying multiple site URLs
This commit is contained in:
parent
9990f10f8e
commit
d10b827ac0
|
@ -10,7 +10,7 @@ import (
|
||||||
// Config contains site configuration.
|
// Config contains site configuration.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Title string // site title
|
Title string // site title
|
||||||
URL string // site URL
|
URLs []string // site URLs
|
||||||
Feeds map[string]string // site feeds
|
Feeds map[string]string // site feeds
|
||||||
Templates *Templates // site templates
|
Templates *Templates // site templates
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ func (c *Config) Load(path string) error {
|
||||||
case "title":
|
case "title":
|
||||||
c.Title = value
|
c.Title = value
|
||||||
case "url":
|
case "url":
|
||||||
c.URL = value
|
c.URLs = append(c.URLs, value)
|
||||||
}
|
}
|
||||||
case "feeds":
|
case "feeds":
|
||||||
c.Feeds[key] = value
|
c.Feeds[key] = value
|
||||||
|
@ -50,7 +50,7 @@ func (c *Config) LoadTemplates(path string) error {
|
||||||
// Site contains site metadata passed to templates
|
// Site contains site metadata passed to templates
|
||||||
type Site struct {
|
type Site struct {
|
||||||
Title string
|
Title string
|
||||||
URL string
|
URLs []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load templates
|
// Load templates
|
||||||
|
@ -59,7 +59,7 @@ func (c *Config) LoadTemplates(path string) error {
|
||||||
"site": func() Site {
|
"site": func() Site {
|
||||||
return Site{
|
return Site{
|
||||||
Title: c.Title,
|
Title: c.Title,
|
||||||
URL: c.URL,
|
URLs: c.URLs,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
@ -164,7 +164,12 @@ The following keys are supported:
|
||||||
| title
|
| title
|
||||||
: Site title
|
: Site title
|
||||||
| url
|
| url
|
||||||
: Site URL. Should not end with a trailing slash.
|
: Site URL.
|
||||||
|
|
||||||
|
Site URLs are only used when generating Atom feeds.
|
||||||
|
Site URLs should not end with a trailing slash.
|
||||||
|
More than one site URL may be specified by specifying multiple url keys.
|
||||||
|
This allows a site that is hosted on both Gemini and HTTP to specify URLs for both locations.
|
||||||
|
|
||||||
The following sections are supported:
|
The following sections are supported:
|
||||||
|
|
||||||
|
|
11
templates.go
11
templates.go
|
@ -99,15 +99,18 @@ const output_html = `<!DOCTYPE html>
|
||||||
// Default atom feed template
|
// Default atom feed template
|
||||||
const atom_xml = `<?xml version="1.0" encoding="utf-8"?>
|
const atom_xml = `<?xml version="1.0" encoding="utf-8"?>
|
||||||
<feed xmlns="http://www.w3.org/2005/Atom">
|
<feed xmlns="http://www.w3.org/2005/Atom">
|
||||||
<id>{{ site.URL }}{{ .Path }}</id>
|
<id>{{ index site.URLs 0 }}{{ .Path }}</id>
|
||||||
<title>{{ .Title }}</title>
|
<title>{{ .Title }}</title>
|
||||||
<updated>{{ .Updated.Format "2006-01-02T15:04:05Z07:00" }}</updated>
|
<updated>{{ .Updated.Format "2006-01-02T15:04:05Z07:00" }}</updated>
|
||||||
<link href="{{ site.URL }}{{ .Path }}" rel="alternate">
|
<link href="{{ index site.URLs 0 }}{{ .Path }}" rel="alternate">
|
||||||
{{ range .Entries }}<entry>
|
{{ range .Entries }}<entry>
|
||||||
<id>{{ site.URL }}{{ .Path }}</id>
|
<id>{{ index site.URLs 0 }}{{ .Path }}</id>
|
||||||
<title>{{ .Title }}</title>
|
<title>{{ .Title }}</title>
|
||||||
<updated>{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}</updated>
|
<updated>{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}</updated>
|
||||||
<link href="{{ site.URL }}{{ .Path }}" rel="alternate">
|
{{- $path := .Path }}
|
||||||
|
{{- range site.URLs }}
|
||||||
|
<link href="{{ . }}{{ $path }}" rel="alternate">
|
||||||
|
{{- end }}
|
||||||
</entry>
|
</entry>
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
</feed>`
|
</feed>`
|
||||||
|
|
|
@ -1,14 +1,17 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<feed xmlns="http://www.w3.org/2005/Atom">
|
<feed xmlns="http://www.w3.org/2005/Atom">
|
||||||
<id>{{ site.URL }}{{ .Path }}</id>
|
<id>{{ index site.URLs 0 }}{{ .Path }}</id>
|
||||||
<title>{{ .Title }}</title>
|
<title>{{ .Title }}</title>
|
||||||
<updated>{{ .Updated.Format "2006-01-02T15:04:05Z07:00" }}</updated>
|
<updated>{{ .Updated.Format "2006-01-02T15:04:05Z07:00" }}</updated>
|
||||||
<link href="{{ site.URL }}{{ .Path }}" rel="alternate">
|
<link href="{{ index site.URLs 0 }}{{ .Path }}" rel="alternate">
|
||||||
{{ range .Entries }}<entry>
|
{{ range .Entries }}<entry>
|
||||||
<id>{{ site.URL }}{{ .Path }}</id>
|
<id>{{ index site.URLs 0 }}{{ .Path }}</id>
|
||||||
<title>{{ .Title }}</title>
|
<title>{{ .Title }}</title>
|
||||||
<updated>{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}</updated>
|
<updated>{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}</updated>
|
||||||
<link href="{{ site.URL }}{{ .Path }}" rel="alternate">
|
{{- $path := .Path }}
|
||||||
|
{{- range site.URLs }}
|
||||||
|
<link href="{{ . }}{{ $path }}" rel="alternate">
|
||||||
|
{{- end }}
|
||||||
</entry>
|
</entry>
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
</feed>
|
</feed>
|
||||||
|
|
Loading…
Reference in a new issue