Skip to main content

archive_path_for_bean

Function archive_path_for_bean 

Source
pub fn archive_path_for_bean(
    beans_dir: &Path,
    id: &str,
    slug: &str,
    ext: &str,
    date: NaiveDate,
) -> PathBuf
Expand description

Compute the archive path for a bean given its ID, slug, and date.

Returns the path: .beans/archive/YYYY/MM/<id>-<slug>.md

§Arguments

  • beans_dir - Path to the .beans/ directory
  • id - The bean ID (e.g., “1”, “11.1”, “3.2.1”)
  • slug - The bean slug (derived from title)
  • ext - The file extension (e.g., “md”, “yaml”)
  • date - The date to use for year/month subdirectories

§Returns

A PathBuf representing .beans/archive/YYYY/MM/<id>-<slug>.<ext>

§Examples

let path = archive_path_for_bean(
    Path::new(".beans"),
    "12",
    "bean-archive-system",
    "md",
    chrono::NaiveDate::from_ymd_opt(2026, 1, 31).unwrap()
);
// Returns: .beans/archive/2026/01/12-bean-archive-system.md