Skip to content

Commit 2dad10c

Browse files
committed
Fix panic when changing archetype files when servere is running
Fixes gohugoio#12195
1 parent dc6a292 commit 2dad10c

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

hugolib/hugo_sites_build.go

+2
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,8 @@ func (h *HugoSites) processPartial(ctx context.Context, l logg.LevelLogger, conf
792792
// It's hard to determine the exact change set of this,
793793
// so be very coarse grained for now.
794794
changes = append(changes, identity.GenghisKhan)
795+
case files.ComponentFolderArchetypes:
796+
// Ignore for now.
795797
default:
796798
panic(fmt.Sprintf("unknown component: %q", pathInfo.Component()))
797799
}

hugolib/rebuild_test.go

+18
Original file line numberDiff line numberDiff line change
@@ -1472,3 +1472,21 @@ all: {{ $ab.RelPermalink }}
14721472
b.AddFiles("assets/common/c3.css", "c3").Build()
14731473
b.AssertFileContent("public/ab.css", "abc1c2 editedc3")
14741474
}
1475+
1476+
func TestRebuildEditArchetypeFile(t *testing.T) {
1477+
t.Parallel()
1478+
1479+
files := `
1480+
-- hugo.toml --
1481+
baseURL = "https://example.com"
1482+
disableLiveReload = true
1483+
-- archetypes/default.md --
1484+
---
1485+
title: "Default"
1486+
---
1487+
`
1488+
1489+
b := TestRunning(t, files)
1490+
// Just make sure that it doesn't panic.
1491+
b.EditFileReplaceAll("archetypes/default.md", "Default", "Default Edited").Build()
1492+
}

0 commit comments

Comments
 (0)