Skip to content

Commit

Permalink
fix: dual processing of html files
Browse files Browse the repository at this point in the history
avoid processing the html file again
  • Loading branch information
barelyhuman committed Sep 9, 2023
1 parent bba718e commit 3c21b88
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,15 @@ func main() {
fileName := strings.Replace(toProcessItem, pagesPath, "", 1)
fileName = prefixSlashPath.ReplaceAllString(fileName, "")
destFilePath := strings.Replace(toProcessItem, pagesPath, outPath, 1)
isHTML := strings.HasSuffix(fileName, ".html")

alvuFile := &AlvuFile{
lock: &sync.Mutex{},
sourcePath: toProcessItem,
hooks: hookCollection,
destPath: destFilePath,
name: fileName,
isHTML: isHTML,
headFile: headFileFd,
tailFile: tailFileFd,
baseTemplate: baseFileFd,
Expand Down Expand Up @@ -443,6 +445,7 @@ type AlvuFile struct {
hooks HookCollection
name string
sourcePath string
isHTML bool
destPath string
meta map[string]interface{}
content []byte
Expand Down Expand Up @@ -633,8 +636,12 @@ func (af *AlvuFile) FlushFile() {
bail(err)

var toHtml bytes.Buffer
err = mdProcessor.Convert(preConvertHTML.Bytes(), &toHtml)
bail(err)
if !af.isHTML {
err = mdProcessor.Convert(preConvertHTML.Bytes(), &toHtml)
bail(err)
} else {
toHtml = preConvertHTML
}

layoutData := LayoutRenderData{
PageRenderData: renderData,
Expand Down

0 comments on commit 3c21b88

Please sign in to comment.