Sayfa (Sayfa v0.5.0)

Copy Markdown View Source

Sayfa — a simple, extensible static site generator built in Elixir.

Sayfa (Turkish for "page") provides core SSG functionality as a reusable Hex package. Users create their own sites by depending on Sayfa and writing content in Markdown with YAML front matter.

Quick Start

# Parse a markdown string with front matter
{:ok, content} = Sayfa.parse("---\ntitle: Hello\n---\n# World")
content.title  #=> "Hello"
content.body   #=> "<h1>...World</h1>"  # includes anchor id

# Parse a file
{:ok, content} = Sayfa.parse_file("content/articles/hello.md")

# Render markdown to HTML
{:ok, html} = Sayfa.render_markdown("# Hello **World**")

Summary

Functions

Builds the static site from content files.

Removes the output directory.

Parses a raw string containing YAML front matter and Markdown body.

Reads and parses a content file from disk.

Renders a Markdown string to HTML.

Functions

build(opts \\ [])

@spec build(keyword()) :: {:ok, Sayfa.Builder.Result.t()} | {:error, term()}

Builds the static site from content files.

See Sayfa.Builder.build/1 for details and options.

clean(opts \\ [])

@spec clean(keyword()) :: :ok

Removes the output directory.

See Sayfa.Builder.clean/1 for details.

parse(raw_string)

@spec parse(String.t()) :: {:ok, Sayfa.Content.t()} | {:error, term()}

Parses a raw string containing YAML front matter and Markdown body.

See Sayfa.Content.parse/1 for details.

parse_file(file_path)

@spec parse_file(String.t()) :: {:ok, Sayfa.Content.t()} | {:error, term()}

Reads and parses a content file from disk.

See Sayfa.Content.parse_file/1 for details.

render_markdown(markdown)

@spec render_markdown(String.t()) :: {:ok, String.t()} | {:error, term()}

Renders a Markdown string to HTML.

See Sayfa.Markdown.render/1 for details.