@@ -161,6 +161,13 @@ func (h *Hooks) ProcessFile(file transformers.TransformedFile) (hookedFile Hooke
161
161
fileData , _ := os .ReadFile (file .TransformedFile )
162
162
hookedFile .content = fileData
163
163
164
+ fileTargetName := strings .TrimPrefix (
165
+ file .SourcePath ,
166
+ filepath .Join (h .ac .RootPath , "pages" ),
167
+ )
168
+ fileTargetName = filepath .Clean (strings .TrimPrefix (fileTargetName , "/" ))
169
+ fileTargetName = strings .Replace (fileTargetName , filepath .Ext (fileTargetName ), ".html" , 1 )
170
+
164
171
hookInput := struct {
165
172
Name string `json:"name"`
166
173
SourcePath string `json:"source_path"`
@@ -169,17 +176,14 @@ func (h *Hooks) ProcessFile(file transformers.TransformedFile) (hookedFile Hooke
169
176
WriteableContent string `json:"content"`
170
177
// HTMLContent string `json:"html"`
171
178
}{
172
- Name : filepath .Clean (strings .TrimPrefix (strings .TrimPrefix (file .SourcePath , filepath .Join (h .ac .RootPath , "pages" )), "/" )),
173
- SourcePath : file .SourcePath ,
174
- WriteableContent : string (fileData ),
179
+ Name : fileTargetName ,
180
+ SourcePath : file .SourcePath ,
175
181
}
176
182
177
- hookJsonInput , _ := json .Marshal (hookInput )
178
-
179
183
localCollection := []* HookSource {}
180
184
181
- filePathSplits := strings .Split (file .SourcePath , string ( filepath .Separator ))
182
- nonRootPath := filepath . Join ( filePathSplits [ 1 :] ... )
185
+ nonRootPath := strings .TrimPrefix (file .SourcePath , filepath .Join ( h . ac . RootPath , "pages" ))
186
+ nonRootPath = strings . TrimPrefix ( nonRootPath , "/" )
183
187
184
188
if len (h .forSpecificFiles [nonRootPath ]) > 0 {
185
189
localCollection = append (localCollection , h .forSpecificFiles [nonRootPath ]... )
@@ -194,6 +198,9 @@ func (h *Hooks) ProcessFile(file transformers.TransformedFile) (hookedFile Hooke
194
198
hook := localCollection [i ]
195
199
hookFunc := hook .luaState .GetGlobal ("Writer" )
196
200
201
+ hookInput .WriteableContent = string (hookedFile .content )
202
+ hookJsonInput , _ := json .Marshal (hookInput )
203
+
197
204
if hookFunc == lua .LNil {
198
205
continue
199
206
}
@@ -224,6 +231,9 @@ func (h *Hooks) ProcessFile(file transformers.TransformedFile) (hookedFile Hooke
224
231
225
232
if fromPlug ["transform" ] != nil {
226
233
hookedFile .transform = fmt .Sprintf ("%v" , fromPlug ["transform" ])
234
+ } else {
235
+ h .ac .logger .Warning ("Auto transformation of content returned from the hooks will be removed in v0.3,\n please return a `transform` property from the hooks instead." )
236
+ hookedFile .transform = ".md"
227
237
}
228
238
229
239
if fromPlug ["data" ] != nil {
0 commit comments