@@ -42,6 +42,7 @@ FILE *f = NULL;
4242
4343const char * src_path = NULL ;
4444const char * dest_path = NULL ;
45+ const char * base_url = NULL ;
4546bool strip_html = false;
4647bool strip_jsx = false;
4748bool strip_md_title = false;
@@ -95,7 +96,7 @@ static char *file_buildpath (const char *filename, const char *dirpath) {
9596 return full_path ;
9697}
9798
98- static char * file_buildurl (const char * fullpath ) {
99+ static char * file_buildurl (const char * base_url , const char * fullpath ) {
99100 char * url = (char * )malloc (512 );
100101 if (!url ) return NULL ;
101102
@@ -125,7 +126,6 @@ static char *file_buildurl (const char *fullpath) {
125126 }
126127 }
127128
128- const char * base_url = "https://docs.sqlitecloud.io/docs/" ;
129129 snprintf (url , 512 , "%s%s" , base_url , p );
130130
131131 free (path );
@@ -469,7 +469,7 @@ static void add_entry(const char *url, char *buffer, size_t size) {
469469#endif
470470}
471471
472- static void scan_docs (const char * dir_path ) {
472+ static void scan_docs (const char * base_url , const char * dir_path ) {
473473 DIRREF dir = opendir (dir_path );
474474 if (!dir ) return ;
475475
@@ -479,15 +479,15 @@ static void scan_docs (const char *dir_path) {
479479 // if file is a folder then start recursion
480480 const char * full_path = file_buildpath (target_file , dir_path );
481481 if (is_directory (full_path )) {
482- scan_docs (full_path );
482+ scan_docs (base_url , full_path );
483483 continue ;
484484 }
485485
486486 // test only files with a .md or mdx extension
487487 if ((strstr (full_path , ".md" ) == NULL ) && (strstr (full_path , ".mdx" ) == NULL )) continue ;
488488
489489 // build url and title
490- const char * url = file_buildurl (full_path );
490+ const char * url = file_buildurl (base_url , full_path );
491491
492492 // load md source code
493493 size_t size = 0 ;
@@ -532,6 +532,14 @@ int main (int argc, char * argv[]) {
532532 .value_name = "output_path" ,
533533 .description = "Output path"
534534 },
535+
536+ {
537+ .identifier = 'b' ,
538+ .access_letters = "b" ,
539+ .access_name = "base-url" ,
540+ .value_name = "base_url" ,
541+ .description = "Base url in docs path"
542+ },
535543
536544 {
537545 .identifier = 'a' ,
@@ -614,6 +622,7 @@ int main (int argc, char * argv[]) {
614622 switch (cag_option_get_identifier (& context )) {
615623 case 'i' : src_path = cag_option_get_value (& context ); break ;
616624 case 'o' : dest_path = cag_option_get_value (& context ); break ;
625+ case 'b' : base_url = cag_option_get_value (& context ); break ;
617626 case 'l' : strip_html = true; break ;
618627 case 'j' : strip_jsx = true; break ;
619628 case 'm' : strip_md_title = true; break ;
@@ -636,7 +645,7 @@ int main (int argc, char * argv[]) {
636645 }
637646
638647 create_output (dest_path );
639- scan_docs (src_path );
648+ scan_docs (base_url , src_path );
640649 close_output ();
641650
642651 return 0 ;
0 commit comments