Merge pull request #172 from Incubaid/development_docs_timur
docusaurus hero fix
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
module data
|
module data
|
||||||
|
|
||||||
import freeflowuniverse.herolib.core.texttools
|
import freeflowuniverse.herolib.core.texttools
|
||||||
|
import freeflowuniverse.herolib.core.base
|
||||||
import freeflowuniverse.herolib.data.markdown.elements
|
import freeflowuniverse.herolib.data.markdown.elements
|
||||||
import freeflowuniverse.herolib.data.doctree.pointer
|
import freeflowuniverse.herolib.data.doctree.pointer
|
||||||
|
|
||||||
@@ -32,11 +33,27 @@ pub fn (page Page) process_links(paths map[string]string) ![]string {
|
|||||||
doc.linked_pages << ptr.str()
|
doc.linked_pages << ptr.str()
|
||||||
}
|
}
|
||||||
|
|
||||||
if ptr.collection == page.collection_name {
|
// Check if Docusaurus-specific paths are available in Redis
|
||||||
// same directory
|
mut context := base.context() or { base.context_new()! }
|
||||||
path = './' + path.all_after_first('/')
|
mut redis := context.redis() or { panic('Redis not available') }
|
||||||
|
|
||||||
|
// 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
|
||||||
|
} else {
|
||||||
|
path = '/' + docusaurus_path
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
path = '../${path}'
|
// 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}'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ptr.cat == .image && element.extra.trim_space() != '' {
|
if ptr.cat == .image && element.extra.trim_space() != '' {
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
module docusaurus
|
module docusaurus
|
||||||
|
|
||||||
import freeflowuniverse.herolib.core.pathlib
|
import freeflowuniverse.herolib.core.pathlib
|
||||||
import freeflowuniverse.herolib.web.site as sitemodule
|
import freeflowuniverse.herolib.core.base
|
||||||
|
import freeflowuniverse.herolib.core.texttools
|
||||||
|
import freeflowuniverse.herolib.web.site { Site, SiteConfig }
|
||||||
import freeflowuniverse.herolib.osal.core as osal
|
import freeflowuniverse.herolib.osal.core as osal
|
||||||
import freeflowuniverse.herolib.ui.console
|
import freeflowuniverse.herolib.ui.console
|
||||||
|
|
||||||
@@ -15,7 +17,7 @@ pub mut:
|
|||||||
path_build pathlib.Path
|
path_build pathlib.Path
|
||||||
errors []SiteError
|
errors []SiteError
|
||||||
config Configuration
|
config Configuration
|
||||||
website sitemodule.Site
|
website site.Site
|
||||||
generated bool
|
generated bool
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,13 +103,13 @@ pub mut:
|
|||||||
cat ErrorCat
|
cat ErrorCat
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut site DocSite) error(args ErrorArgs) {
|
pub fn (mut s DocSite) error(args ErrorArgs) {
|
||||||
// path2 := pathlib.get(args.path)
|
// path2 := pathlib.get(args.path)
|
||||||
e := SiteError{
|
e := SiteError{
|
||||||
path: args.path
|
path: args.path
|
||||||
msg: args.msg
|
msg: args.msg
|
||||||
cat: args.cat
|
cat: args.cat
|
||||||
}
|
}
|
||||||
site.errors << e
|
s.errors << e
|
||||||
console.print_stderr(args.msg)
|
console.print_stderr(args.msg)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ pub fn (mut docsite DocSite) generate() ! {
|
|||||||
|
|
||||||
console.print_header(' docsite generate: ${docsite.name} on ${c.path_build.path}')
|
console.print_header(' docsite generate: ${docsite.name} on ${c.path_build.path}')
|
||||||
|
|
||||||
|
// Store Docusaurus site structure in Redis for link processing
|
||||||
|
docsite.store_site_structure()!
|
||||||
|
|
||||||
osal.rm('${c.path_build.path}/docs')!
|
osal.rm('${c.path_build.path}/docs')!
|
||||||
|
|
||||||
cfg_path := '${c.path_build.path}/cfg'
|
cfg_path := '${c.path_build.path}/cfg'
|
||||||
|
|||||||
40
lib/web/docusaurus/dsite_store_structure.v
Normal file
40
lib/web/docusaurus/dsite_store_structure.v
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
module docusaurus
|
||||||
|
|
||||||
|
import freeflowuniverse.herolib.core.base
|
||||||
|
import freeflowuniverse.herolib.core.texttools
|
||||||
|
|
||||||
|
// Store the Docusaurus site structure in Redis for link processing
|
||||||
|
// This maps collection:page to their actual Docusaurus paths
|
||||||
|
pub fn (mut docsite DocSite) store_site_structure() ! {
|
||||||
|
mut context := base.context()!
|
||||||
|
mut redis := context.redis()!
|
||||||
|
|
||||||
|
// Store mapping of collection:page to docusaurus path (without .md extension)
|
||||||
|
for page in docsite.website.pages {
|
||||||
|
parts := page.src.split(':')
|
||||||
|
if parts.len != 2 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
collection_name := texttools.name_fix(parts[0])
|
||||||
|
page_name := texttools.name_fix(parts[1])
|
||||||
|
|
||||||
|
// Calculate the docusaurus path (without .md extension for URLs)
|
||||||
|
mut doc_path := page.path
|
||||||
|
|
||||||
|
// Handle empty or root path
|
||||||
|
if doc_path.trim_space() == '' || doc_path == '/' {
|
||||||
|
doc_path = page_name
|
||||||
|
} else if doc_path.ends_with('/') {
|
||||||
|
doc_path += page_name
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove .md extension if present for URL paths
|
||||||
|
if doc_path.ends_with('.md') {
|
||||||
|
doc_path = doc_path[..doc_path.len - 3]
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store in Redis with key format: collection:page.md
|
||||||
|
key := '${collection_name}:${page_name}.md'
|
||||||
|
redis.hset('doctree_docusaurus_paths', key, doc_path)!
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user