site

A custom static site generator written in C.
git clone https://unitehenry.com/git/site.git
Log | Files | Refs | README

commit 23707a08ab39a8f0c88ea7952080f151667ba1ff
parent 83ee5bab7777f4e3de47e197e78f78a223e287bc
Author: Henry Unite <unitehenry@gmail.com>
Date:   Tue, 14 Apr 2026 03:08:25 +0000

feat: description meta tag

Diffstat:
Msrc/generate.c | 12+++++++++++-
Mtemplates/base.html | 1+
2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/generate.c b/src/generate.c @@ -10,6 +10,7 @@ #define BASE_TEMPLATE "templates/base.html" #define CONTENT_TAG "{{ content }}" #define TITLE_TAG "{{ title }}" +#define DESCRIPTION_TAG "{{ description }}" #define STATIC_DIRECTORY "static" void run_pandoc(FILE **fp, char *content_path) { @@ -253,11 +254,20 @@ void generate_pages(StringList *list) { if (string_map_contains(metadata, "title")) { char *title_tag; - asprintf(&title_tag, "<title>%s</title>", + asprintf(&title_tag, "<title>%s</title>\n", string_map_get(metadata, "title")); fputs(title_tag, write_fp); } + } else if (strcmp(trim_whitespace(template_line), DESCRIPTION_TAG) == 0) { + if (string_map_contains(metadata, "description")) { + char *title_tag; + + asprintf(&title_tag, "<meta name=\"description\" content=\"%s\" />\n", + string_map_get(metadata, "description")); + + fputs(title_tag, write_fp); + } } else { fputs(template_line, write_fp); } diff --git a/templates/base.html b/templates/base.html @@ -3,6 +3,7 @@ <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + {{ description }} {{ title }} <link rel="icon" href="/favicon/favicon.ico" /> <link rel="stylesheet" href="/css/style.css" />