Class: Jekyll::WebAwesome::Plugin
- Inherits:
-
Object
- Object
- Jekyll::WebAwesome::Plugin
- Defined in:
- lib/jekyll/webawesome/plugin.rb
Overview
Plugin class that registers hooks for pre-render processing
Class Method Summary collapse
-
.debug_enabled?(site) ⇒ Boolean
Check if debug mode is enabled from various configuration sources.
-
.image_dialog_config(site) ⇒ Object
Get image dialog configuration with default width support.
-
.image_dialog_enabled?(site) ⇒ Boolean
Check if image dialog transformation is enabled.
-
.markdown_file?(filepath) ⇒ Boolean
Check if a file is a markdown file.
-
.sync_configuration(site) ⇒ Object
Sync Jekyll configuration to Markawesome before processing.
-
.transform_documents_enabled?(site) ⇒ Boolean
Check if documents transformation is enabled.
-
.transform_pages_enabled?(site) ⇒ Boolean
Check if pages transformation is enabled.
Class Method Details
.debug_enabled?(site) ⇒ Boolean
Check if debug mode is enabled from various configuration sources
10 11 12 13 14 15 16 |
# File 'lib/jekyll/webawesome/plugin.rb', line 10 def self.debug_enabled?(site) return true if Jekyll::WebAwesome.configuration&.debug_mode return true if site.config.dig('webawesome', 'debug') return true if site.config['webawesome_debug'] false end |
.image_dialog_config(site) ⇒ Object
Get image dialog configuration with default width support
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/jekyll/webawesome/plugin.rb', line 55 def self.image_dialog_config(site) config = {} # First check if it's enabled enabled_config = nil if Jekyll::WebAwesome.configuration enabled_config = Jekyll::WebAwesome.configuration.image_dialog elsif site.config.dig('webawesome', 'image_dialog') != nil enabled_config = site.config.dig('webawesome', 'image_dialog') end # If disabled or not set, return empty config return config unless enabled_config # If it's a boolean true, set enabled if enabled_config == true config[:enabled] = true # If it's a hash, merge it elsif enabled_config.is_a?(Hash) config = enabled_config.transform_keys(&:to_sym) config[:enabled] = true unless config.key?(:enabled) end config end |
.image_dialog_enabled?(site) ⇒ Boolean
Check if image dialog transformation is enabled
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/jekyll/webawesome/plugin.rb', line 43 def self.image_dialog_enabled?(site) # Check plugin configuration first return Jekyll::WebAwesome.configuration.image_dialog if Jekyll::WebAwesome.configuration # Check site config return site.config.dig('webawesome', 'image_dialog') if site.config.dig('webawesome', 'image_dialog') != nil # Default to false (opt-in feature) false end |
.markdown_file?(filepath) ⇒ Boolean
Check if a file is a markdown file
82 83 84 |
# File 'lib/jekyll/webawesome/plugin.rb', line 82 def self.markdown_file?(filepath) filepath.to_s.match?(/\.md$/i) end |
.sync_configuration(site) ⇒ Object
Sync Jekyll configuration to Markawesome before processing
87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/jekyll/webawesome/plugin.rb', line 87 def self.sync_configuration(site) # Sync callout icons from site config if present if site.config.dig('webawesome', 'callout_icons') Markawesome.configure do |config| config.callout_icons = site.config.dig('webawesome', 'callout_icons').transform_keys(&:to_sym) end elsif Jekyll::WebAwesome.configuration&.callout_icons Markawesome.configure do |config| config.callout_icons = Jekyll::WebAwesome.configuration.callout_icons end end end |
.transform_documents_enabled?(site) ⇒ Boolean
Check if documents transformation is enabled
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/jekyll/webawesome/plugin.rb', line 31 def self.transform_documents_enabled?(site) # Check plugin configuration first return Jekyll::WebAwesome.configuration.transform_documents if Jekyll::WebAwesome.configuration # Check site config return site.config.dig('webawesome', 'transform_documents') if site.config.dig('webawesome', 'transform_documents') != nil # Default to true true end |
.transform_pages_enabled?(site) ⇒ Boolean
Check if pages transformation is enabled
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/jekyll/webawesome/plugin.rb', line 19 def self.transform_pages_enabled?(site) # Check plugin configuration first return Jekyll::WebAwesome.configuration.transform_pages if Jekyll::WebAwesome.configuration # Check site config return site.config.dig('webawesome', 'transform_pages') if site.config.dig('webawesome', 'transform_pages') != nil # Default to true true end |