feat: added handling of cases where only the directory
This commit is contained in:
parent
2d0745233d
commit
dc848ecc28
2 changed files with 19 additions and 0 deletions
|
@ -113,12 +113,17 @@ fn (mut b Builder) md2html(md_path string) ! {
|
||||||
content := get_content(md_path)!
|
content := get_content(md_path)!
|
||||||
// want to change from contents to content
|
// want to change from contents to content
|
||||||
b.config_map['contents'] = content
|
b.config_map['contents'] = content
|
||||||
|
|
||||||
// parse template
|
// parse template
|
||||||
html_path := get_html_path(md_path)
|
html_path := get_html_path(md_path)
|
||||||
|
dir := os.dir(md_path)
|
||||||
mut template_content := ''
|
mut template_content := ''
|
||||||
if os.exists('layouts/${html_path}') {
|
if os.exists('layouts/${html_path}') {
|
||||||
b.logger.info('use custom template: layouts/${html_path}')
|
b.logger.info('use custom template: layouts/${html_path}')
|
||||||
template_content = os.read_file('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 {
|
} else {
|
||||||
b.logger.info('use default template')
|
b.logger.info('use default template')
|
||||||
template_content = b.template_content
|
template_content = b.template_content
|
||||||
|
|
14
example/layouts/post/index.html
Normal file
14
example/layouts/post/index.html
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>@title</title>
|
||||||
|
<base href="@base_url">
|
||||||
|
<meta name="description" content="@description" />
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<header> Post </header>
|
||||||
|
|
||||||
|
@contents
|
||||||
|
</body>
|
Loading…
Reference in a new issue