feat: added the source path to the runtime.
This commit is contained in:
parent
c9e78e8b7e
commit
3266727e1e
2 changed files with 4 additions and 0 deletions
|
@ -17,4 +17,5 @@ type ContextValues struct {
|
|||
IsIndex bool
|
||||
IndexSuffix string
|
||||
Ext string
|
||||
SourcePath string
|
||||
}
|
||||
|
|
|
@ -77,6 +77,7 @@ func DefaultPP(mod string) *tpp.Preprocessor {
|
|||
s.Add("__is_index__", vals.IsIndex)
|
||||
s.Add("__index_suffix__", vals.IndexSuffix)
|
||||
s.Add("__tpp_ext__", vals.Ext)
|
||||
s.Add("__source_path__", vals.SourcePath)
|
||||
}).SetPreCode(func(ctx context.Context) []byte {
|
||||
return []byte(`
|
||||
markdown := func(...args) {
|
||||
|
@ -92,6 +93,7 @@ func DefaultPP(mod string) *tpp.Preprocessor {
|
|||
context.is_index = __is_index__
|
||||
context.index_suffix = __index_suffix__
|
||||
context.tpp_ext = __tpp_ext__
|
||||
context.source_path = __source_path__
|
||||
|
||||
import("./pre")(context)
|
||||
`)
|
||||
|
@ -171,6 +173,7 @@ func (h *Handler) ServeHTTP(
|
|||
IsIndex: isIndex,
|
||||
IndexSuffix: h.indexSuffix,
|
||||
Ext: h.ext,
|
||||
SourcePath: h.sourcePath,
|
||||
},
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue