cld-ssg

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

commit fced347041500053ddd334b31107fdaab2f0bd20
parent c8eff44d4284cc7e1fded80c32002532df5e0aa3
Author: Christopher Ray Langford <chris@hellocld.com>
Date:   Sun, 29 Sep 2019 12:36:30 -0400

Header/footer appending working

Need to figure out how to add the title to the html though

Diffstat:
Aassets/footer.html | 2++
Aassets/header.html | 5+++++
Mconfig.h | 4++++
Mmain.c | 10++++++----
4 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/assets/footer.html b/assets/footer.html @@ -0,0 +1,2 @@ +</body> +</html> diff --git a/assets/header.html b/assets/header.html @@ -0,0 +1,5 @@ +<!DOCTYPE html> +<html> +<head> +</head> +<body> diff --git a/config.h b/config.h @@ -9,6 +9,10 @@ #define HTMLDIR "testhtml/" /* Directory where .md posts are saved */ #define POSTDIR "postdir/" +/* Header and footer files */ +#define HEADER_HTML "assets/header.html" +#define FOOTER_HTML "assets/footer.html" + #define INDEX_POSTS 10 /* I should probably use some system defaults for these */ diff --git a/main.c b/main.c @@ -36,11 +36,15 @@ int write_rss(struct post *posts, int totalPosts); int write_post(struct post *post); char buf[MAX_POST_CHARS]; +char *header; +char *footer; int main() { /* Load header and footer html */ + header = read_text(HEADER_HTML, MAX_POST_CHARS); + footer = read_text(FOOTER_HTML, MAX_POST_CHARS); /* Load all posts */ struct dirent **t_mds; @@ -58,9 +62,6 @@ int main() write_post(posts[i]); } - - - /* Write index.html */ /* Write archive.html */ @@ -192,7 +193,8 @@ int write_post(struct post *post) sprintf(buf, "%s%s%s", HTMLDIR, post->dir, post->fhtml); FILE *f = fopen(buf, "w"); - fprintf(f, post->content); + sprintf(buf, "%s%s%s", header, post->content, footer); + fprintf(f, buf); fclose(f); return 0; }