Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
SourLemonJuice opened this issue Oct 1, 2024 · 1 comment
Open

Comments

@SourLemonJuice
Copy link

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 SourLemonJuice changed the title Can't use many theme.* liquid variable with remote theme Can't use many "theme.*" liquid variable with remote theme Oct 1, 2024
@silvinor
Copy link

silvinor commented Oct 6, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants