Module: Jekyll::VitePressTheme::CopyPage
- Defined in:
- lib/jekyll/vitepress_theme/hooks.rb
Class Method Summary collapse
- .enabled?(item) ⇒ Boolean
- .leading_h1?(markdown) ⇒ Boolean
- .liquid_render_info(item, payload) ⇒ Object
- .resolved_markdown(item, payload) ⇒ Object
Class Method Details
.enabled?(item) ⇒ Boolean
180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/jekyll/vitepress_theme/hooks.rb', line 180 def enabled?(item) theme_config = item.site.config['jekyll_vitepress'] copy_page_disabled = theme_config.is_a?(Hash) && theme_config['copy_page'].is_a?(Hash) && theme_config['copy_page']['enabled'] == false unless copy_page_disabled page_theme = item.data['jekyll_vitepress'] copy_page_disabled = page_theme == false || (page_theme.is_a?(Hash) && page_theme['copy_page'] == false) end !copy_page_disabled end |
.leading_h1?(markdown) ⇒ Boolean
215 216 217 218 219 220 221 222 223 224 |
# File 'lib/jekyll/vitepress_theme/hooks.rb', line 215 def leading_h1?(markdown) return false if markdown.nil? stripped = markdown.lstrip return false if stripped.empty? stripped.match?(/\A#\s+\S/) || stripped.match?(/\A<h1(?:\s|>)/i) || stripped.match?(/\A[^\n]+\n=+\s*(?:\n|$)/) end |
.liquid_render_info(item, payload) ⇒ Object
205 206 207 208 209 210 211 212 213 |
# File 'lib/jekyll/vitepress_theme/hooks.rb', line 205 def liquid_render_info(item, payload) = item.site.config['liquid'] || {} { registers: { site: item.site, page: payload['page'] }, strict_filters: ['strict_filters'], strict_variables: ['strict_variables'] } end |
.resolved_markdown(item, payload) ⇒ Object
194 195 196 197 198 199 200 201 202 203 |
# File 'lib/jekyll/vitepress_theme/hooks.rb', line 194 def resolved_markdown(item, payload) raw = item.content.to_s return raw unless item.respond_to?(:render_with_liquid?) && item.render_with_liquid? item.renderer.render_liquid(raw, payload, liquid_render_info(item, payload), item.path) rescue StandardError => e relative_path = item.respond_to?(:relative_path) ? item.relative_path : item.path Jekyll.logger.warn('jekyll-vitepress-theme', "Copy page markdown capture failed for #{relative_path}: #{e.}") raw end |