Class: Liquidbook::Config
- Inherits:
-
Object
- Object
- Liquidbook::Config
- Defined in:
- lib/liquidbook/config.rb
Overview
Loads .liquid-preview/config.yml from the theme root
head entries can be:
- Raw HTML: <script src="https://cdn.tailwindcss.com"></script>
- File path: ../src-lit/styles/main.css
- File path: ./src/components.js
File paths are resolved relative to the theme root and served via /__imports__/
Constant Summary collapse
- DEFAULT_CONFIG =
{ "head" => [], "port" => 4567, "host" => "127.0.0.1" }.freeze
- IMPORT_PATH_PREFIX =
"/__imports__"
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#head_tags_html ⇒ Object
Returns HTML strings ready to inject into <head>.
- #host ⇒ Object
-
#import_files ⇒ Object
Returns a map of serve_path => absolute_file_path for file imports.
-
#initialize(theme_root: nil) ⇒ Config
constructor
A new instance of Config.
- #port ⇒ Object
Constructor Details
#initialize(theme_root: nil) ⇒ Config
Returns a new instance of Config.
23 24 25 26 |
# File 'lib/liquidbook/config.rb', line 23 def initialize(theme_root: nil) @theme_root = theme_root || Liquidbook.root @data = load_config end |
Instance Method Details
#[](key) ⇒ Object
46 47 48 |
# File 'lib/liquidbook/config.rb', line 46 def [](key) @data[key.to_s] end |
#head_tags_html ⇒ Object
Returns HTML strings ready to inject into <head>
29 30 31 |
# File 'lib/liquidbook/config.rb', line 29 def Array(@data["head"]).map { |entry| entry_to_html(entry) } end |
#host ⇒ Object
42 43 44 |
# File 'lib/liquidbook/config.rb', line 42 def host @data["host"] || "127.0.0.1" end |
#import_files ⇒ Object
Returns a map of serve_path => absolute_file_path for file imports
34 35 36 |
# File 'lib/liquidbook/config.rb', line 34 def import_files @import_files ||= build_import_map end |
#port ⇒ Object
38 39 40 |
# File 'lib/liquidbook/config.rb', line 38 def port @data["port"] || 4567 end |