commit ddb31bfdd167f5874351ed3fe942a47a931824da
parent 060c0906462066fbed11a696caf7d25ccac18845
Author: Henry Unite <unitehenry@gmail.com>
Date: Thu, 9 Apr 2026 04:14:39 +0000
feat: dynamic write path
Diffstat:
4 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/build/blog/first-post.html b/build/blog/first-post.html
@@ -0,0 +1,2 @@
+<h1 id="first-post">First Post</h1>
+<p>This is my first blog post.</p>
diff --git a/build/blog/nested/nested-1.html b/build/blog/nested/nested-1.html
@@ -0,0 +1 @@
+<p>nested content</p>
diff --git a/build/index.html b/build/index.html
@@ -0,0 +1,2 @@
+<h2 id="welcome-to-my-site">Welcome to my Site</h2>
+<p>This is my website.</p>
diff --git a/src/main.c b/src/main.c
@@ -59,23 +59,23 @@ void run_pandoc(FILE **fp, char *content_path) {
*fp = popen(command, "r");
}
-void to_write_path(char *write_path, char *read_path) {
+void to_write_path(char **write_path, char *read_path) {
char replace_path[strlen(read_path)];
strcpy(replace_path, read_path);
- strcpy(write_path, str_replace(replace_path, ".md", ".html"));
+ *write_path = str_replace(replace_path, ".md", ".html");
- strcpy(write_path, str_replace(write_path, "content/", "build/"));
+ *write_path = str_replace(*write_path, "content/", "build/");
}
void generate_pages(StringList *list) {
int i = 0;
while (list->strings[i] != NULL) {
- char write_path[1024];
+ char *write_path;
- to_write_path(write_path, list->strings[i]);
+ to_write_path(&write_path, list->strings[i]);
printf("filepath: %s\n", write_path);