✨ Add: config file support
This commit is contained in:
parent
6327f95e22
commit
e013540177
1 changed files with 7 additions and 2 deletions
9
vss.v
9
vss.v
|
@ -2,8 +2,11 @@ module main
|
|||
|
||||
import os
|
||||
import cli
|
||||
import toml
|
||||
import markdown
|
||||
|
||||
const default_config = 'config.toml'
|
||||
|
||||
const default_index = 'index.md'
|
||||
|
||||
const default_dist = 'dist'
|
||||
|
@ -11,7 +14,7 @@ const default_dist = 'dist'
|
|||
fn main() {
|
||||
mut app := cli.Command{
|
||||
name: 'vss'
|
||||
version: '0.0.1'
|
||||
version: '0.0.2'
|
||||
description: 'static site generator'
|
||||
execute: fn (cmd cli.Command) ? {
|
||||
generate_index_page()?
|
||||
|
@ -28,10 +31,12 @@ fn get_paths(path string) []string {
|
|||
}
|
||||
|
||||
fn generate_index_page() ? {
|
||||
config_text := os.read_file(default_config)?
|
||||
config := toml.parse_text(config_text)?
|
||||
index_md := os.read_file(default_index)?
|
||||
|
||||
// for $tmpl value
|
||||
title := 'tsurutatakumi.info'
|
||||
title := config.value('title').string()
|
||||
contents := markdown.to_html(index_md)
|
||||
|
||||
// tmpl に変数を割り当てるのは今の所無理
|
||||
|
|
Loading…
Add table
Reference in a new issue