Skip to content
Merged
Show file tree
Hide file tree
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
Prev Previous commit
Next Next commit
add blog homepaget
  • Loading branch information
montanalow committed Nov 26, 2023
commit 300f04fbe5fd928f1a543fe5fdfd16fbd1ed0a9c
316 changes: 172 additions & 144 deletions pgml-dashboard/src/api/cms.rs

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions pgml-dashboard/src/components/cms/content/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
pub struct Content {

}
pub struct Content {}
2 changes: 1 addition & 1 deletion pgml-dashboard/src/components/cms/toc_link/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pub struct TocLink {}
pub struct TocLink {}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
<% } %>

<%+ MarketingLink::new().link(StaticNavLink::new("Docs".to_string(), "/docs/".to_string())) %>
<%+ MarketingLink::new().link(StaticNavLink::new("Blog".to_string(), "/blog/speeding-up-vector-recall-by-5x-with-hnsw".to_string())) %>
<%+ MarketingLink::new().link(StaticNavLink::new("Blog".to_string(), "/blog/".to_string())) %>

<% if !standalone_dashboard { %>
<div class="d-none d-xl-flex">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<div class="vr my-2 opacity-100 d-lg-block d-none" style="width: 2px"></div>

<li class="nav-item d-flex align-items-center">
<a class="nav-link p-lg-0" href="/blog/speeding-up-vector-recall-by-5x-with-hnsw">Blog</a>
<a class="nav-link p-lg-0" href="/blog/">Blog</a>
</li>

<% if !account_management_nav.links.is_empty() { %>
Expand Down Expand Up @@ -84,7 +84,7 @@
</li>

<li class="menu-item rounded-0 d-flex align-items-center">
<a href="/blog/speeding-up-vector-recall-by-5x-with-hnsw">Blog</a>
<a href="/blog/">Blog</a>
</li>

<% if !standalone_dashboard { %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl MarketingFooter {
StaticNavLink::new("Documentation".into(), "/docs/".into()),
StaticNavLink::new(
"Blog".into(),
"/blog/speeding-up-vector-recall-by-5x-with-hnsw".into(),
"/blog/".into(),
),
],
company: vec![StaticNavLink::new(
Expand Down
2 changes: 1 addition & 1 deletion pgml-dashboard/src/templates/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use pgml_components::Component;
use std::collections::HashMap;

pub use crate::components::{self, NavLink, StaticNav, StaticNavLink, cms::index_link::IndexLink};
pub use crate::components::{self, cms::index_link::IndexLink, NavLink, StaticNav, StaticNavLink};

use sailfish::TemplateOnce;
use sqlx::postgres::types::PgMoney;
Expand Down
16 changes: 12 additions & 4 deletions pgml-dashboard/src/utils/config.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{
env::var,
borrow::Cow,
path::{Path, PathBuf}
env::var,
path::{Path, PathBuf},
};

use lazy_static::lazy_static;
Expand Down Expand Up @@ -53,8 +53,16 @@ impl Config {
let css_version = env_string_default("CSS_VERSION", "");
let js_version = env_string_default("JS_VERSION", "1");

let css_extension = if dev_mode { "css".to_string() } else { format!("{css_version}.css") };
let js_extension = if dev_mode { "js".to_string() } else { format!("{js_version}.js") };
let css_extension = if dev_mode {
"css".to_string()
} else {
format!("{css_version}.css")
};
let js_extension = if dev_mode {
"js".to_string()
} else {
format!("{js_version}.js")
};

Config {
dev_mode,
Expand Down
69 changes: 0 additions & 69 deletions pgml-dashboard/src/utils/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use tantivy::tokenizer::{LowerCaser, NgramTokenizer, TextAnalyzer};
use tantivy::{Index, IndexReader, SnippetGenerator};
use url::Url;

use crate::components::cms::index_link::IndexLink;
use std::fmt;

pub struct MarkdownHeadings {
Expand Down Expand Up @@ -572,74 +571,6 @@ pub fn nest_relative_links(node: &mut markdown::mdast::Node, path: &PathBuf) {
});
}

pub fn get_sub_links(list: &markdown::mdast::List, path: &Path) -> Result<Vec<IndexLink>> {
let mut links = Vec::new();
for node in list.children.iter() {
match node {
markdown::mdast::Node::ListItem(list_item) => {
for node in list_item.children.iter() {
match node {
markdown::mdast::Node::Paragraph(paragraph) => {
for node in paragraph.children.iter() {
match node {
markdown::mdast::Node::Link(link) => {
for node in link.children.iter() {
match node {
markdown::mdast::Node::Text(text) => {
let mut url = Path::new(&link.url)
.with_extension("")
.to_string_lossy()
.to_string();
if url.ends_with("README") {
url = url.replace("README", "");
}
let url = path
.join(url)
.into_os_string()
.into_string()
.unwrap();
let parent = IndexLink::new(text.value.as_str())
.href(&url);
links.push(parent);
}
_ => error!("unhandled link child: {:?}", node),
}
}
}
_ => error!("unhandled paragraph child: {:?}", node),
}
}
}
markdown::mdast::Node::List(list) => {
let mut link = links.pop().unwrap();
link.children = get_sub_links(list, path).unwrap();
links.push(link);
}
_ => error!("unhandled list_item child: {:?}", node),
}
}
}
_ => error!("unhandled list child: {:?}", node),
}
}
Ok(links)
}

pub fn parse_summary_into_nav_links(
root: &markdown::mdast::Node,
path: &Path,
) -> Result<Vec<IndexLink>> {
for node in root.children().unwrap().iter() {
match node {
markdown::mdast::Node::List(list) => {
return get_sub_links(list, path);
}
_ => { /* irrelevant */ }
}
}
return Ok(vec![]);
}

/// Get the title of the article.
///
/// # Arguments
Expand Down