...
This commit is contained in:
@@ -18,10 +18,9 @@ pub mut:
|
||||
production bool
|
||||
watch_changes bool = true
|
||||
update bool
|
||||
open bool
|
||||
init bool // means create new one if needed
|
||||
init bool //means create new one if needed
|
||||
deploykey string
|
||||
config ?Configuration
|
||||
config ?Config
|
||||
}
|
||||
|
||||
pub fn (mut f DocusaurusFactory) get(args_ DSiteGetArgs) !&DocSite {
|
||||
@@ -41,60 +40,43 @@ pub fn (mut f DocusaurusFactory) get(args_ DSiteGetArgs) !&DocSite {
|
||||
args.path = gs.get_path(url: args.url)!
|
||||
}
|
||||
|
||||
if args.path.trim_space() == '' {
|
||||
if args.path.trim_space() == "" {
|
||||
args.path = os.getwd()
|
||||
}
|
||||
}
|
||||
args.path = args.path.replace('~', os.home_dir())
|
||||
|
||||
mut r := gs.get_repo(
|
||||
url: 'https://github.com/freeflowuniverse/docusaurus_template.git'
|
||||
url: 'https://github.com/freeflowuniverse/docusaurus_template.git'
|
||||
)!
|
||||
mut template_path := r.patho()!
|
||||
|
||||
// First, check if the new site args provides a configuration
|
||||
// First, check if the new site args provides a configuration that can be written instead of template cfg dir
|
||||
if cfg := args.config {
|
||||
// Use the provided config
|
||||
generate_configuration(args.path, cfg)!
|
||||
} else if f.config.main.title != '' {
|
||||
// Use the factory's config from heroscript if available
|
||||
generate_configuration(args.path, f.config)!
|
||||
panic("not implemented")
|
||||
// cfg.write('${args.path}/cfg')!
|
||||
} else {
|
||||
// Then ensure cfg directory exists in src,
|
||||
if !os.exists('${args.path}/cfg') {
|
||||
if args.init {
|
||||
if !os.exists('${args.path}/cfg') {
|
||||
if args.init{
|
||||
// else copy config from template
|
||||
mut template_cfg := template_path.dir_get('cfg')!
|
||||
template_cfg.copy(dest: '${args.path}/cfg')!
|
||||
} else {
|
||||
}else{
|
||||
return error("Can't find cfg dir in chosen docusaurus location: ${args.path}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !os.exists('${args.path}/docs') {
|
||||
if args.init {
|
||||
// Create docs directory if it doesn't exist in template or site
|
||||
os.mkdir_all('${args.path}/docs')!
|
||||
|
||||
// Create a default docs/intro.md file
|
||||
intro_content := '---
|
||||
title: Introduction
|
||||
slug: /
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
# Introduction
|
||||
|
||||
Welcome to the documentation site.
|
||||
|
||||
This is a default page created by the Docusaurus site generator.
|
||||
'
|
||||
os.write_file('${args.path}/docs/intro.md', intro_content)!
|
||||
} else {
|
||||
if args.init{
|
||||
mut template_cfg := template_path.dir_get('docs')!
|
||||
template_cfg.copy(dest: '${args.path}/docs')!
|
||||
}else{
|
||||
return error("Can't find docs dir in chosen docusaurus location: ${args.path}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mut myconfig := load_configuration('${args.path}/cfg')!
|
||||
mut myconfig := load_config('${args.path}/cfg')!
|
||||
|
||||
if myconfig.main.name.len == 0 {
|
||||
myconfig.main.name = myconfig.main.base_url.trim_space().trim('/').trim_space()
|
||||
@@ -115,8 +97,8 @@ This is a default page created by the Docusaurus site generator.
|
||||
path_src: pathlib.get_dir(path: args.path, create: false)!
|
||||
path_build: f.path_build
|
||||
// path_publish: pathlib.get_dir(path: args.publish_path, create: true)!
|
||||
args: args
|
||||
config: myconfig
|
||||
args: args
|
||||
config: myconfig
|
||||
factory: &f
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user