Module: Abqari::ThemeFonts

Defined in:
lib/abqari/theme_fonts.rb

Overview

The self-hosted webfonts each shipped theme's font stacks ask for. A theme is a token file — its --font-* stacks can name any face — but the faces only render if the site actually downloads them (fonts: in config/site.yml + bin/fetch-fonts). Before this map existed, magazine and sand silently fell back to system serifs on every site that didn't hand-maintain the list, and their typographic identity never materialised.

Consumed by abqari new --theme <name> (scaffolds the matching fonts: block) and abqari theme eject (prints the block as a hint). Themes not listed use system fonts and need nothing.

Constant Summary collapse

FONTS =
{
  # Display headings; body is Charter/Palatino/Georgia (system).
  'magazine' => [
    { 'family' => 'Playfair Display', 'weights' => [700], 'style' => 'normal' }
  ].freeze,
  # Inter body + JetBrains Mono for headings/meta/code.
  'notebook' => [
    { 'family' => 'Inter',          'weights' => [400, 600], 'style' => 'normal' },
    { 'family' => 'JetBrains Mono', 'weights' => [400, 600], 'style' => 'normal' }
  ].freeze,
  # Merriweather body (regular + italic — serif prose needs a true
  # italic) + Merriweather Sans for headings and UI.
  'sand' => [
    { 'family' => 'Merriweather',      'weights' => [400, 700], 'style' => 'normal' },
    { 'family' => 'Merriweather',      'weights' => [400],      'style' => 'italic' },
    { 'family' => 'Merriweather Sans', 'weights' => [400, 600], 'style' => 'normal' }
  ].freeze
}.freeze

Class Method Summary collapse

Class Method Details

.for(theme) ⇒ Object



35
36
37
# File 'lib/abqari/theme_fonts.rb', line 35

def self.for(theme)
  FONTS.fetch(theme.to_s, [])
end

.yaml_entries(theme, indent: '') ⇒ Object

The fonts: entries as site.yml-ready YAML lines (no leading fonts: key — callers decide how to frame the block).



41
42
43
44
45
46
47
48
49
# File 'lib/abqari/theme_fonts.rb', line 41

def self.yaml_entries(theme, indent: '')
  self.for(theme).map do |font|
    <<~YAML.gsub(/^/, indent).rstrip
      - family: #{font['family']}
        weights: [#{font['weights'].join(', ')}]
        style: #{font['style']}
    YAML
  end.join("\n")
end