This commit is contained in:
2025-02-25 11:17:11 -07:00
parent f306ff728f
commit a56a251d7f
8 changed files with 176 additions and 11 deletions

View File

@@ -78,7 +78,10 @@ pub fn load_config(cfg_dir string) !Config {
// Load and parse footer config
footer_content := os.read_file(os.join_path(cfg_dir, 'footer.json'))!
footer := json.decode(Footer, footer_content)!
footer := json.decode(Footer, footer_content) or {
eprintln('footer.json in ${cfg_dir} is not in the right format please fix.\nError: ${err}')
exit(99)
}
// Load and parse main config
main_config_path := os.join_path(cfg_dir, 'main.json')
@@ -115,7 +118,10 @@ pub fn load_config(cfg_dir string) !Config {
// Load and parse navbar config
navbar_content := os.read_file(os.join_path(cfg_dir, 'navbar.json'))!
navbar := json.decode(Navbar, navbar_content)!
navbar := json.decode(Navbar, navbar_content) or {
eprintln('navbar.json in ${cfg_dir} is not in the right format please fix.\nError: ${err}')
exit(99)
}
return Config{
footer: footer

View File

@@ -209,11 +209,13 @@ fn (mut site DocSite) template_install() ! {
mut build_dev_publish_ := site.path_build.file_get_new('build_dev_publish.sh')!
build_dev_publish_.template_write(build_dev_publish, true)!
build_dev_publish_.chmod(0o700)!
develop_templ := $tmpl('templates/develop_src.sh')
mut develop2_ := site.path_src.file_get_new('develop.sh')!
develop2_.template_write(develop, true)!
develop2_.template_write(develop_templ, true)!
develop2_.chmod(0o700)!
build_templ := $tmpl('templates/build_src.sh')
mut build2_ := site.path_src.file_get_new('build.sh')!
build2_.template_write(build, true)!
build2_.chmod(0o700)!

View File

@@ -0,0 +1,6 @@
#!/bin/bash -e
script_dir="???cd "???dirname "??{BASH_SOURCE[0]}")" && pwd)"
cd "??{script_dir}"
hero docusaurus -bp

View File

@@ -0,0 +1,6 @@
#!/bin/bash -e
script_dir="???cd "???dirname "??{BASH_SOURCE[0]}")" && pwd)"
cd "??{script_dir}"
hero docusaurus -d

View File

@@ -87,10 +87,10 @@ pub fn (mut s DocSite) dev()! {
console.print_item(' 2. To detach from screen: Press Ctrl+A then D')
console.print_item(' 3. To list all screens: screen -ls')
console.print_item('The site content is on::')
console.print_item(' 1. location of documents: ${s.path_src.path}/docs')
console.print_item(' 1. location of documents: ${s.path_src.path}/src')
if osal.cmd_exists('code') {
console.print_item(' 2. We opened above dir in vscode.')
osal.exec(cmd: 'code ${s.path_src.path}/docs')!
osal.exec(cmd: 'code ${s.path_src.path}/src')!
}
// Start the watcher in a separate thread
@@ -99,7 +99,7 @@ pub fn (mut s DocSite) dev()! {
println('\n')
if s.args.watch_changes {
docs_path := '${s.path_src.path}/docs'
docs_path := '${s.path_src.path}/src'
watch_docs(docs_path, s.path_src.path, s.path_build.path)!
}
@@ -154,7 +154,7 @@ pub fn (mut site DocSite) generate() ! {
aa.copy(dest: '${site.path_build.path}/${item}')!
}
}
for item in ['docs'] {
for item in ['src'] {
if os.exists('${site.path_src.path}/${item}') {
mut aa := site.path_src.dir_get(item)!
aa.copy(dest: '${site.path_build.path}/${item}', delete: true)!

View File

@@ -39,8 +39,8 @@ fn handle_file_change(event notifier.NotifyEvent, path string, args map[string]s
}
// Get relative path from docs directory
rel_path := path.replace('${args['path_src']}/docs/', '')
dest_path := '${args['path_build']}/docs/${rel_path}'
rel_path := path.replace('${args['path_src']}/src/', '')
dest_path := '${args['path_build']}/src/${rel_path}'
match event {
.create, .modify {