refactor: Remove Docusaurus path logic

- Remove Redis Docusaurus path lookup
- Simplify path generation logic
This commit is contained in:
Mahmoud-Emad
2025-10-14 17:45:45 +03:00
parent 5fc0909ce7
commit f5694dd4d7

View File

@@ -1,7 +1,6 @@
module data module data
import incubaid.herolib.core.texttools import incubaid.herolib.core.texttools
import incubaid.herolib.core.base
import incubaid.herolib.data.markdown.elements import incubaid.herolib.data.markdown.elements
import incubaid.herolib.data.doctree.pointer import incubaid.herolib.data.doctree.pointer
@@ -33,39 +32,11 @@ pub fn (page Page) process_links(paths map[string]string) ![]string {
doc.linked_pages << ptr.str() doc.linked_pages << ptr.str()
} }
// Check if Docusaurus-specific paths are available in Redis if ptr.collection == page.collection_name {
mut context := base.context() or { base.context_new()! } // same directory
mut redis := context.redis() or { panic('Redis not available') } path = './' + path.all_after_first('/')
// Try to get Docusaurus-specific path from Redis
if docusaurus_path := redis.hget('doctree_docusaurus_paths', ptr.str()) {
// 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 {
// 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 { } else {
// Fall back to default behavior: relative paths with .md path = '../${path}'
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() != '' {