Skip to content

Commit

Permalink
Fix markdown file hot reload when layout changes
Browse files Browse the repository at this point in the history
  • Loading branch information
richcorbs committed Oct 8, 2024
1 parent 2280ced commit e04dff9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions build.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func initializeDependencies() error {
file := filepath.Base(path)
ext := filepath.Ext(file)

if ext == ".html" {
if ext == ".html" || ext == ".md" {
content, err := os.ReadFile(path)
if err != nil {
return err
Expand All @@ -209,7 +209,7 @@ func initializeDependencies() error {
foundLayout := false

for _, layout := range layouts {
if strings.HasPrefix(string(content), "<"+layout.Name+"Layout>") && strings.HasSuffix(string(content), "</"+layout.Name+"Layout>") {
if strings.HasPrefix(string(content), "<"+layout.Name+"Layout>") && (strings.HasSuffix(string(content), "</"+layout.Name+"Layout>") || strings.HasSuffix(string(content), "</"+layout.Name+"Layout>\n")) {
foundLayout = true
if !sliceContains(path, dependencies[layout.Path]) {
dependencies[layout.Path] = append(dependencies[layout.Path], path)
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var PORT = "8080"

const DIST = "dist"
const SRC = "./src"
const DEFAULT_LAYOUT = "./src/layouts/Default.html"
const DEFAULT_LAYOUT = "src/layouts/Default.html"

// src
// └── assets
Expand Down

0 comments on commit e04dff9

Please sign in to comment.