...
This commit is contained in:
parent
44cbf20d7b
commit
b9df692a54
@ -2,6 +2,9 @@
|
||||
name = "doctree"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
[lib]
|
||||
path = "src/lib.rs"
|
||||
|
||||
|
||||
[dependencies]
|
||||
walkdir = "2.3.3"
|
||||
|
@ -156,8 +156,11 @@ impl Collection {
|
||||
// Check if the path is valid
|
||||
if self.path.as_os_str().is_empty() {
|
||||
// If the path is empty, we're working with a collection loaded from Redis
|
||||
// Return a placeholder content for demonstration purposes
|
||||
return Ok(format!("Content for {} in collection {}\nThis is a placeholder since the actual file path is not available.", page_name, self.name));
|
||||
// Return an error since the actual file path is not available
|
||||
return Err(DocTreeError::IoError(std::io::Error::new(
|
||||
std::io::ErrorKind::NotFound,
|
||||
format!("File path not available for {} in collection {}", page_name, self.name)
|
||||
)));
|
||||
}
|
||||
|
||||
// Read the file
|
||||
|
@ -4,11 +4,11 @@ use std::sync::{Arc, Mutex};
|
||||
use std::fs;
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::collection::{Collection, CollectionBuilder};
|
||||
use crate::collection::Collection;
|
||||
use crate::error::{DocTreeError, Result};
|
||||
use crate::storage::RedisStorage;
|
||||
use crate::include::process_includes;
|
||||
use crate::utils::{name_fix, ensure_md_extension};
|
||||
use crate::utils::name_fix;
|
||||
|
||||
/// Configuration for a collection from a .collection file
|
||||
#[derive(Deserialize, Default, Debug)]
|
||||
|
@ -78,20 +78,3 @@ pub fn ensure_md_extension(name: &str) -> String {
|
||||
name.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the file extension from a path
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `path` - The path to check
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// The file extension or an empty string
|
||||
pub fn get_extension(path: &str) -> String {
|
||||
Path::new(path)
|
||||
.extension()
|
||||
.and_then(|ext| ext.to_str())
|
||||
.unwrap_or("")
|
||||
.to_string()
|
||||
}
|
Loading…
Reference in New Issue
Block a user