scriptorium/models/database

The database contains all the parsed data from the input files, but not processed content.

Types

pub opaque type Database

Posts organised by month. This is used inside YearPosts.

pub type MonthPosts =
  Dict(Month, OrderedTree(PostWithID))

Internal post ID, generated automatically.

pub type PostID =
  UniqID
pub type PostWithID {
  PostWithID(id: PostID, post: Post)
}

Constructors

  • PostWithID(id: PostID, post: Post)

All tags and their posts.

pub type TagPosts =
  Dict(Tag, OrderedTree(PostWithID))

Posts organised by year, containing posts organised by month.

pub type YearPosts =
  Dict(Int, MonthPosts)

Functions

pub fn add_page(db: Database, page: Page) -> Database

Add a page into the database.

pub fn add_post(db: Database, post: Post) -> Database

Add a post into the database.

pub fn get_posts_with_ids(
  db: Database,
  order: WalkOrder,
) -> List(PostWithID)

Get all posts in the given order.

pub fn menu(db: Database) -> List(MenuItem)

Get menu items.

pub fn new() -> Database

Create a new empty database.

pub fn pages(db: Database) -> List(Page)

Get pages.

pub fn set_menu(db: Database, menu: List(MenuItem)) -> Database

Set the menu items of the database, replacing any old ones.

pub fn tags(
  db: Database,
) -> Dict(String, OrderedTree(PostWithID))

Get posts organised by tags.

pub fn years(
  db: Database,
) -> Dict(Int, Dict(Month, OrderedTree(PostWithID)))

Get posts organised by years and months.

Search Document