From dc848ecc283b39c86fcd6ed00eeb6055713fcb7b Mon Sep 17 00:00:00 2001 From: zztkm Date: Thu, 18 May 2023 23:25:32 +0900 Subject: [PATCH] feat: added handling of cases where only the directory --- commands/build.v | 5 +++++ example/layouts/post/index.html | 14 ++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 example/layouts/post/index.html diff --git a/commands/build.v b/commands/build.v index ed8257a..e8b40cd 100644 --- a/commands/build.v +++ b/commands/build.v @@ -113,12 +113,17 @@ fn (mut b Builder) md2html(md_path string) ! { content := get_content(md_path)! // want to change from contents to content b.config_map['contents'] = content + // parse template html_path := get_html_path(md_path) + dir := os.dir(md_path) mut template_content := '' if os.exists('layouts/${html_path}') { b.logger.info('use custom template: layouts/${html_path}') template_content = os.read_file('layouts/${html_path}')! + } else if os.exists('layouts/${dir}/index.html') { + b.logger.info('use custom template: layouts/${dir}/index.html') + template_content = os.read_file('layouts/${dir}/index.html')! } else { b.logger.info('use default template') template_content = b.template_content diff --git a/example/layouts/post/index.html b/example/layouts/post/index.html new file mode 100644 index 0000000..f12fe69 --- /dev/null +++ b/example/layouts/post/index.html @@ -0,0 +1,14 @@ + + + + + @title + + + + + +
Post
+ + @contents +