|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +# Copyright © Magento, Inc. All rights reserved. |
| 4 | +# See COPYING.txt for license details. |
| 5 | + |
| 6 | +# To enable this plugin, add to your '_config.local.yml' the following: |
| 7 | +# |
| 8 | +# debug: site_post_render |
| 9 | +# |
| 10 | +# This plugin runs an IRB session (https://github.com/ruby/irb) of a Jekyll application in a serving mode when it's at a state after rendering the whole site, but before writing any files. |
| 11 | +# See the ":site, :post_render" hook: https://jekyllrb.com/docs/plugins/hooks/ |
| 12 | +# Available objects to explore are 'site' and 'payload'. |
| 13 | +# |
| 14 | +# Several helpful methods (to use a method, chain to an object such as 'site.methods', 'payload.keys'): |
| 15 | +# - '.methods.sort' |
| 16 | +# - '.instance_variables.sort' |
| 17 | +# - '.keys.sort' |
| 18 | +# |
| 19 | +# Examples: |
| 20 | +# |
| 21 | +# To view available configuration data of the site |
| 22 | +# > payload.site.keys |
| 23 | +# |
| 24 | +# To view the number of pages: |
| 25 | +# > payload.site.pages.count |
| 26 | +# |
| 27 | +# To find a page by path and view its data: |
| 28 | +# > page = payload.site.pages.select { |page| page.path == 'cloud/env/variables-build.md' }[0] |
| 29 | +# > page.data |
| 30 | +# |
| 31 | +# To exit from the IRB session: |
| 32 | +# > exit! |
| 33 | +# |
| 34 | +Jekyll::Hooks.register :site, :post_render do |site, payload| |
| 35 | + next unless site.config['serving'] |
| 36 | + |
| 37 | + # rubocop:disable Lint/Debugger |
| 38 | + binding.irb if site.config['debug'] == 'site_post_render' |
| 39 | + # rubocop:enable Lint/Debugger |
| 40 | +end |
0 commit comments