require "phlex"
require "phlex/markdown"
require "phlexite"
require "tailwindcss/phlexite"
require "front_matter_parser"

require_relative "util/post_loader"
require_relative "pages/layout"
require_relative "pages/home"
require_relative "pages/blog"
require_relative "pages/about"
require_relative "pages/post"
require_relative "pages/gomod"

def go_modules = {
  'farthergate.com/terminated': 'https://git.farthergate.com/ztYyRKXjvYE5Ri7YjsXf8gGY5cXy.git'
}

Phlexite::Site.new { |s|
  include Util::PostLoader

  s.mount "assets", on: "/"

  Tailwindcss::Phlexite.build s, 'input.css', 'tailwind.css'

  s.page "index.html", Pages::Home.new
  s.page "blog/index.html", Pages::Blog.new
  s.page "about/index.html", Pages::About.new

  posts.each do |post|
    s.page "p/#{post[:slug]}/index.html", Pages::Post.new(post)
  end

  go_modules.each do |import, repo|
    s.page import.to_s.delete_prefix('farthergate.com/'), Pages::GoMod.new(import, repo)
  end
}
