60 lines
1.5 KiB
V
60 lines
1.5 KiB
V
module docusaurus
|
|
|
|
import os
|
|
// import freeflowuniverse.herolib.data.doctree.collection
|
|
import freeflowuniverse.herolib.core.pathlib
|
|
// import freeflowuniverse.herolib.ui.console
|
|
// import freeflowuniverse.herolib.core.base
|
|
import freeflowuniverse.herolib.develop.gittools
|
|
|
|
@[heap]
|
|
pub struct DocusaurusFactory {
|
|
pub mut:
|
|
sites []&DocSite @[skip; str: skip]
|
|
path_build pathlib.Path
|
|
// path_publish pathlib.Path
|
|
args DocusaurusArgs
|
|
config Config // Stores configuration from HeroScript if provided
|
|
}
|
|
|
|
@[params]
|
|
pub struct DocusaurusArgs {
|
|
pub mut:
|
|
// publish_path string
|
|
build_path string
|
|
production bool
|
|
update bool
|
|
heroscript string
|
|
heroscript_path string
|
|
}
|
|
|
|
pub fn new(args_ DocusaurusArgs) !&DocusaurusFactory {
|
|
mut args := args_
|
|
if args.build_path == '' {
|
|
args.build_path = '${os.home_dir()}/hero/var/docusaurus'
|
|
}
|
|
// if args.publish_path == ""{
|
|
// args.publish_path = "${os.home_dir()}/hero/var/docusaurus/publish"
|
|
// }
|
|
|
|
// Create the factory instance
|
|
mut ds := &DocusaurusFactory{
|
|
args: args_
|
|
path_build: pathlib.get_dir(path: args.build_path, create: true)!
|
|
// path_publish: pathlib.get_dir(path: args_.publish_path, create: true)!
|
|
}
|
|
|
|
// Process HeroScript if provided
|
|
if args.heroscript != '' || args.heroscript_path != '' {
|
|
// Use the play function to process the HeroScript
|
|
ds.config = play(
|
|
heroscript: args.heroscript
|
|
heroscript_path: args.heroscript_path
|
|
)!
|
|
}
|
|
|
|
ds.template_install(install: true, template_update: args.update, delete: true)!
|
|
|
|
return ds
|
|
}
|