jekyll-remote-theme icon indicating copy to clipboard operation
jekyll-remote-theme copied to clipboard

Can't use many "theme.*" liquid variable with remote theme

Open SourLemonJuice opened this issue 1 year ago • 1 comments

Describe the bug

When the site using remote theme, if trying to use some variables in "themes.*" an error is thrown:

Liquid Exception: undefined method `authors' for #<Jekyll::RemoteTheme::MockGemspec:0x000075fe6282baa0 @theme=#<Jekyll::RemoteTheme::Theme host="github.com" owner="sourlemonjuice" name="minima-for-sourlemonjuice" ref="HEAD" root="/tmp/jekyll-remote-theme-20241001-343013-3ugjua">, @path=nil, @dependency_names=[], @runtime_dependencies=[]> in pages/version.md
             Error: undefined method `authors' for #<Jekyll::RemoteTheme::MockGemspec:0x000075fe6282baa0 @theme=#<Jekyll::RemoteTheme::Theme host="github.com" owner="sourlemonjuice" name="minima-for-sourlemonjuice" ref="HEAD" root="/tmp/jekyll-remote-theme-20241001-343013-3ugjua">, @path=nil, @dependency_names=[], @runtime_dependencies=[]>
             Error: Run jekyll build --trace for more information.

The variable that go wrong are: authors, description, version, metadata But these are no problem: root, dependencies

If the remote theme can't access this info. Then can it just warning or return a default value? Now it will break the whole build

Steps to reproduce the behavior

  1. find a site that uses remote theme
  2. put {{ theme.authors }} into any page

Additional context

SourLemonJuice avatar Oct 01 '24 13:10 SourLemonJuice

If you add {{ theme }} to a page - you will get " Jekyll::Drops::ThemeDrop ". So the theme variable, is not a collection/array, but rather an object.. This object is populated from the gemspec file, here: lib/jekyll/drops/theme_drop.rb, , but since jekyll core is not written to access the theme's .gemspec (in a remote sense) it falls back to an empty object content in line #35.

This is not a fix tho - it's a why. idk what the fix is, except having the plugin override the theme ThemeDrop object.

silvinor avatar Oct 06 '24 15:10 silvinor