From 822b179ef45ad9d470b200aa8676e1a6bbfc75d1 Mon Sep 17 00:00:00 2001 From: timurgordon Date: Mon, 19 May 2025 11:19:19 +0300 Subject: [PATCH] docusaurus fixes --- lib/biz/bizmodel/export.v | 2 +- lib/web/docusaurus/dsite.v | 78 +----- lib/web/docusaurus/dsite_get.v | 8 +- lib/web/docusaurus/factory.v | 2 +- lib/web/docusaurus/generate.v | 229 ++++++++++++++++++ lib/web/docusaurus/model_configuration.v | 101 ++++++++ lib/web/docusaurus/process.v | 35 +++ lib/web/docusaurus/template.v | 196 --------------- .../docusaurus/templates/docusaurus.config.ts | 63 ++--- lib/web/docusaurus/templates/package.json | 14 +- lib/web/docusaurus/templates/sidebars.ts | 2 +- lib/web/docusaurus/templates/tsconfig.json | 2 +- 12 files changed, 419 insertions(+), 313 deletions(-) create mode 100644 lib/web/docusaurus/generate.v create mode 100644 lib/web/docusaurus/model_configuration.v create mode 100644 lib/web/docusaurus/process.v delete mode 100644 lib/web/docusaurus/template.v diff --git a/lib/biz/bizmodel/export.v b/lib/biz/bizmodel/export.v index 800b43a9..10dd07e4 100644 --- a/lib/biz/bizmodel/export.v +++ b/lib/biz/bizmodel/export.v @@ -71,7 +71,7 @@ pub fn (r Report) export(export Export) ! { path: export.path publish_path: export.path init: true - config: docusaurus.Config{ + config: docusaurus.Configuration{ navbar: docusaurus.Navbar{ title: 'Business Model' items: [ diff --git a/lib/web/docusaurus/dsite.v b/lib/web/docusaurus/dsite.v index 0b7145cc..02292645 100644 --- a/lib/web/docusaurus/dsite.v +++ b/lib/web/docusaurus/dsite.v @@ -21,7 +21,7 @@ pub mut: // path_publish pathlib.Path args DSiteGetArgs errors []SiteError - config Config + config Configuration factory &DocusaurusFactory @[skip; str: skip] // Reference to the parent } @@ -66,7 +66,6 @@ pub fn (mut s DocSite) open() ! { pub fn (mut s DocSite) dev() ! { - s.clean()! s.generate()! // Create screen session for docusaurus development server @@ -151,72 +150,6 @@ fn (mut site DocSite) check() ! { } } -pub fn (mut site DocSite) generate() ! { - console.print_header(' site generate: ${site.name} on ${site.path_build.path}') - console.print_header(' site source on ${site.path_src.path}') - site.check()! - site.template_install()! - - // Now copy all directories that exist in src to build - for item in ['src', 'static', 'cfg'] { - if os.exists('${site.path_src.path}/${item}') { - mut aa := site.path_src.dir_get(item)! - aa.copy(dest: '${site.path_build.path}/${item}')! - } - } - for item in ['docs'] { - 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)! - } - } - - mut gs := gittools.new()! - - for item in site.config.import_sources { - mypath := gs.get_path( - pull: false - reset: false - url: item.url - )! - mut mypatho := pathlib.get(mypath) - site.process_md(mut mypatho, item)! - } -} - -fn (mut site DocSite) process_md(mut path pathlib.Path, args ImportSource) ! { - if path.is_dir() { - mut pathlist_images := path.list( - regex: [r'.*\.png$', r'.*\.jpg$', r'.*\.svg$', r'.*\.jpeg$'] - recursive: true - )! - for mut mypatho_img in pathlist_images.paths { - // now copy the image to the dest - dest := '${site.path_build.path}/docs/${args.dest}/img/${texttools.name_fix(mypatho_img.name())}' - // println("image copy: ${dest}") - mypatho_img.copy(dest: dest, rsync: false)! - } - - mut pathlist := path.list(regex: [r'.*\.md$'], recursive: true)! - for mut mypatho2 in pathlist.paths { - site.process_md(mut mypatho2, args)! - } - return - } - mydest := '${site.path_build.path}/docs/${args.dest}/${texttools.name_fix(path.name())}' - mut mydesto := pathlib.get_file(path: mydest, create: true)! - - mut mymd := markdownparser.new(path: path.path)! - mut myfm := mymd.frontmatter2()! - if !args.visible { - myfm.args['draft'] = 'true' - } - // println(myfm) - // println(mymd.markdown()!) - mydesto.write(mymd.markdown()!)! - // Note: exit(0) was removed to prevent unexpected program termination -} - fn (mut site DocSite) template_install() ! { mut gs := gittools.new()! @@ -237,7 +170,7 @@ fn (mut site DocSite) template_install() ! { develop := $tmpl('templates/develop.sh') build := $tmpl('templates/build.sh') - build_dev_publish := $tmpl('templates/build_dev_publish.sh') + // build_dev_publish := $tmpl('templates/build_dev_publish.sh') build_publish := $tmpl('templates/build_publish.sh') mut develop_ := site.path_build.file_get_new('develop.sh')! @@ -252,9 +185,10 @@ fn (mut site DocSite) template_install() ! { build_publish_.template_write(build_publish, true)! build_publish_.chmod(0o700)! - 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)! + // TODO: implement + // 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')! diff --git a/lib/web/docusaurus/dsite_get.v b/lib/web/docusaurus/dsite_get.v index 710c8e50..34246f72 100644 --- a/lib/web/docusaurus/dsite_get.v +++ b/lib/web/docusaurus/dsite_get.v @@ -21,7 +21,7 @@ pub mut: open bool init bool // means create new one if needed deploykey string - config ?Config + config ?Configuration } pub fn (mut f DocusaurusFactory) get(args_ DSiteGetArgs) !&DocSite { @@ -54,10 +54,10 @@ pub fn (mut f DocusaurusFactory) get(args_ DSiteGetArgs) !&DocSite { // First, check if the new site args provides a configuration if cfg := args.config { // Use the provided config - cfg.write('${args.path}/cfg')! + generate_configuration(args.path, cfg)! } else if f.config.main.title != '' { // Use the factory's config from heroscript if available - f.config.write('${args.path}/cfg')! + generate_configuration(args.path, f.config)! } else { // Then ensure cfg directory exists in src, if !os.exists('${args.path}/cfg') { @@ -94,7 +94,7 @@ This is a default page created by the Docusaurus site generator. } } - mut myconfig := load_config('${args.path}/cfg')! + mut myconfig := load_configuration('${args.path}/cfg')! if myconfig.main.name.len == 0 { myconfig.main.name = myconfig.main.base_url.trim_space().trim('/').trim_space() diff --git a/lib/web/docusaurus/factory.v b/lib/web/docusaurus/factory.v index cf9dc6db..ddf9e7e7 100644 --- a/lib/web/docusaurus/factory.v +++ b/lib/web/docusaurus/factory.v @@ -15,7 +15,7 @@ pub mut: path_build pathlib.Path // path_publish pathlib.Path args DocusaurusArgs - config Config // Stores configuration from HeroScript if provided + config Configuration // Stores configuration from HeroScript if provided } @[params] diff --git a/lib/web/docusaurus/generate.v b/lib/web/docusaurus/generate.v new file mode 100644 index 00000000..86fbde36 --- /dev/null +++ b/lib/web/docusaurus/generate.v @@ -0,0 +1,229 @@ +module docusaurus + +import freeflowuniverse.herolib.develop.gittools +import freeflowuniverse.herolib.osal +import freeflowuniverse.herolib.installers.web.bun +import freeflowuniverse.herolib.core.pathlib +import json +import os +import freeflowuniverse.herolib.ui.console + +@[params] +struct TemplateInstallArgs { + template_update bool = true + install bool = true + delete bool = true +} + +pub fn (mut site DocSite) generate() ! { + console.print_header(' site generate: ${site.name} on ${site.path_build.path}') + console.print_header(' site source on ${site.path_src.path}') + site.check()! + site.template_install()! + + site.config = fix_configuration(site.config)! + generate_configuration(site.path_build.path, site.config)! + generate_docusaurus_config_ts(site.path_build.path, site.config)! + + // Now copy all directories that exist in src to build + for item in ['src', 'static', 'cfg'] { + if os.exists('${site.path_src.path}/${item}') { + mut aa := site.path_src.dir_get(item)! + aa.copy(dest: '${site.path_build.path}/${item}')! + } + } + for item in ['docs'] { + 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)! + } + } + + mut gs := gittools.new()! + + // for item in site.config.import_sources { + // mypath := gs.get_path( + // pull: false + // reset: false + // url: item.url + // )! + // mut mypatho := pathlib.get(mypath) + // site.process_md(mut mypatho, item)! + // } +} + +fn generate_configuration(path string, config Configuration) ! { + cfg_path := os.join_path(path, 'cfg') + + mut main_file := pathlib.get_file(path: '${cfg_path}/main.json', create: true)! + main_file.write(json.encode(config.main))! + + mut navbar_file := pathlib.get_file(path: '${cfg_path}/navbar.json', create: true)! + navbar_file.write(json.encode(config.navbar))! + + mut footer_file := pathlib.get_file(path: '${cfg_path}/footer.json', create: true)! + footer_file.write(json.encode(config.footer))! +} + +fn generate_docusaurus_config_ts(path string, config Configuration) ! { + mut config_file := pathlib.get_file( + path: os.join_path(path, 'docusaurus.config.ts') + create: true + )! + content := $tmpl('templates/docusaurus.config.ts') + config_file.write(content)! +} + +fn (mut self DocusaurusFactory) template_install(args TemplateInstallArgs) ! { + mut gs := gittools.new()! + + mut r := gs.get_repo( + url: 'https://github.com/freeflowuniverse/docusaurus_template.git' + pull: args.template_update + )! + mut template_path := r.patho()! + + // always start from template first for static assets and source files + for item in ['src', 'static'] { + mut aa := template_path.dir_get(item)! + aa.copy(dest: '${self.path_build.path}/${item}', delete: args.delete)! + } + + // Generate config files dynamically from config + self.generate_package_json()! + self.generate_tsconfig_json()! + self.generate_sidebars_ts()! + self.generate_gitignore()! + + if args.install { + // install bun + mut installer := bun.get()! + installer.install()! + + osal.exec( + cmd: ' + ${osal.profile_path_source_and()!} + export PATH=/tmp/docusaurus_build/node_modules/.bin:${os.home_dir()}/.bun/bin/:??PATH + cd ${self.path_build.path} + bun install + ' + )! + } +} + +fn (mut self DocusaurusFactory) generate_gitignore() ! { + mut gitignore := pathlib.get_file( + path: os.join_path(self.path_build.path, '.gitignore') + create: true + )! + content := $tmpl('templates/.gitignore') + gitignore.write(content)! +} + +// Generate package.json based on the configuration +fn (mut self DocusaurusFactory) generate_package_json() ! { + // Build package.json content as a structured JSON string + mut name := 'docusaurus-site' + if self.config.main.name != '' { + name = self.config.main.name + } else if self.config.navbar.title != '' { + name = self.config.navbar.title.to_lower().replace(' ', '-') + } + + // Load package.json from template + // The 'name' variable is defined in this function's scope and will be used by $tmpl. + content := $tmpl('templates/package.json') + mut package_file := pathlib.get_file( + path: os.join_path(self.path_build.path, 'package.json') + create: true + )! + package_file.write(content)! +} + +// Generate tsconfig.json based on the configuration +fn (mut self DocusaurusFactory) generate_tsconfig_json() ! { + // Load tsconfig.json from template + content := $tmpl('templates/tsconfig.json') + mut tsconfig_file := pathlib.get_file( + path: os.join_path(self.path_build.path, 'tsconfig.json') + create: true + )! + tsconfig_file.write(content)! +} + +// Generate sidebars.ts based on the configuration +fn (mut self DocusaurusFactory) generate_sidebars_ts() ! { + // Load sidebars.ts from template + content := $tmpl('templates/sidebars.ts') + mut sidebars_file := pathlib.get_file( + path: os.join_path(self.path_build.path, 'sidebars.ts') + create: true + )! + sidebars_file.write(content)! +} + +// // Generate docusaurus.config.ts based on the configuration +// fn (mut self DocusaurusFactory) generate_docusaurus_config_ts() ! { +// // Use config values with fallbacks +// title := if self.config.main.title != '' { self.config.main.title } else { 'Docusaurus Site' } + +// // Format navbar items from config +// mut navbar_items_list_temp := []string{} +// for item in self.config.navbar.items { +// navbar_items_list_temp << "{ +// label: '${item.label}', +// href: '${item.href}', +// position: '${item.position}' +// }" +// } + +// // Generate footer links if available +// mut footer_links_list_temp := []string{} +// for link in self.config.footer.links { +// mut items_temp := []string{} +// for item in link.items { +// mut item_str := '{' +// if item.label != '' { +// item_str += "label: '${item.label}', " +// } +// if item.href != '' { +// item_str += "href: '${item.href}'" +// } else if item.to != '' { +// item_str += "to: '${item.to}'" +// } else { +// item_str += "to: '/docs'" // Default link +// } +// item_str += '}' +// items_temp << item_str +// } +// footer_links_list_temp << "{ +// title: '${link.title}', +// items: [ +// ${items_temp.join(',\n ')} +// ] +// }" +// } + +// // Year for copyright +// year := time.now().year.str() + +// // Copyright string (variable `copyright` must be in scope for the template) +// // `title` is defined at line 181, `year` is defined above. +// copyright := if self.config.main.copyright != '' { +// self.config.main.copyright +// } else { +// 'Copyright © ${year} ${title}' +// } + +// // Load docusaurus.config.ts from template +// // All required variables (title, tagline, favicon, url, base_url, +// // projectName, navbarTitle, navbarItems, footerLinks, copyright) +// // are in scope for $tmpl. +// content := $tmpl('templates/docusaurus.config.ts') + +// mut config_file := pathlib.get_file( +// path: os.join_path(self.path_build.path, 'docusaurus.config.ts') +// create: true +// )! +// config_file.write(content)! +// } diff --git a/lib/web/docusaurus/model_configuration.v b/lib/web/docusaurus/model_configuration.v new file mode 100644 index 00000000..26e8f984 --- /dev/null +++ b/lib/web/docusaurus/model_configuration.v @@ -0,0 +1,101 @@ +module docusaurus + +import os +import json +import freeflowuniverse.herolib.core.pathlib + +pub struct Configuration { + pub mut: + main Main + navbar Navbar + footer Footer + } + +pub struct Main { + pub mut: + title string + tagline string + favicon string + url string + base_url string @[json: 'baseUrl'] + url_home string + image string + metadata Metadata + build_dest []string @[json: 'buildDest'] + build_dest_dev []string @[json: 'buildDestDev'] + copyright string + name string + } + +pub struct Metadata { + pub mut: + description string + image string + title string + } + +pub struct Navbar { + pub mut: + title string + logo Logo + items []NavbarItem + } + +pub struct Logo { + pub mut: + alt string + src string + src_dark string @[json: 'srcDark'] + } + +pub struct NavbarItem { + pub mut: + label string + href string + position string + to string + } + +pub struct Footer { + pub mut: + style string + links []FooterLink + } + +pub struct FooterLink { + pub mut: + title string + items []FooterItem + } + +pub struct FooterItem { + pub mut: + label string + href string + to string + } + +pub fn load_configuration(cfg_path string) !Configuration { + mut main_json := pathlib.get_file(path: os.join_path(cfg_path, 'main.json'))! + mut navbar_json := pathlib.get_file(path: os.join_path(cfg_path, 'navbar.json'))! + mut footer_json := pathlib.get_file(path: os.join_path(cfg_path, 'footer.json'))! + mut cfg := Configuration{ + main: json.decode(Main, main_json.read()!)!, + navbar: json.decode(Navbar, navbar_json.read()!)!, + footer: json.decode(Footer, footer_json.read()!)! + } + return cfg +} + +pub fn fix_configuration(config Configuration) !Configuration { + return Configuration { + ...config, + main: Main { + ...config.main, + title: if config.main.title == "" { "Docusaurus" } else { config.main.title }, + favicon: if config.main.favicon == "" { "img/favicon.ico" } else { config.main.favicon }, + url: if config.main.url == "" { "https://example.com" } else { config.main.url }, + base_url: if config.main.base_url == "" { "/" } else { config.main.base_url }, + } + } +} \ No newline at end of file diff --git a/lib/web/docusaurus/process.v b/lib/web/docusaurus/process.v new file mode 100644 index 00000000..52cae2a4 --- /dev/null +++ b/lib/web/docusaurus/process.v @@ -0,0 +1,35 @@ +module docusaurus + + +// fn (mut site DocSite) process_md(mut path pathlib.Path, args ImportSource) ! { +// if path.is_dir() { +// mut pathlist_images := path.list( +// regex: [r'.*\.png$', r'.*\.jpg$', r'.*\.svg$', r'.*\.jpeg$'] +// recursive: true +// )! +// for mut mypatho_img in pathlist_images.paths { +// // now copy the image to the dest +// dest := '${site.path_build.path}/docs/${args.dest}/img/${texttools.name_fix(mypatho_img.name())}' +// // println("image copy: ${dest}") +// mypatho_img.copy(dest: dest, rsync: false)! +// } + +// mut pathlist := path.list(regex: [r'.*\.md$'], recursive: true)! +// for mut mypatho2 in pathlist.paths { +// site.process_md(mut mypatho2, args)! +// } +// return +// } +// mydest := '${site.path_build.path}/docs/${args.dest}/${texttools.name_fix(path.name())}' +// mut mydesto := pathlib.get_file(path: mydest, create: true)! + +// mut mymd := markdownparser.new(path: path.path)! +// mut myfm := mymd.frontmatter2()! +// if !args.visible { +// myfm.args['draft'] = 'true' +// } +// // println(myfm) +// // println(mymd.markdown()!) +// mydesto.write(mymd.markdown()!)! +// // Note: exit(0) was removed to prevent unexpected program termination +// } \ No newline at end of file diff --git a/lib/web/docusaurus/template.v b/lib/web/docusaurus/template.v deleted file mode 100644 index 480627d6..00000000 --- a/lib/web/docusaurus/template.v +++ /dev/null @@ -1,196 +0,0 @@ -module docusaurus - -import freeflowuniverse.herolib.develop.gittools -import freeflowuniverse.herolib.osal -import freeflowuniverse.herolib.installers.web.bun -import freeflowuniverse.herolib.core.pathlib -import json -import os -import time - -@[params] -struct TemplateInstallArgs { - template_update bool = true - install bool = true - delete bool = true -} - -fn (mut self DocusaurusFactory) template_install(args TemplateInstallArgs) ! { - mut gs := gittools.new()! - - mut r := gs.get_repo( - url: 'https://github.com/freeflowuniverse/docusaurus_template.git' - pull: args.template_update - )! - mut template_path := r.patho()! - - // always start from template first for static assets and source files - for item in ['src', 'static'] { - mut aa := template_path.dir_get(item)! - aa.copy(dest: '${self.path_build.path}/${item}', delete: args.delete)! - } - - // Generate config files dynamically from config - self.generate_package_json()! - self.generate_tsconfig_json()! - self.generate_sidebars_ts()! - self.generate_docusaurus_config_ts()! - self.generate_gitignore()! - - if args.install { - // install bun - mut installer := bun.get()! - installer.install()! - - osal.exec( - cmd: ' - ${osal.profile_path_source_and()!} - export PATH=/tmp/docusaurus_build/node_modules/.bin:${os.home_dir()}/.bun/bin/:??PATH - cd ${self.path_build.path} - bun install - ' - )! - } - - // Only try to delete docs if it exists in the template - if os.exists(os.join_path(template_path.path, 'docs')) { - mut aa := template_path.dir_get('docs')! - aa.delete()! - } -} - -fn (mut self DocusaurusFactory) generate_gitignore() ! { - mut gitignore := pathlib.get_file( - path: os.join_path(self.path_build.path, '.gitignore') - create: true - )! - content := $tmpl('templates/.gitignore') - gitignore.write(content)! -} - -// Generate package.json based on the configuration -fn (mut self DocusaurusFactory) generate_package_json() ! { - // Build package.json content as a structured JSON string - mut name := 'docusaurus-site' - if self.config.main.name != '' { - name = self.config.main.name - } else if self.config.navbar.title != '' { - name = self.config.navbar.title.to_lower().replace(' ', '-') - } - - // Load package.json from template - // The 'name' variable is defined in this function's scope and will be used by $tmpl. - content := $tmpl('templates/package.json') - mut package_file := pathlib.get_file( - path: os.join_path(self.path_build.path, 'package.json') - create: true - )! - package_file.write(content)! -} - -// Generate tsconfig.json based on the configuration -fn (mut self DocusaurusFactory) generate_tsconfig_json() ! { - // Load tsconfig.json from template - content := $tmpl('templates/tsconfig.json') - mut tsconfig_file := pathlib.get_file( - path: os.join_path(self.path_build.path, 'tsconfig.json') - create: true - )! - tsconfig_file.write(content)! -} - -// Generate sidebars.ts based on the configuration -fn (mut self DocusaurusFactory) generate_sidebars_ts() ! { - // Load sidebars.ts from template - content := $tmpl('templates/sidebars.ts') - mut sidebars_file := pathlib.get_file( - path: os.join_path(self.path_build.path, 'sidebars.ts') - create: true - )! - sidebars_file.write(content)! -} - -// Generate docusaurus.config.ts based on the configuration -fn (mut self DocusaurusFactory) generate_docusaurus_config_ts() ! { - // Use config values with fallbacks - title := if self.config.main.title != '' { self.config.main.title } else { 'Docusaurus Site' } - tagline := if self.config.main.tagline != '' { - self.config.main.tagline - } else { - 'Documentation Site' - } - url := if self.config.main.url != '' { self.config.main.url } else { 'https://example.com' } - base_url := if self.config.main.base_url != '' { self.config.main.base_url } else { '/' } - favicon := if self.config.main.favicon != '' { - self.config.main.favicon - } else { - 'img/favicon.png' - } - - // Define additional variables for the template - // Variables `title`, `tagline`, `favicon`, `url`, `base_url` are already defined above (lines 181-193) - projectName := self.config.main.name - navbarTitle := self.config.navbar.title - - // Format navbar items from config - mut navbar_items_list_temp := []string{} - for item in self.config.navbar.items { - navbar_items_list_temp << "{ - label: '${item.label}', - href: '${item.href}', - position: '${item.position}' - }" - } - navbarItems := navbar_items_list_temp.join(',\n ') // Matches ${navbarItems} in template - - // Generate footer links if available - mut footer_links_list_temp := []string{} - for link in self.config.footer.links { - mut items_temp := []string{} - for item in link.items { - mut item_str := '{' - if item.label != '' { - item_str += "label: '${item.label}', " - } - if item.href != '' { - item_str += "href: '${item.href}'" - } else if item.to != '' { - item_str += "to: '${item.to}'" - } else { - item_str += "to: '/docs'" // Default link - } - item_str += '}' - items_temp << item_str - } - footer_links_list_temp << "{ - title: '${link.title}', - items: [ - ${items_temp.join(',\n ')} - ] - }" - } - footerLinks := footer_links_list_temp.join(',\n ') // Matches ${footerLinks} in template - - // Year for copyright - year := time.now().year.str() - - // Copyright string (variable `copyright` must be in scope for the template) - // `title` is defined at line 181, `year` is defined above. - copyright := if self.config.main.copyright != '' { - self.config.main.copyright - } else { - 'Copyright © ${year} ${title}' - } - - // Load docusaurus.config.ts from template - // All required variables (title, tagline, favicon, url, base_url, - // projectName, navbarTitle, navbarItems, footerLinks, copyright) - // are in scope for $tmpl. - content := $tmpl('templates/docusaurus.config.ts') - - mut config_file := pathlib.get_file( - path: os.join_path(self.path_build.path, 'docusaurus.config.ts') - create: true - )! - config_file.write(content)! -} diff --git a/lib/web/docusaurus/templates/docusaurus.config.ts b/lib/web/docusaurus/templates/docusaurus.config.ts index 164523f1..2eb1a59d 100644 --- a/lib/web/docusaurus/templates/docusaurus.config.ts +++ b/lib/web/docusaurus/templates/docusaurus.config.ts @@ -1,22 +1,22 @@ import {themes as prismThemes} from 'prism-react-renderer'; -import type {Config} from '@docusaurus/types'; -import type * as Preset from '@docusaurus/preset-classic'; +import type {Configuration} from '@@docusaurus/types'; +import type * as Preset from '@@docusaurus/preset-classic'; -const config: Config = { - title: '${title}', - tagline: '${tagline}', - favicon: '${favicon}', +const config: Configuration = { + title: '@{config.main.title}', + tagline: '@{config.main.tagline}', + favicon: '@{config.main.favicon}', // Set the production url of your site here - url: '${url}', + url: '@{config.main.url}', // Set the // pathname under which your site is served // For GitHub pages deployment, it is often '//' - baseUrl: '${base_url}', + baseUrl: '@{config.main.base_url}', // GitHub pages deployment config. // If you aren't using GitHub pages, you don't need these. organizationName: 'freeflowuniverse', // Usually your GitHub org/user name. - projectName: '${projectName}', // Usually your repo name. + projectName: '@{config.main.name}', // Usually your repo name. onBrokenLinks: 'warn', onBrokenMarkdownLinks: 'warn', @@ -44,42 +44,45 @@ const config: Config = { themeConfig: { // Replace with your project's social card image: 'img/docusaurus-social-card.jpg', + colorMode: { + defaultMode: 'dark', + }, navbar: { - title: '${navbarTitle}', + title: '@{config.navbar.title}', items: [ - @for item in navbar_items { + @for item in config.navbar.items { - label: '${item.label}', - href: '${item.href}', - position: '${item.position}' + label: '@{item.label}', + href: '@{item.href}', + position: '@{item.position}' }, - } + @end ], }, footer: { - style: '${footerStyle}', + style: '@{config.footer.style}', links: [ - @for link_group in footer_links { + @for link_group in config.footer.links { - title: '${link_group.title}', + title: '@{link_group.title}', items: [ - @for item in link_group.items { + @for item in link_group.items { - label: '${item.label}', - @if item.href != '' { - href: '${item.href}' - } @else if item.to != '' { - to: '${item.to}' - } @else { - to: '/docs' - } + label: '@{item.label}', + @if item.href != '' + href: '@{item.href}' + @else if item.to != '' + to: '@{item.to}' + @else + to: '/docs' + @end }, - } + @end ] }, - } + @end ], - copyright: '${copyright}', + copyright: '@{config.main.copyright}', }, prism: { theme: prismThemes.github, diff --git a/lib/web/docusaurus/templates/package.json b/lib/web/docusaurus/templates/package.json index ac14726c..936e58d9 100644 --- a/lib/web/docusaurus/templates/package.json +++ b/lib/web/docusaurus/templates/package.json @@ -1,5 +1,5 @@ { - "name": "${name}", + "name": "@{name}", "version": "0.0.1", "private": true, "scripts": { @@ -15,18 +15,18 @@ "typecheck": "tsc" }, "dependencies": { - "@docusaurus/core": "^3.1.0", - "@docusaurus/preset-classic": "^3.1.0", - "@mdx-js/react": "^3.0.0", + "@@docusaurus/core": "^3.1.0", + "@@docusaurus/preset-classic": "^3.1.0", + "@@mdx-js/react": "^3.0.0", "clsx": "^2.0.0", "prism-react-renderer": "^2.3.0", "react": "^18.0.0", "react-dom": "^18.0.0" }, "devDependencies": { - "@docusaurus/module-type-aliases": "^3.1.0", - "@docusaurus/tsconfig": "^3.1.0", - "@docusaurus/types": "^3.1.0", + "@@docusaurus/module-type-aliases": "^3.1.0", + "@@docusaurus/tsconfig": "^3.1.0", + "@@docusaurus/types": "^3.1.0", "typescript": "^5.2.2" }, "browserslist": { diff --git a/lib/web/docusaurus/templates/sidebars.ts b/lib/web/docusaurus/templates/sidebars.ts index 3dfb7297..a2b53bb4 100644 --- a/lib/web/docusaurus/templates/sidebars.ts +++ b/lib/web/docusaurus/templates/sidebars.ts @@ -1,4 +1,4 @@ -import type {SidebarsConfig} from '@docusaurus/plugin-content-docs'; +import type {SidebarsConfig} from '@@docusaurus/plugin-content-docs'; /** * Creating a sidebar enables you to: diff --git a/lib/web/docusaurus/templates/tsconfig.json b/lib/web/docusaurus/templates/tsconfig.json index b653946c..fb364589 100644 --- a/lib/web/docusaurus/templates/tsconfig.json +++ b/lib/web/docusaurus/templates/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "@docusaurus/tsconfig", + "extends": "@@docusaurus/tsconfig", "compilerOptions": { "baseUrl": ".", "resolveJsonModule": true