Module: Bh::Helpers::Heads

Included in:
Bh::Helpers
Defined in:
lib/bh/helpers/heads.rb

Overview

What a page built on Bootstrap 6 puts in its <head>.

Constant Summary collapse

INDENT =

One line per tag, each at the depth a head's children sit at in a layout indented by two: <html>, then <head>, then these.

"\n    "

Instance Method Summary collapse

Instance Method Details

#bh_head_tagsObject

The metas Bootstrap and Turbo read, and the stylesheet and script this gem serves. color-scheme is what lets light dark follow the system, so most pages need no theme attribute at all. A page refresh Turbo is sent morphs the page in place and keeps the scroll, so an answer landing in a thread leaves the reader where they were. The icon font is the host's to link: which glyphs a page draws is the host's business, and a gem reaching for somebody else's CDN on its own is not.



15
16
17
18
19
20
21
22
23
24
# File 'lib/bh/helpers/heads.rb', line 15

def bh_head_tags
  safe_join [
    tag.meta(name: 'viewport', content: 'width=device-width, initial-scale=1'),
    tag.meta(name: 'color-scheme', content: 'light dark'),
    tag.meta(name: 'turbo-refresh-method', content: 'morph'),
    tag.meta(name: 'turbo-refresh-scroll', content: 'preserve'),
    tag.link(rel: 'stylesheet', href: "#{Engine::PREFIX}css/bh.css"),
    tag.script('', type: 'module', src: "#{Engine::PREFIX}js/bh.js"),
  ], INDENT
end