mirror of
https://git.sr.ht/~adnano/kiln
synced 2024-10-30 01:13:08 +00:00
Remove paths from pages and directories
This commit is contained in:
parent
772b801eea
commit
3e6c69d48a
|
@ -38,19 +38,16 @@ Running `kiln` takes the contents in `src`, runs them through the templates in
|
|||
|
||||
## Permalinks
|
||||
|
||||
Every page and directory in the site is assigned a path and a permalink.
|
||||
Paths are relative and point to the source file.
|
||||
Every page and directory in the site is assigned a permalink.
|
||||
Permalinks are absolute and point to the destination file.
|
||||
|
||||
Examples:
|
||||
|
||||
```
|
||||
file: src/posts/2020-09-22-hello-world.gmi
|
||||
path: posts/2020-09-22-hello-world.gmi
|
||||
permalink: /posts/hello-world/
|
||||
|
||||
directory: src/posts/
|
||||
path: posts
|
||||
permalink: /posts/
|
||||
```
|
||||
|
||||
|
|
9
kiln.go
9
kiln.go
|
@ -81,7 +81,7 @@ func (s *Site) Write(dstDir string, format OutputFormat) error {
|
|||
func (s *Site) Manipulate(dir *Directory) error {
|
||||
// Write the directory index file, if it doesn't exist
|
||||
if dir.Index == nil {
|
||||
path := filepath.Join(dir.Path, "index.gmi")
|
||||
path := filepath.Join(dir.Permalink, "index.gmi")
|
||||
var b bytes.Buffer
|
||||
tmpl := s.Templates.Lookup("index.gmi")
|
||||
if tmpl != nil {
|
||||
|
@ -94,7 +94,6 @@ func (s *Site) Manipulate(dir *Directory) error {
|
|||
permalink = ""
|
||||
}
|
||||
page := &Page{
|
||||
Path: path,
|
||||
Permalink: "/" + permalink,
|
||||
content: content,
|
||||
}
|
||||
|
@ -122,8 +121,6 @@ func (s *Site) Sort() {
|
|||
|
||||
// Page represents a page.
|
||||
type Page struct {
|
||||
// The path to this page.
|
||||
Path string
|
||||
// The permalink to this page.
|
||||
Permalink string
|
||||
// The title of this page, parsed from the Gemini contents.
|
||||
|
@ -180,7 +177,6 @@ func NewPage(path string, content []byte) *Page {
|
|||
permalink := strings.TrimSuffix(path, ".gmi")
|
||||
|
||||
return &Page{
|
||||
Path: path,
|
||||
Permalink: "/" + permalink + "/",
|
||||
Title: title,
|
||||
Date: date,
|
||||
|
@ -190,8 +186,6 @@ func NewPage(path string, content []byte) *Page {
|
|||
|
||||
// Directory represents a directory of pages.
|
||||
type Directory struct {
|
||||
// The path to this directory.
|
||||
Path string
|
||||
// The permalink to this directory.
|
||||
Permalink string
|
||||
// The pages in this directory.
|
||||
|
@ -211,7 +205,6 @@ func NewDirectory(path string) *Directory {
|
|||
permalink = "/" + path + "/"
|
||||
}
|
||||
return &Directory{
|
||||
Path: path,
|
||||
Permalink: permalink,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue