Add: config file support

main
zztkm 2 years ago
parent 6327f95e22
commit e013540177

@ -2,8 +2,11 @@ module main
import os import os
import cli import cli
import toml
import markdown import markdown
const default_config = 'config.toml'
const default_index = 'index.md' const default_index = 'index.md'
const default_dist = 'dist' const default_dist = 'dist'
@ -11,7 +14,7 @@ const default_dist = 'dist'
fn main() { fn main() {
mut app := cli.Command{ mut app := cli.Command{
name: 'vss' name: 'vss'
version: '0.0.1' version: '0.0.2'
description: 'static site generator' description: 'static site generator'
execute: fn (cmd cli.Command) ? { execute: fn (cmd cli.Command) ? {
generate_index_page()? generate_index_page()?
@ -28,10 +31,12 @@ fn get_paths(path string) []string {
} }
fn generate_index_page() ? { fn generate_index_page() ? {
config_text := os.read_file(default_config)?
config := toml.parse_text(config_text)?
index_md := os.read_file(default_index)? index_md := os.read_file(default_index)?
// for $tmpl value // for $tmpl value
title := 'tsurutatakumi.info' title := config.value('title').string()
contents := markdown.to_html(index_md) contents := markdown.to_html(index_md)
// tmpl に変数を割り当てるのは今の所無理 // tmpl に変数を割り当てるのは今の所無理

Loading…
Cancel
Save