Skip to content

Add Support for Subcategories in Guide#84

Open
ElijahAhianyo wants to merge 11 commits intocot-rs:masterfrom
ElijahAhianyo:elijah/sub-categories
Open

Add Support for Subcategories in Guide#84
ElijahAhianyo wants to merge 11 commits intocot-rs:masterfrom
ElijahAhianyo:elijah/sub-categories

Conversation

@ElijahAhianyo
Copy link
Copy Markdown
Contributor

@ElijahAhianyo ElijahAhianyo commented Apr 2, 2026

With this you should be able to add nested subcategories like this:

vec![
    GuideItem::Page(md_page!("v0.2", "introduction")),
    GuideItem::SubCategory {
      title: "Database",
      pages: vec![
         md_page!("databases/overview"),
         md_page!("databases/queries"),
      ],
   },
],

Refer to the sidebar in this image(cot-rs/cot#515 (comment)) on how this renders

@ElijahAhianyo
Copy link
Copy Markdown
Contributor Author

Depends on #82

@ElijahAhianyo ElijahAhianyo mentioned this pull request Apr 2, 2026
12 tasks
Comment thread src/lib.rs
/// A subcategory containing a collection of related pages.
///
/// # Examples
/// ```ignore
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ignore here because the md_page macro will try to read the guides which we dont want

@ElijahAhianyo ElijahAhianyo requested review from m4tx and seqre April 9, 2026 17:25
Comment thread static/static/css/guide_chapters.css Outdated
Comment thread templates/_base.html Outdated
Comment thread src/lib.rs
}

#[derive(Debug, Clone)]
enum GuideCategoryItem {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wonder if GuideCategoryItem could be merged with GuideItem as they seem almost the same. Why did you decide to split them? 🤔

Copy link
Copy Markdown
Contributor Author

@ElijahAhianyo ElijahAhianyo Apr 10, 2026

Choose a reason for hiding this comment

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

I don't think they serve the same purpose, per se. The previous version of CotApp::new accepted MdPage, which was a public-facing representation of a page. When parsing the guide(cot_site::guides::parse_guides), we convert that to MdPageLink(almost similar signature as MdPage), which is an internal representation of the page that gets rendered in the template.

This change also follows the same concept/design; GuideItem is public-facing, whereas GuideCategoryItem is an internal representation of MdPageLink(s) that get rendered in the template

Comment thread src/lib.rs Outdated
@ElijahAhianyo ElijahAhianyo requested a review from seqre April 10, 2026 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants