Commit Diff


commit - 044348ebfee5cdeab03452924bb5db2024d9f9ed
commit + bf6a94c965569ff8cd4e55c0aff269a484f946ed
blob - ac926753bad217c67bf4ff1f883ebd19e30fa12d
blob + 00202058e5e7989f735f6e362d18f249e550ee6f
--- content/index.md
+++ content/index.md
@@ -1,11 +1,9 @@
 ---
 title: Hello kssg
 date: 2026-04-03
-draft: true
+draft: false
 ---
 
 # Bem-Vindo
 
 Esse é o **primeiro post** gerado pelo kssg.
-
-Esse conteúdo não aparece pois está como draft.
blob - 88121dca19f0a12c13878a5c58adbb184c833616
blob + e268781dc44180e52ee6c9426f3c3740f1bdf74b
--- src/main.rs
+++ src/main.rs
@@ -216,6 +216,8 @@ fn build() {
 
     }
 
+    let post_list = generate_post_list(&posts);
+
     for i in 0..posts.len() {
         let nav = series_nav(&posts, i);
 
@@ -223,10 +225,18 @@ fn build() {
         if !nav.is_empty() {
             content.push_str(&nav);
         }
+        println!("{}", posts[i].out_path.display());
 
+        let list = if posts[i].out_path == Path::new("public/index.html") {
+            &post_list
+        } else {
+            ""
+        };
+
         let output = template
             .replace("{{title}}", &posts[i].meta.title)
-            .replace("{{content}}", &content);
+            .replace("{{content}}", &content)
+            .replace("{{posts}}", list);
 
         if let Some(parent) = posts[i].out_path.parent() {
             fs::create_dir_all(parent).expect("create dir");
@@ -292,3 +302,29 @@ fn series_nav(posts: &[Post], current: usize) -> Strin
     nav.push_str("</nav>");
     nav
 }
+
+fn generate_post_list(posts: &[Post]) -> String {
+    let mut items: Vec<(&str, &str, &Path)> = Vec::new();
+
+    for post in posts {
+        if post.out_path == Path::new("public/index.html") {
+            continue;
+        }
+        items.push((
+                &post.meta.date,
+                &post.meta.title,
+                &post.out_path,
+        ));
+    }
+
+    items.sort_by(|a, b| b.0.cmp(a.0));
+
+    let mut html = String::from("<ul class=\"post-list\">\n");
+    for (date, title, path) in &items {
+        let href = format!("/{}", path.strip_prefix("public").unwrap_or(path).display());
+        html.push_str(&format!("<li><time>{}</time> - <a href=\"{}\">{}</a></li>\n", date, href, title));
+    }
+
+    html.push_str("</ul>");
+    html
+}
blob - cb8f8298114bedabdf68f23b7c680502cee80ac6
blob + fdb4c3fe39d11fb55fa91e457e9720f2940afc07
--- templates/base.html
+++ templates/base.html
@@ -7,5 +7,6 @@
   </head>
   <body>
     {{content}}
+    {{posts}}
   </body>
 </html>