🌐 AI搜索 & 代理 主页
Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Allow for filtering out of documents to add to search
  • Loading branch information
SilasMarvin committed Feb 29, 2024
commit 6d18877cd191a952b97cf9286d51a88652f81831
13 changes: 12 additions & 1 deletion pgml-dashboard/src/utils/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ use std::fmt;
use std::sync::Mutex;
use url::Url;

// Excluded paths in the pgml-cms directory
const EXCLUDED_DOCUMENT_PATHS: [&str; 1] = ["blog/README.md"];

pub struct MarkdownHeadings {
header_map: Arc<Mutex<HashMap<String, usize>>>,
}
Expand Down Expand Up @@ -1334,7 +1337,7 @@ impl SiteSearch {
results["results"]
.as_array()
.context("Error getting results from search")?
.into_iter()
.iter()
.map(|r| {
let SearchResultWithoutSnippet { title, contents, path } =
serde_json::from_value(r["document"].clone())?;
Expand All @@ -1358,6 +1361,14 @@ impl SiteSearch {
.map(|path| async move { Document::from_path(&path).await }),
)
.await?;
let documents: Vec<Document> = documents
.into_iter()
.filter(|f| {
!EXCLUDED_DOCUMENT_PATHS
.iter()
.any(|p| f.path == config::cms_dir().join(p))
})
.collect();
let documents: Vec<pgml::types::Json> = documents
.into_iter()
.map(|d| {
Expand Down