added fmt and defer
This commit is contained in:
@@ -24,7 +24,6 @@ BLOG_BACK_MD := `
|
||||
[<= Back](./..)
|
||||
`
|
||||
generate_blog_md_file :: proc(path: string, allocator := context.allocator) {
|
||||
|
||||
blog_list := make([dynamic]string, allocator)
|
||||
sb := strings.builder_make(allocator)
|
||||
blog_md_file := strings.builder_make(allocator)
|
||||
@@ -39,33 +38,23 @@ generate_blog_md_file :: proc(path: string, allocator := context.allocator) {
|
||||
for blog in blogs {
|
||||
b := strings.split(blog, blog_dir, allocator)
|
||||
trim_b := strings.trim_right(b[1], ".md")
|
||||
if trim_b == "index" {continue}
|
||||
if trim_b == "index_non_blank" {continue}
|
||||
if trim_b == "test" {continue}
|
||||
if trim_b == "test_blog" {continue}
|
||||
if trim_b == "2026-03-16-Test" {continue}
|
||||
if strings.starts_with(trim_b, "!") {continue}
|
||||
if trim_b == "index" { continue } //Ignore Index
|
||||
|
||||
if strings.starts_with(trim_b, "!") { continue }
|
||||
append(&blog_list, blog)
|
||||
}
|
||||
|
||||
for blog_entry in blog_list {
|
||||
b := strings.split(blog_entry, blog_dir, allocator)
|
||||
trim_b := strings.trim_right(b[1], ".md")
|
||||
strings.write_string(
|
||||
&blog_md_file,
|
||||
fmt.aprintf("* [%s](./%s.html)", trim_b, trim_b, allocator = allocator),
|
||||
)
|
||||
strings.write_string(&blog_md_file, fmt.aprintf("* [%s](./%s.html)", trim_b, trim_b, allocator = allocator))
|
||||
strings.write_string(&blog_md_file, "\n")
|
||||
}
|
||||
|
||||
os.change_directory(blog_dir)
|
||||
index_file, err := os.create("index.md")
|
||||
if err != nil {
|
||||
fmt.eprintfln(
|
||||
"ERROR in generate_blog_md_file: Could not open file %s: %s",
|
||||
index_file,
|
||||
os.error_string(err),
|
||||
)
|
||||
fmt.eprintfln("ERROR in generate_blog_md_file: Could not open file %s: %s", index_file, os.error_string(err))
|
||||
}
|
||||
os.write_string(index_file, "```")
|
||||
os.write_string(index_file, BLOG_START_MD)
|
||||
|
||||
Reference in New Issue
Block a user