From 5fc0909ce75d30ae21a7f68126fcc4e72a7aa831 Mon Sep 17 00:00:00 2001 From: Mahmoud-Emad Date: Tue, 14 Oct 2025 13:08:03 +0300 Subject: [PATCH] refactor: Rename docusaurus command to docs - Change command name from 'docusaurus' to 'docs' - Update path handling for empty Docusaurus paths - Adjust example usage in documentation --- lib/core/herocmds/docusaurus.v | 2 +- .../doctree/collection/data/process_link.v | 22 ++++++++++++++----- lib/web/docusaurus/README.md | 7 +++--- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/lib/core/herocmds/docusaurus.v b/lib/core/herocmds/docusaurus.v index 4ae770c1..0059745d 100644 --- a/lib/core/herocmds/docusaurus.v +++ b/lib/core/herocmds/docusaurus.v @@ -9,7 +9,7 @@ import cli { Command, Flag } pub fn cmd_docusaurus(mut cmdroot Command) Command { mut cmd_run := Command{ - name: 'docusaurus' + name: 'docs' description: 'Generate, build, run docusaurus sites.' required_args: 0 execute: cmd_docusaurus_execute diff --git a/lib/data/doctree/collection/data/process_link.v b/lib/data/doctree/collection/data/process_link.v index fc97aded..be5b8b94 100644 --- a/lib/data/doctree/collection/data/process_link.v +++ b/lib/data/doctree/collection/data/process_link.v @@ -39,12 +39,24 @@ pub fn (page Page) process_links(paths map[string]string) ![]string { // Try to get Docusaurus-specific path from Redis if docusaurus_path := redis.hget('doctree_docusaurus_paths', ptr.str()) { - // Use Docusaurus path (already without .md extension) - // Ensure it starts with / for absolute path - if docusaurus_path.starts_with('/') { - path = docusaurus_path + // Only use the Docusaurus path if it's not empty + if docusaurus_path.trim_space() != '' { + // Use Docusaurus path (already without .md extension) + // Ensure it starts with / for absolute path + if docusaurus_path.starts_with('/') { + path = docusaurus_path + } else { + path = '/' + docusaurus_path + } } else { - path = '/' + docusaurus_path + // Empty Docusaurus path, fall back to default behavior + // Fall back to default behavior: relative paths with .md + if ptr.collection == page.collection_name { + // same directory + path = './' + path.all_after_first('/') + } else { + path = '../${path}' + } } } else { // Fall back to default behavior: relative paths with .md diff --git a/lib/web/docusaurus/README.md b/lib/web/docusaurus/README.md index acb857f7..6bbba091 100644 --- a/lib/web/docusaurus/README.md +++ b/lib/web/docusaurus/README.md @@ -15,16 +15,15 @@ For quick setup and development, use the hero command: ```bash # Start development server -hero docusaurus -d -path /path/to/your/site +hero docs -d -path /path/to/your/site # Build for production -hero docusaurus -b -path /path/to/your/site +hero docs -b -path /path/to/your/site # Build and publish -hero docusaurus -bp -path /path/to/your/site +hero docs -bp -path /path/to/your/site ``` - ### Example HeroScript ```heroscript