✨ markdown で書いたコンテンツをhtmlに埋め込む機能を追加
This commit is contained in:
parent
e543219674
commit
e8059cca2b
2 changed files with 22 additions and 12 deletions
23
vss.v
23
vss.v
|
@ -4,28 +4,39 @@ import os
|
||||||
import cli
|
import cli
|
||||||
import markdown
|
import markdown
|
||||||
|
|
||||||
|
const markdown_text = "
|
||||||
|
# Open Sea
|
||||||
|
|
||||||
|
A static site generator
|
||||||
|
|
||||||
|
- [GitHub](https://github.com/zztkm)
|
||||||
|
"
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
mut app := cli.Command{
|
mut app := cli.Command{
|
||||||
name: 'vss'
|
name: 'vss'
|
||||||
version: '0.0.0'
|
version: '0.0.0'
|
||||||
description: 'static site generator'
|
description: 'static site generator'
|
||||||
execute: fn (cmd cli.Command) ? {
|
execute: fn (cmd cli.Command) ? {
|
||||||
paths := get_paths("testfiles")
|
paths := get_paths('testfiles')
|
||||||
if paths.len == 0 {
|
if paths.len == 0 {
|
||||||
println("Cloud not retrieve path")
|
println('Cloud not retrieve path')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for path in paths {
|
for path in paths {
|
||||||
println(path)
|
println(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// index_html := $embed_file("layouts/_index.html")
|
||||||
|
title := 'tsurutatakumi.info'
|
||||||
|
contents := markdown.to_html(markdown_text)
|
||||||
|
|
||||||
|
index_html := $tmpl('layouts/_index.html')
|
||||||
|
os.write_file('index.html', index_html) ?
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
text := '# Markdown Rocks!'
|
|
||||||
output := markdown.to_html(text)
|
|
||||||
println(output) // <h1>Markdown Rocks!</h1>
|
|
||||||
|
|
||||||
app.setup()
|
app.setup()
|
||||||
app.parse(os.args)
|
app.parse(os.args)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ module main
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
fn normalise_paths(paths []string) []string {
|
fn normalise_paths(paths []string) []string {
|
||||||
mut res := paths.map(it.replace(os.path_separator, '/'))
|
mut res := paths.map(it.replace(os.path_separator, '/'))
|
||||||
res.sort()
|
res.sort()
|
||||||
|
@ -10,11 +9,11 @@ fn normalise_paths(paths []string) []string {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_get_paths() {
|
fn test_get_paths() {
|
||||||
testpath := "testfiles"
|
testpath := 'testfiles'
|
||||||
mds := normalise_paths(get_paths(testpath))
|
mds := normalise_paths(get_paths(testpath))
|
||||||
assert mds.len == 2
|
assert mds.len == 2
|
||||||
assert mds == [
|
assert mds == [
|
||||||
"testfiles/aaa.md",
|
'testfiles/aaa.md',
|
||||||
"testfiles/bbb.md",
|
'testfiles/bbb.md',
|
||||||
]
|
]
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue