From e013540177c20d5c5ece8ca665aa8a595f1cd8d9 Mon Sep 17 00:00:00 2001 From: zztkm Date: Fri, 29 Jul 2022 12:46:36 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add:=20config=20file=20support?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vss.v | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/vss.v b/vss.v index 9fe5e1f..0c3f06b 100644 --- a/vss.v +++ b/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 に変数を割り当てるのは今の所無理