module Jekyll class EmojiTag < Liquid::Tag def initialize(tag_name, text, tokens) super @text = text.strip end def render(context) # Load the emoji data from the _data/emoji.yml file emojis = context.registers[:site].data['emoji'] #puts emojis.inspect # Debugging line to output the emoji data to the console # Search for the emoji with the name matching @text emoji = emojis.find { |e| e['shortcode'] == @text } if emoji # Construct the img HTML tag if found "#{emoji[" else # Return a default alt text if not found "#{@text}" end end end end # Register the custom tag Liquid::Template.register_tag('emoji', Jekyll::EmojiTag)