commit 0eaede954186ca453a5e3c6f9dada89d86711048
parent 124d755ac75e1fc3cb702e5190cea76fe8ba69e2
Author: Henry Unite <unitehenry@gmail.com>
Date: Sun, 12 Apr 2026 01:17:54 +0000
feat: get metadata
Diffstat:
1 file changed, 33 insertions(+), 0 deletions(-)
diff --git a/src/generate.c b/src/generate.c
@@ -143,10 +143,43 @@ void to_write_path(char **write_path, char *read_path) {
*write_path = str_replace(*write_path, from_dir, to_dir);
}
+void get_content_metadata(StringMap **map, char* content_path) {
+ FILE *content_fp = fopen(content_path, "r");
+
+ char *content_line = NULL;
+
+ size_t content_len = 0;
+
+ ssize_t content_read;
+
+ bool metadata_start = false;
+
+ while((content_read = getline(&content_line, &content_len, content_fp)) != -1) {
+ if (strcmp(trim_whitespace(content_line), "---") == 0) {
+ if (metadata_start) {
+ break;
+ } else {
+ metadata_start = true;
+ continue;
+ }
+ }
+
+ if (metadata_start) {
+ printf("metadata: %s", content_line);
+ }
+ }
+
+ fclose(content_fp);
+}
+
void generate_pages(StringList *list) {
int i = 0;
while (list->strings[i] != NULL) {
+ StringMap *metadata = string_map_create();
+
+ get_content_metadata(&metadata, list->strings[i]);
+
char *write_path;
to_write_path(&write_path, list->strings[i]);