forked from magento/devdocs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsite_pre_render.rb
40 lines (37 loc) · 1.25 KB
/
site_pre_render.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# frozen_string_literal: true
# Copyright © Magento, Inc. All rights reserved.
# See COPYING.txt for license details.
# To enable this plugin, add to your '_config.local.yml' the following:
#
# debug: site_pre_render
#
# 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 just before rendering the whole site.
# See the ":site, :pre_render" hook: https://jekyllrb.com/docs/plugins/hooks/
# Available objects to explore are 'site' and 'payload'.
#
# Several helpful methods (to use a method, chain to an object such as 'site.methods', 'payload.keys'):
# - '.methods.sort'
# - '.instance_variables.sort'
# - '.keys.sort'
#
# Examples:
#
# To view available configuration data of the site
# > payload.site.keys
#
# To view the number of pages:
# > payload.site.pages.count
#
# To find a page by path and view its data:
# > page = payload.site.pages.select { |page| page.path == 'cloud/env/variables-build.md' }[0]
# > page.data
#
# To exit from the IRB session:
# > exit!
#
Jekyll::Hooks.register :site, :pre_render do |site, payload|
next unless site.config['serving']
# rubocop:disable Lint/Debugger
binding.irb if site.config['debug'] == 'site_pre_render'
# rubocop:enable Lint/Debugger
end