Files
2026-08-27 17:29:16 -03:00

19 lines
609 B
Ruby

# frozen_string_literal: true
# Helper plugin that nests form schemas
Jekyll::Hooks.register :site, :post_read do |site|
Jekyll.logger.info 'Forms:', 'Nesting forms'
nested_types = %w[nested_form multi_nested_form]
site.data['forms']&.each_pair do |form, schema|
next unless schema.values.any? { nested_types.include?(_1['type']) }
schema.select do |_, definition|
nested_types.include? definition['type']
end.each do |field, definition|
Jekyll.logger.info 'Forms:', "Nesting #{field} into #{form}"
definition['schema'] = site.data.dig('forms', field)
end
end
end