@@ -12,12 +12,13 @@ const donation = "<p><a href='https://bsky.app/profile/pogging.fish'>Follow me o
1212const tmpl = readFile (" wiki/templates/base.html" )
1313let meta = parseFile (" wiki/meta.json" )
1414
15- proc applyTemplate (page: string , tags: string = " " , date: string = " (meta pages have no date)" ): string =
15+ proc applyTemplate (page: string , tags: string = " " , date: string = " (meta pages have no date)" , name = " " ): string =
1616 return multireplace (tmpl,
1717 [(" __varHtmlpage__var" , page),
1818 (" __varTags__var" , tags),
1919 (" __varCreationdate__var" , date),
2020 (" __varWikiName__var" , pageName),
21+ (" __varPageName__var" , name),
2122 (" __varDonate__var" , donation)
2223 ]
2324 )
@@ -28,7 +29,7 @@ proc getPostDate(i: string): int =
2829 return 19700101
2930 else :
3031 return d.getInt ()
31-
32+
3233proc customCmp (i: (string , string , string ), i2: (string , string , string )): int =
3334 return cmp (
3435 getPostDate (i[0 ]),
@@ -68,7 +69,7 @@ proc main() =
6869 let basePath = filePath.changeFileExt (" .html" )
6970 let metadata = meta{string (basePath)}
7071 let original = readFile (string (i))
71- let name = original.split (" \n " )[0 ].replace (" #" , " " )
72+ let name = original.split (" \n " )[0 ].replace (" #" , " " ). strip ()
7273 var tagstring = " "
7374 var first = true
7475 for tag_j in getPostTags (string (basePath)):
@@ -82,7 +83,7 @@ proc main() =
8283 let path = " generated/" & string (basePath)
8384 index.add ((string (basePath), name, tagstring))
8485 let mdhtml = markdown (original)
85- writeFile (string (path), applyTemplate (mdhtml, fmt" <p>{ tagstring} </p> " , fmt" { intToDate (getPostDate (string (basePath)))} " ))
86+ writeFile (string (path), applyTemplate (mdhtml, fmt" <p>{ tagstring} </p> " , fmt" { intToDate (getPostDate (string (basePath)))} " , name ))
8687 # Create index page
8788 var indexhtml = " <h2>Looking for something specific? Do CTRL+F to find it!</h2>"
8889 indexhtml &= " tag listing: "
@@ -96,8 +97,8 @@ proc main() =
9697 for tag in getPostTags (i[0 ]):
9798 tags[tag.getStr ()] &= createLink (i)
9899 for i in tags.keys ():
99- writeFile (fmt" generated/tags/{ i} .html " , applyTemplate (tags[i]))
100- writeFile (" generated/indexpage.html" , applyTemplate (indexhtml))
100+ writeFile (fmt" generated/tags/{ i} .html " , applyTemplate (tags[i], name = i ))
101+ writeFile (" generated/indexpage.html" , applyTemplate (indexhtml, name = " Index " ))
101102
102103
103104when isMainModule :
0 commit comments