samhuri.net/lib/pressa/site.rb
Sami Samhuri 007b1058b6
Migrate from Swift to Ruby (#33)
Replace the Swift site generator with a Ruby and Phlex implementation.
Loads site and projects from TOML, derive site metadata from posts.

Migrate from make to bake and add standardrb and code coverage tasks.

Update CI and docs to match the new workflow, and remove unused
assets/dependencies plus obsolete tooling.
2026-02-07 21:19:03 -08:00

39 lines
1 KiB
Ruby

require "dry-struct"
module Pressa
module Types
include Dry.Types()
end
class Script < Dry::Struct
attribute :src, Types::String
attribute :defer, Types::Bool.default(true)
end
class Stylesheet < Dry::Struct
attribute :href, Types::String
end
class Site < Dry::Struct
attribute :author, Types::String
attribute :email, Types::String
attribute :title, Types::String
attribute :description, Types::String
attribute :url, Types::String
attribute :image_url, Types::String.optional.default(nil)
attribute :copyright_start_year, Types::Integer.optional.default(nil)
attribute :scripts, Types::Array.of(Script).default([].freeze)
attribute :styles, Types::Array.of(Stylesheet).default([].freeze)
attribute :plugins, Types::Array.default([].freeze)
attribute :renderers, Types::Array.default([].freeze)
def url_for(path)
"#{url}#{path}"
end
def image_url_for(path)
return nil unless image_url
"#{image_url}#{path}"
end
end
end