diff --git a/context.go b/context.go index 5b8813d..55747c7 100644 --- a/context.go +++ b/context.go @@ -17,4 +17,5 @@ type ContextValues struct { IsIndex bool IndexSuffix string Ext string + SourcePath string } diff --git a/handler.go b/handler.go index 2ef2326..588f3f9 100644 --- a/handler.go +++ b/handler.go @@ -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, }, )