fix: Fix docusaurus compilation issues in development branch

- Update docusaurus.v to use correct API (dsite_add instead of add)
- Fix factory.v compiler bug by rewriting problematic or block syntax
- Ensure compilation works with current docusaurus module structure
This commit is contained in:
Mahmoud-Emad
2025-08-05 15:34:46 +03:00
parent 59acea177d
commit ccf2d4a3a5
2 changed files with 49 additions and 52 deletions

View File

@@ -204,14 +204,13 @@ fn cmd_docusaurus_execute(cmd Command) ! {
mut generic_site := site.get(name: site_name)!
// Add docusaurus site
mut dsite := docusaurus.add(
site: generic_site
path_src: url // Use URL as source path for now
path_build: build_path
path_publish: publish_path
reset: false
template_update: update
install: init
mut dsite := docusaurus.dsite_add(
sitename: site_name
path: url // Use URL as source path for now
path_publish: publish_path
git_reset: false
git_pull: false
play: true
)!
// Conditional site actions based on flags
@@ -222,7 +221,7 @@ fn cmd_docusaurus_execute(cmd Command) ! {
} else if dev {
dsite.dev(host: 'localhost', port: 3000, open: open)!
} else if open {
dsite.open('localhost', 3000)!
dsite.open(host: 'localhost', port: 3000)!
} else {
// If no specific action (build/dev/open) is requested, just generate the site
dsite.generate()!

View File

@@ -8,71 +8,69 @@ import freeflowuniverse.herolib.osal.core as osal
import freeflowuniverse.herolib.installers.web.bun
__global (
docusaurus_sites map[string]&DocSite
docusaurus_factory ?DocSiteFactory
docusaurus_sites map[string]&DocSite
docusaurus_factory ?DocSiteFactory
)
pub struct DocSiteFactory{
pub struct DocSiteFactory {
pub mut:
path_publish pathlib.Path
path_build pathlib.Path
path_build pathlib.Path
}
@[params]
pub struct DocSiteFactoryArgs {
pub mut:
path_build string
path_publish string
install bool
reset bool
template_update bool
path_build string
path_publish string
install bool
reset bool
template_update bool
}
pub fn factory_get(args_ DocSiteFactoryArgs) !DocSiteFactory {
mut args:= args_
mut f:= docusaurus_factory or {
mut factory:=factory_set(args)!
factory
}
return f
mut args := args_
if f := docusaurus_factory {
return f
} else {
mut factory := factory_set(args)!
docusaurus_factory = factory
return factory
}
}
pub fn factory_set(args_ DocSiteFactoryArgs) !DocSiteFactory {
mut args:= args_
if args.path_build == '' {
args.path_build = '${os.home_dir()}/hero/var/docusaurus/build'
}
if args.path_publish == '' {
args.path_publish = '${os.home_dir()}/hero/var/docusaurus/publish'
}
mut factory := DocSiteFactory{
path_publish: pathlib.get_dir(path:args.path_publish,create:true)!
path_build: pathlib.get_dir(path:args.path_build,create:true)!
}
mut args := args_
if args.path_build == '' {
args.path_build = '${os.home_dir()}/hero/var/docusaurus/build'
}
if args.path_publish == '' {
args.path_publish = '${os.home_dir()}/hero/var/docusaurus/publish'
}
mut factory := DocSiteFactory{
path_publish: pathlib.get_dir(path: args.path_publish, create: true)!
path_build: pathlib.get_dir(path: args.path_build, create: true)!
}
if !os.exists('${args.path_build}/node_modules') {
args.install = true
}
if !os.exists('${args.path_build}/node_modules') {
args.install = true
}
if args.install {
factory.install(args.reset, args.template_update)!
}
if args.install {
factory.install(args.reset, args.template_update)!
}
return factory
}
pub fn dsite_get(name_ string) !&DocSite {
name := texttools.name_fix(name_)
return docusaurus_sites[name] or {
return error('docusaurus site with name "${name}" does not exist')
}
name := texttools.name_fix(name_)
return docusaurus_sites[name] or {
return error('docusaurus site with name "${name}" does not exist')
}
}
pub fn dsite_exists(name_ string) !bool {
name := texttools.name_fix(name_)
d := docusaurus_sites[name] or {
return false
}
return true
name := texttools.name_fix(name_)
d := docusaurus_sites[name] or { return false }
return true
}