cld-ssg

The static site generator (to be) used for hellocld.com
git clone git://git.hellocld.com/cld-ssg
Log | Files | Refs

commit 3d21f1085d92fcb5aa86871664890a5ee5cebcb2
parent fced347041500053ddd334b31107fdaab2f0bd20
Author: Christopher Ray Langford <chris@hellocld.com>
Date:   Mon, 30 Sep 2019 12:16:28 -0400

Index writer created

Diffstat:
Mmain.c | 16+++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/main.c b/main.c @@ -30,7 +30,7 @@ char *get_post_title(struct cmark_node *root); struct tm *get_post_time(const char *file); void free_post(struct post *p); -int write_index(struct post *posts, int totalPosts); +int write_index(struct post *posts[], int totalPosts); int write_archive(struct post *posts, int totalPosts); int write_rss(struct post *posts, int totalPosts); int write_post(struct post *post); @@ -63,6 +63,7 @@ int main() } /* Write index.html */ + write_index(posts, t_postcount); /* Write archive.html */ @@ -198,3 +199,16 @@ int write_post(struct post *post) fclose(f); return 0; } + +int write_index(struct post *posts[], int totalPosts) +{ + sprintf(buf, "%s%s", HTMLDIR, "index.html"); + FILE *f = fopen(buf, "w"); + fprintf(f, header); + int c = 0; + while(totalPosts-- > 0 && c++ < INDEX_POSTS) + fprintf(f, posts[totalPosts]->content); + fprintf(f, footer); + fclose(f); + return 0; +}