Module: Above::Mime

Defined in:
lib/above/mime.rb

Overview

Mime types

Class Method Summary collapse

Class Method Details

.type(path:) ⇒ Object

Mime type based on extension for Gemtext files & Marcel for everything else throws Errno::ENOENT on missing non gemtext files Marcel::MimeType.extend “text/gemini”, extensions: %w[.gmi .gemini] doesn’t seem to work?



13
14
15
16
17
18
19
20
# File 'lib/above/mime.rb', line 13

def type(path:)
  if %w[.gmi .gemini].include? File.extname(path)
    "text/gemini"
  else
    name = File.basename(path)
    Marcel::MimeType.for(Pathname.new(path), name: name)
  end
end