Fixed some bugs around paths and templates

This commit is contained in:
Leon Mika 2026-02-08 10:50:39 +11:00
parent b84425251a
commit 984257fb41
2 changed files with 5 additions and 4 deletions

View file

@ -2,9 +2,9 @@ package progdoc
import ( import (
"bytes" "bytes"
"html/template"
"io" "io"
"os" "os"
"text/template"
"github.com/yuin/goldmark" "github.com/yuin/goldmark"
"github.com/yuin/goldmark/extension" "github.com/yuin/goldmark/extension"

View file

@ -2,11 +2,11 @@ package progdoc
import ( import (
"bytes" "bytes"
"html/template"
"log" "log"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
"text/template"
) )
func Path(path string) PathBuilder { func Path(path string) PathBuilder {
@ -59,6 +59,7 @@ func (pb PathBuilder) GoFiles(dir, templateFile string) Option {
if err != nil { if err != nil {
return nil return nil
} }
targetPath := filepath.Join(pb.path, relPath)
absName, err := filepath.Abs(path) absName, err := filepath.Abs(path)
if err != nil { if err != nil {
@ -81,7 +82,7 @@ func (pb PathBuilder) GoFiles(dir, templateFile string) Option {
} }
sm.Pages = append(sm.Pages, sitePage{ sm.Pages = append(sm.Pages, sitePage{
Path: relPath, Path: targetPath,
Source: stdLayoutSource{ Source: stdLayoutSource{
MainSource: mdTemplateSource{ MainSource: mdTemplateSource{
Template: tmpl, Template: tmpl,
@ -120,7 +121,7 @@ func (pb PathBuilder) Dir(dir string) Option {
log.Printf("Page '%s' -> %s", targetPath, path) log.Printf("Page '%s' -> %s", targetPath, path)
sm.Pages = append(sm.Pages, sitePage{ sm.Pages = append(sm.Pages, sitePage{
Path: relPath, Path: targetPath,
Source: stdLayoutSource{MainSource: src}, Source: stdLayoutSource{MainSource: src},
}) })
} }