@@ -21,8 +21,13 @@ const rebuildFilesSimple = `
21
21
baseURL = "https://example.com"
22
22
disableKinds = ["term", "taxonomy", "sitemap", "robotstxt", "404"]
23
23
disableLiveReload = true
24
+ [outputFormats]
25
+ [outputFormats.rss]
26
+ weight = 10
27
+ [outputFormats.html]
28
+ weight = 20
24
29
[outputs]
25
- home = ["html"]
30
+ home = ["rss", " html"]
26
31
section = ["html"]
27
32
page = ["html"]
28
33
-- content/mysection/_index.md --
@@ -58,6 +63,21 @@ Home Text Content.
58
63
title: "myothersectionpage"
59
64
---
60
65
myothersectionpage Content.
66
+ -- content/mythirdsection/mythirdsectionpage.md --
67
+ ---
68
+ title: "mythirdsectionpage"
69
+ ---
70
+ mythirdsectionpage Content.
71
+ {{< myshortcodetext >}}
72
+ §§§ myothertext
73
+ foo
74
+ §§§
75
+ -- assets/mytext.txt --
76
+ Assets My Text.
77
+ -- assets/myshortcodetext.txt --
78
+ Assets My Shortcode Text.
79
+ -- assets/myothertext.txt --
80
+ Assets My Other Text.
61
81
-- layouts/_default/single.html --
62
82
Single: {{ .Title }}|{{ .Content }}$
63
83
Resources: {{ range $i, $e := .Resources }}{{ $i }}:{{ .RelPermalink }}|{{ .Content }}|{{ end }}$
@@ -68,6 +88,13 @@ Len Resources: {{ len .Resources }}|
68
88
Resources: {{ range $i, $e := .Resources }}{{ $i }}:{{ .RelPermalink }}|{{ .Content }}|{{ end }}$
69
89
-- layouts/shortcodes/foo.html --
70
90
Foo.
91
+ -- layouts/shortcodes/myshortcodetext.html --
92
+ {{ warnf "mytext %s" now}}
93
+ {{ $r := resources.Get "myshortcodetext.txt" }}
94
+ My Shortcode Text: {{ $r.Content }}|{{ $r.Permalink }}|
95
+ -- layouts/_default/_markup/render-codeblock-myothertext.html --
96
+ {{ $r := resources.Get "myothertext.txt" }}
97
+ My Other Text: {{ $r.Content }}|{{ $r.Permalink }}|
71
98
72
99
`
73
100
@@ -83,6 +110,34 @@ func TestRebuildEditTextFileInLeafBundle(t *testing.T) {
83
110
b .AssertRenderCountContent (1 )
84
111
}
85
112
113
+ func TestRebuildEditTextFileInShortcode (t * testing.T ) {
114
+ t .Parallel ()
115
+ for i := 0 ; i < 3 ; i ++ {
116
+ b := TestRunning (t , rebuildFilesSimple )
117
+ b .AssertFileContent ("public/mythirdsection/mythirdsectionpage/index.html" ,
118
+ "Text: Assets My Shortcode Text." )
119
+ b .EditFileReplaceAll ("assets/myshortcodetext.txt" , "My Shortcode Text" , "My Shortcode Text Edited" ).Build ()
120
+ fmt .Println (b .LogString ())
121
+ b .AssertFileContent ("public/mythirdsection/mythirdsectionpage/index.html" ,
122
+ "Text: Assets My Shortcode Text Edited." )
123
+
124
+ }
125
+ }
126
+
127
+ func TestRebuildEditTextFileInHook (t * testing.T ) {
128
+ t .Parallel ()
129
+ for i := 0 ; i < 3 ; i ++ {
130
+ b := TestRunning (t , rebuildFilesSimple )
131
+ b .AssertFileContent ("public/mythirdsection/mythirdsectionpage/index.html" ,
132
+ "Text: Assets My Other Text." )
133
+ b .AssertFileContent ("public/myothertext.txt" , "Assets My Other Text." )
134
+ b .EditFileReplaceAll ("assets/myothertext.txt" , "My Other Text" , "My Other Text Edited" ).Build ()
135
+ b .AssertFileContent ("public/mythirdsection/mythirdsectionpage/index.html" ,
136
+ "Text: Assets My Other Text Edited." )
137
+
138
+ }
139
+ }
140
+
86
141
func TestRebuiEditUnmarshaledYamlFileInLeafBundle (t * testing.T ) {
87
142
files := `
88
143
-- hugo.toml --
@@ -140,8 +195,8 @@ func TestRebuildRenameTextFileInLeafBundle(t *testing.T) {
140
195
141
196
b .RenameFile ("content/mysection/mysectionbundle/mysectionbundletext.txt" , "content/mysection/mysectionbundle/mysectionbundletext2.txt" ).Build ()
142
197
b .AssertFileContent ("public/mysection/mysectionbundle/index.html" , "mysectionbundletext2" , "My Section Bundle Text 2 Content." , "Len Resources: 2|" )
143
- b .AssertRenderCountPage (5 )
144
- b .AssertRenderCountContent (6 )
198
+ b .AssertRenderCountPage (8 )
199
+ b .AssertRenderCountContent (8 )
145
200
})
146
201
}
147
202
@@ -161,8 +216,8 @@ func TestRebuilEditContentFileThenAnother(t *testing.T) {
161
216
162
217
b .EditFileReplaceAll ("content/myothersection/myothersectionpage.md" , "myothersectionpage Content." , "myothersectionpage Content Edited." ).Build ()
163
218
b .AssertFileContent ("public/myothersection/myothersectionpage/index.html" , "myothersectionpage Content Edited" )
164
- b .AssertRenderCountPage (1 )
165
- b .AssertRenderCountContent (1 )
219
+ b .AssertRenderCountPage (2 )
220
+ b .AssertRenderCountContent (2 )
166
221
}
167
222
168
223
func TestRebuildRenameTextFileInBranchBundle (t * testing.T ) {
@@ -171,7 +226,7 @@ func TestRebuildRenameTextFileInBranchBundle(t *testing.T) {
171
226
172
227
b .RenameFile ("content/mysection/mysectiontext.txt" , "content/mysection/mysectiontext2.txt" ).Build ()
173
228
b .AssertFileContent ("public/mysection/index.html" , "mysectiontext2" , "My Section" )
174
- b .AssertRenderCountPage (2 )
229
+ b .AssertRenderCountPage (3 )
175
230
b .AssertRenderCountContent (2 )
176
231
}
177
232
@@ -181,14 +236,14 @@ func TestRebuildRenameTextFileInHomeBundle(t *testing.T) {
181
236
182
237
b .RenameFile ("content/hometext.txt" , "content/hometext2.txt" ).Build ()
183
238
b .AssertFileContent ("public/index.html" , "hometext2" , "Home Text Content." )
184
- b .AssertRenderCountPage (3 )
239
+ b .AssertRenderCountPage (5 )
185
240
}
186
241
187
242
func TestRebuildRenameDirectoryWithLeafBundle (t * testing.T ) {
188
243
b := TestRunning (t , rebuildFilesSimple )
189
244
b .RenameDir ("content/mysection/mysectionbundle" , "content/mysection/mysectionbundlerenamed" ).Build ()
190
245
b .AssertFileContent ("public/mysection/mysectionbundlerenamed/index.html" , "My Section Bundle" )
191
- b .AssertRenderCountPage (1 )
246
+ b .AssertRenderCountPage (2 )
192
247
}
193
248
194
249
func TestRebuildRenameDirectoryWithBranchBundle (t * testing.T ) {
@@ -197,7 +252,7 @@ func TestRebuildRenameDirectoryWithBranchBundle(t *testing.T) {
197
252
b .AssertFileContent ("public/mysectionrenamed/index.html" , "My Section" )
198
253
b .AssertFileContent ("public/mysectionrenamed/mysectionbundle/index.html" , "My Section Bundle" )
199
254
b .AssertFileContent ("public/mysectionrenamed/mysectionbundle/mysectionbundletext.txt" , "My Section Bundle Text 2 Content." )
200
- b .AssertRenderCountPage (3 )
255
+ b .AssertRenderCountPage (5 )
201
256
}
202
257
203
258
func TestRebuildRenameDirectoryWithRegularPageUsedInHome (t * testing.T ) {
@@ -296,7 +351,7 @@ func TestRebuildRenameDirectoryWithBranchBundleFastRender(t *testing.T) {
296
351
b .AssertFileContent ("public/mysectionrenamed/index.html" , "My Section" )
297
352
b .AssertFileContent ("public/mysectionrenamed/mysectionbundle/index.html" , "My Section Bundle" )
298
353
b .AssertFileContent ("public/mysectionrenamed/mysectionbundle/mysectionbundletext.txt" , "My Section Bundle Text 2 Content." )
299
- b .AssertRenderCountPage (3 )
354
+ b .AssertRenderCountPage (5 )
300
355
}
301
356
302
357
func TestRebuilErrorRecovery (t * testing.T ) {
@@ -1239,7 +1294,7 @@ Single.
1239
1294
return strings .Replace (s , "red" , "blue" , 1 )
1240
1295
}).Build ()
1241
1296
1242
- b .AssertRenderCountPage (3 )
1297
+ b .AssertRenderCountPage (4 )
1243
1298
1244
1299
b .AssertFileContent ("public/index.html" , "Home." , "<style>body {\n \t background: blue;\n }</style>" )
1245
1300
}
0 commit comments