Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
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
84 changes: 73 additions & 11 deletions blogr-cli/src/commands/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,55 @@ pub async fn handle_list() -> Result<()> {
if all_themes.is_empty() {
println!(" 📦 No themes available");
} else {
// Separate themes by type
let mut blog_themes = Vec::new();
let mut personal_themes = Vec::new();

for (name, theme) in all_themes {
let info = theme.info();
let is_active = current_theme.as_ref() == Some(&name);
let status_icon = if is_active { "✅" } else { "📦" };
let status_text = if is_active { " (active)" } else { "" };
if info.site_type == "blog" {
blog_themes.push((name, info));
} else {
personal_themes.push((name, info));
}
}

println!(
" {} {}{} - {}",
status_icon, name, status_text, info.description
);
println!(
" 👤 Author: {} | 📦 Version: {}",
info.author, info.version
);
// Display blog themes
if !blog_themes.is_empty() {
println!("\n📝 Blog Themes (for traditional blogs with posts):");
for (name, info) in blog_themes {
let is_active = current_theme.as_ref() == Some(&name);
let status_icon = if is_active { "✅" } else { "📦" };
let status_text = if is_active { " (active)" } else { "" };

println!(
" {} {}{} - {}",
status_icon, name, status_text, info.description
);
println!(
" 👤 Author: {} | 📦 Version: {}",
info.author, info.version
);
}
}

// Display personal themes
if !personal_themes.is_empty() {
println!("\n👤 Personal Website Themes (for portfolios and personal sites):");
for (name, info) in personal_themes {
let is_active = current_theme.as_ref() == Some(&name);
let status_icon = if is_active { "✅" } else { "📦" };
let status_text = if is_active { " (active)" } else { "" };

println!(
" {} {}{} - {}",
status_icon, name, status_text, info.description
);
println!(
" 👤 Author: {} | 📦 Version: {}",
info.author, info.version
);
}
}
}

Expand Down Expand Up @@ -111,6 +146,33 @@ pub async fn handle_set(name: String) -> Result<()> {
// Load current configuration
let mut config = project.load_config()?;

// Validate theme compatibility with site type
let theme_info = theme.info();
let site_type = &config.site.site_type;

if theme_info.site_type != *site_type {
let blog_themes = "minimal-retro, obsidian, terminal-candy";
let personal_themes = "dark-minimal, musashi, slate-portfolio, typewriter";

return Err(anyhow!(
"❌ Theme '{}' is a {} theme, but your site is configured as a {} site.\n\n\
{} themes: {}\n\
{} themes: {}\n\n\
💡 To use this theme, either:\n\
1. Choose a compatible {} theme from the list above\n\
2. Change your site type in blogr.toml: [site] site_type = \"{}\"",
name,
theme_info.site_type,
site_type,
"Blog",
blog_themes,
"Personal",
personal_themes,
site_type,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you can convert to string as its the intent is clear

theme_info.site_type
));
}

// Update theme name
config.theme.name = name.clone();

Expand Down
1 change: 1 addition & 0 deletions blogr-themes/src/dark_minimal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ impl Theme for DarkMinimalTheme {
author: "Blogr Team".to_string(),
description: "A dark, minimal theme for personal websites with quirky interactions and clean aesthetics.".to_string(),
config_schema,
site_type: "personal".to_string(),
}
}

Expand Down
2 changes: 2 additions & 0 deletions blogr-themes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ pub struct ThemeInfo {
pub author: String,
pub description: String,
pub config_schema: HashMap<String, ConfigOption>,
/// Type of site this theme supports: "blog" or "personal"
pub site_type: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand Down
1 change: 1 addition & 0 deletions blogr-themes/src/minimal_retro/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ impl Theme for MinimalRetroTheme {
author: "Blogr Team".to_string(),
description: "An artistic, minimal theme focused on content with expandable posts and beautiful typography".to_string(),
config_schema,
site_type: "blog".to_string(),
}
}

Expand Down
1 change: 1 addition & 0 deletions blogr-themes/src/musashi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ impl Theme for MusashiTheme {
author: "Blogr Team".to_string(),
description: "An elegant monochrome theme inspired by sumi-e ink wash painting. Soft whites, warm grays, and ink blacks. Peaceful, refined, embodying the warrior's disciplined way. Fully customizable from content.md.".to_string(),
config_schema,
site_type: "personal".to_string(),
}
}

Expand Down
1 change: 1 addition & 0 deletions blogr-themes/src/obsidian/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ impl Theme for ObsidianTheme {
author: "Blogr Team".to_string(),
description: "Adopts Obsidian community themes to style Blogr content".to_string(),
config_schema: schema,
site_type: "blog".to_string(),
}
}

Expand Down
1 change: 1 addition & 0 deletions blogr-themes/src/slate_portfolio/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ impl Theme for SlatePortfolioTheme {
author: "Blogr Team".to_string(),
description: "A sleek, modern dark portfolio theme with polished aesthetics and smooth interactions.".to_string(),
config_schema,
site_type: "personal".to_string(),
}
}

Expand Down
1 change: 1 addition & 0 deletions blogr-themes/src/terminal_candy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ impl Theme for TerminalCandyTheme {
author: "Blogr Team".to_string(),
description: "A quirky terminal-inspired theme with pastel colors, glitch effects, and playful animations. Perfect for personal websites.".to_string(),
config_schema,
site_type: "blog".to_string(),
}
}

Expand Down
1 change: 1 addition & 0 deletions blogr-themes/src/typewriter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ impl Theme for TypewriterTheme {
author: "Blogr Team".to_string(),
description: "A vintage typewriter-inspired theme with nostalgic aesthetics and mechanical charm.".to_string(),
config_schema,
site_type: "personal".to_string(),
}
}

Expand Down