       title: header[:title],
       tags: tags,
       html: html,
-      preview: preview,
+      preview: preview(html, proj.preview_length),
       raw_date: raw_date,
       date: date_str,
       url: Path.join(proj.base_url, filename),

    end
  end

  @spec generate_preview(binary(), non_neg_integer()) :: binary()
  defp generate_preview(html, length)
  defp generate_preview(_html, length) when length <= 0, do: ""

  defp generate_preview(html, length) do
    text =
      html
      |> Floki.text(sep: " ")
      |> String.trim()
      |> String.replace(~r/\s+/, " ")

    if String.length(text) <= length do
      text
    else
      String.slice(text, 0, length) <> "\u2026"
    end
  end

  @spec to_fragment(t(), map()) :: Result.t(Fragment.t())
  def to_fragment(post, templates) do

    datetime = header[:date]
    date_str = Timex.format!(datetime, proj.date_format)
    raw_date = to_erl_datetime(datetime)

    filename =
      path
