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.
|
||||
type Config struct {
|
||||
Title string // site title
|
||||
URL string // site URL
|
||||
URLs []string // site URLs
|
||||
Feeds map[string]string // site feeds
|
||||
Templates *Templates // site templates
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ func (c *Config) Load(path string) error {
|
|||
case "title":
|
||||
c.Title = value
|
||||
case "url":
|
||||
c.URL = value
|
||||
c.URLs = append(c.URLs, value)
|
||||
}
|
||||
case "feeds":
|
||||
c.Feeds[key] = value
|
||||
|
@ -50,7 +50,7 @@ func (c *Config) LoadTemplates(path string) error {
|
|||
// Site contains site metadata passed to templates
|
||||
type Site struct {
|
||||
Title string
|
||||
URL string
|
||||
URLs []string
|
||||
}
|
||||
|
||||
// Load templates
|
||||
|
@ -59,7 +59,7 @@ func (c *Config) LoadTemplates(path string) error {
|
|||
"site": func() Site {
|
||||
return Site{
|
||||
Title: c.Title,
|
||||
URL: c.URL,
|
||||
URLs: c.URLs,
|
||||
}
|
||||
},
|
||||
})
|
||||
|
|
|
@ -164,7 +164,12 @@ The following keys are supported:
|
|||
| title
|
||||
: Site title
|
||||
| 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:
|
||||
|
||||
|
|
11
templates.go
11
templates.go
|
@ -99,15 +99,18 @@ const output_html = `<!DOCTYPE html>
|
|||
// Default atom feed template
|
||||
const atom_xml = `<?xml version="1.0" encoding="utf-8"?>
|
||||
<feed xmlns="http://www.w3.org/2005/Atom">
|
||||
<id>{{ site.URL }}{{ .Path }}</id>
|
||||
<id>{{ index site.URLs 0 }}{{ .Path }}</id>
|
||||
<title>{{ .Title }}</title>
|
||||
<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>
|
||||
<id>{{ site.URL }}{{ .Path }}</id>
|
||||
<id>{{ index site.URLs 0 }}{{ .Path }}</id>
|
||||
<title>{{ .Title }}</title>
|
||||
<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>
|
||||
{{ end -}}
|
||||
</feed>`
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<feed xmlns="http://www.w3.org/2005/Atom">
|
||||
<id>{{ site.URL }}{{ .Path }}</id>
|
||||
<id>{{ index site.URLs 0 }}{{ .Path }}</id>
|
||||
<title>{{ .Title }}</title>
|
||||
<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>
|
||||
<id>{{ site.URL }}{{ .Path }}</id>
|
||||
<id>{{ index site.URLs 0 }}{{ .Path }}</id>
|
||||
<title>{{ .Title }}</title>
|
||||
<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>
|
||||
{{ end -}}
|
||||
</feed>
|
||||
|
|
Loading…
Reference in a new issue