Skip to content

Commit 396829d

Browse files
Copilotdmalan
andcommitted
Render Liquid in DescriptionGenerator before Markdown conversion
Co-authored-by: dmalan <[email protected]>
1 parent 8bd49b5 commit 396829d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lib/jekyll-theme-cs50.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,19 @@ module DescriptionGenerator
104104
def describe(input, max_length = 160)
105105
return "" if input.nil? || input.to_s.strip.empty?
106106

107+
# Render Liquid tags first if $site is defined
108+
markdown = input.to_s
109+
if defined?($site) && $site
110+
begin
111+
markdown = $site.liquid_renderer.file("(cs50-describe)").parse(markdown).render!($site.site_payload, { :registers => { :site => $site } })
112+
rescue => e
113+
Jekyll.logger.warn "CS50 warning: failed to render Liquid in description: #{e.message}"
114+
markdown = input.to_s
115+
end
116+
end
117+
107118
# Convert Markdown to HTML
108-
html = $site.find_converter_instance(::Jekyll::Converters::Markdown).convert(input.to_s)
119+
html = $site.find_converter_instance(::Jekyll::Converters::Markdown).convert(markdown)
109120

110121
# Parse HTML and extract text
111122
doc = Nokogiri::HTML5.fragment(html)

0 commit comments

Comments
 (0)