Remove paths from pages and directories

This commit is contained in:
adnano 2020-09-29 11:33:17 -04:00
parent 772b801eea
commit 3e6c69d48a
2 changed files with 2 additions and 12 deletions

View file

@ -38,19 +38,16 @@ Running `kiln` takes the contents in `src`, runs them through the templates in
## Permalinks ## Permalinks
Every page and directory in the site is assigned a path and a permalink. Every page and directory in the site is assigned a permalink.
Paths are relative and point to the source file.
Permalinks are absolute and point to the destination file. Permalinks are absolute and point to the destination file.
Examples: Examples:
``` ```
file: src/posts/2020-09-22-hello-world.gmi file: src/posts/2020-09-22-hello-world.gmi
path: posts/2020-09-22-hello-world.gmi
permalink: /posts/hello-world/ permalink: /posts/hello-world/
directory: src/posts/ directory: src/posts/
path: posts
permalink: /posts/ permalink: /posts/
``` ```

View file

@ -81,7 +81,7 @@ func (s *Site) Write(dstDir string, format OutputFormat) error {
func (s *Site) Manipulate(dir *Directory) error { func (s *Site) Manipulate(dir *Directory) error {
// Write the directory index file, if it doesn't exist // Write the directory index file, if it doesn't exist
if dir.Index == nil { if dir.Index == nil {
path := filepath.Join(dir.Path, "index.gmi") path := filepath.Join(dir.Permalink, "index.gmi")
var b bytes.Buffer var b bytes.Buffer
tmpl := s.Templates.Lookup("index.gmi") tmpl := s.Templates.Lookup("index.gmi")
if tmpl != nil { if tmpl != nil {
@ -94,7 +94,6 @@ func (s *Site) Manipulate(dir *Directory) error {
permalink = "" permalink = ""
} }
page := &Page{ page := &Page{
Path: path,
Permalink: "/" + permalink, Permalink: "/" + permalink,
content: content, content: content,
} }
@ -122,8 +121,6 @@ func (s *Site) Sort() {
// Page represents a page. // Page represents a page.
type Page struct { type Page struct {
// The path to this page.
Path string
// The permalink to this page. // The permalink to this page.
Permalink string Permalink string
// The title of this page, parsed from the Gemini contents. // 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") permalink := strings.TrimSuffix(path, ".gmi")
return &Page{ return &Page{
Path: path,
Permalink: "/" + permalink + "/", Permalink: "/" + permalink + "/",
Title: title, Title: title,
Date: date, Date: date,
@ -190,8 +186,6 @@ func NewPage(path string, content []byte) *Page {
// Directory represents a directory of pages. // Directory represents a directory of pages.
type Directory struct { type Directory struct {
// The path to this directory.
Path string
// The permalink to this directory. // The permalink to this directory.
Permalink string Permalink string
// The pages in this directory. // The pages in this directory.
@ -211,7 +205,6 @@ func NewDirectory(path string) *Directory {
permalink = "/" + path + "/" permalink = "/" + path + "/"
} }
return &Directory{ return &Directory{
Path: path,
Permalink: permalink, Permalink: permalink,
} }
} }