mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-16 20:53:59 +02:00
Fix some server rebuild issues for non-HTML custom output formats
The failing test case here is * A custom search output format defined on the home page, marked as `noAlternative` and not `permalinkable` * In fast render mode, when making a change to a data source for that search output format, the JSON file was not refreshed. There are variants of the above, but the gist of it is: * The change set was correctly determined, but since the search JSON file was not in the recently visited browser stack, we skipped rendering it. Running with `hugo server --disableFastRender` would be a workaround for the above. This commit fixes this by: * Adding a check for the HTTP request header `Sec-Fetch-Mode = navigation` to the condition for if we should track server request as a user navigation (and not e.g. a HTTP request for a linked CSS stylesheet). * Making sure that we compare against the real relative URL for non-permalinkable output formats. Fixes #13014
This commit is contained in:
@@ -357,8 +357,8 @@ RegularPages: {{ range .Site.RegularPages }}{{ .RelPermalink }}|{{ end }}$
|
||||
}
|
||||
|
||||
func TestRebuildRenameDirectoryWithBranchBundleFastRender(t *testing.T) {
|
||||
recentlyVisited := types.NewEvictingStringQueue(10).Add("/a/b/c/")
|
||||
b := TestRunning(t, rebuildFilesSimple, func(cfg *IntegrationTestConfig) { cfg.BuildCfg = BuildCfg{RecentlyVisited: recentlyVisited} })
|
||||
recentlyVisited := types.NewEvictingQueue[string](10).Add("/a/b/c/")
|
||||
b := TestRunning(t, rebuildFilesSimple, func(cfg *IntegrationTestConfig) { cfg.BuildCfg = BuildCfg{RecentlyTouched: recentlyVisited} })
|
||||
b.RenameDir("content/mysection", "content/mysectionrenamed").Build()
|
||||
b.AssertFileContent("public/mysectionrenamed/index.html", "My Section")
|
||||
b.AssertFileContent("public/mysectionrenamed/mysectionbundle/index.html", "My Section Bundle")
|
||||
@@ -1181,6 +1181,49 @@ Content: {{ .Content }}
|
||||
b.AssertFileContent("public/index.html", "Content: <p>Home</p>")
|
||||
}
|
||||
|
||||
// Issue #13014.
|
||||
func TestRebuildEditNotPermalinkableCustomOutputFormatTemplateInFastRenderMode(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- hugo.toml --
|
||||
baseURL = "https://example.com/docs/"
|
||||
disableLiveReload = true
|
||||
[internal]
|
||||
fastRenderMode = true
|
||||
disableKinds = ["taxonomy", "term", "sitemap", "robotsTXT", "404"]
|
||||
[outputFormats]
|
||||
[outputFormats.SearchIndex]
|
||||
baseName = 'Search'
|
||||
isPlainText = true
|
||||
mediaType = 'text/plain'
|
||||
noAlternative = true
|
||||
permalinkable = false
|
||||
|
||||
[outputs]
|
||||
home = ['HTML', 'SearchIndex']
|
||||
-- content/_index.md --
|
||||
---
|
||||
title: "Home"
|
||||
---
|
||||
Home.
|
||||
-- layouts/index.html --
|
||||
Home.
|
||||
-- layouts/_default/index.searchindex.txt --
|
||||
Text. {{ .Title }}|{{ .RelPermalink }}|
|
||||
|
||||
`
|
||||
b := TestRunning(t, files, TestOptInfo())
|
||||
|
||||
b.AssertFileContent("public/search.txt", "Text.")
|
||||
|
||||
b.EditFileReplaceAll("layouts/_default/index.searchindex.txt", "Text.", "Text Edited.").Build()
|
||||
|
||||
b.BuildPartial("/docs/search.txt")
|
||||
|
||||
b.AssertFileContent("public/search.txt", "Text Edited.")
|
||||
}
|
||||
|
||||
func TestRebuildVariationsAssetsJSImport(t *testing.T) {
|
||||
t.Parallel()
|
||||
files := `
|
||||
|
Reference in New Issue
Block a user