Class

Item

class Item<M> where M : Metadata

A model representing an item.

An item can be any text file (like a Markdown or RestructedText file). Readers will turn the file into an Item, and Writers will turn the Item into a String (for example HTML or RSS) to be written to disk.

Mentioned In

Initializers

init(
  absoluteSource: Path,
  relativeSource: Path,
  relativeDestination: Path,
  title: String,
  body: String,
  date: Date,
  created: Date,
  lastModified: Date,
  metadata: M
)
convenience init(
  title: String,
  body: String = "",
  date: Date = Date(),
  relativeDestination: Path? = nil,
  metadata: M
)

Create an Item programmatically (without reading from a file).

Parameters

title

The title of the item.

body

The body content. Defaults to an empty string.

date

The date of the item. Defaults to the current date.

relativeDestination

The output path relative to the site's output folder. Defaults to title-slug/index.html.

metadata

The parsed metadata.

Instance Properties

let absoluteSource: Path

The absolute path of the file

var body: String

The body of the file, without the metadata header, and without the first title.

let created: Date

The creation date of the item. Please note that this value can be inconsistent when cloning or pulling from git, see https://github.com/loopwerk/Saga/issues/21.

var date: Date

The date of the item. Will be taken from the metadata if available, defaults to the creation date otherwise. Please note that the creation date value can be inconsistent when cloning or pulling from git, see https://github.com/loopwerk/Saga/issues/21.

var filenameWithoutExtension: String { get }
let lastModified: Date

The last modified date of the item. Please note that this value can be inconsistent when cloning or pulling from git, see https://github.com/loopwerk/Saga/issues/21.

var metadata: M

The parsed metadata. Metadata can be any Codable object.

var relativeDestination: Path

The destination, where the Writer will write it to disk.

let relativeSource: Path

The path of the file, relative to the site’s input.

var title: String

The title of the item.

var url: String { get }

Relationships

Conforms To

AnyItem , Swift.Sendable