From 3e6c69d48a9b1e3cea38efa68932f5f02ef1c311 Mon Sep 17 00:00:00 2001 From: adnano Date: Tue, 29 Sep 2020 11:33:17 -0400 Subject: [PATCH] Remove paths from pages and directories --- README.md | 5 +---- kiln.go | 9 +-------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 03b072b..a0c3ced 100644 --- a/README.md +++ b/README.md @@ -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/ ``` diff --git a/kiln.go b/kiln.go index 2390d12..4913767 100644 --- a/kiln.go +++ b/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, } }