0

我对RUBY了解不多,只是想你们可能会帮助我:(。我使用 storyblok 作为我的无头 CMS,当我构建它时,这是我得到的错误

33: from C:/project/test/_plugins/storyblok_generator.rb:8:in `generate'
32: from C:/project/test/_plugins/storyblok_cms/generator.rb:12:in `generate!'
C:/project/test/vendor/cache/ruby/2.7.0/gems/storyblok-3.0.1/lib/storyblok/client.rb:354:in `block (2 levels) in find_and_fill_links': undefined method `[]' for nil:NilClass (NoMethodError)

下面的代码来自_plugins/storyblok_cms/generator.rb

def generate!
  timestamp = Time.now.to_i
  links = client.links(cv: timestamp)['data']['links']
  stories = client.stories(per_page: 100, page: 1, cv: timestamp)['data']['stories']   #line 12

  stories.each do |story|
    # create all pages except global (header,footer,etc.)
    content_type = story['content']['component']
    if content_type != 'shared'
      site.pages << create_page(site, story, links)
    end
    rescue UnknownContentTypeError => e
    # for production, raise unknown content type error;
    # for preview and other environments, issue an warning only since the content_type might be available
    # but the code handling that content type might be in a different branch.
    Jekyll.env == 'production' ? raise :  Jekyll.logger.warn(e.message)
  end

  site.data['stories'] = stories
  site.data['articles'] = stories.select { |story| story['full_slug'].start_with?('articles') }
  site.data['shared'] = stories.select { |story| story['full_slug'].start_with?('shared') }
end

下面的代码来自_plugins/storyblok_generator.rb

require "storyblok"

module Jekyll
  class StoryblokGenerator < Jekyll::Generator
    safe true

    def generate(site)
      StoryblokCms::Generator.new(site).generate!   #line 8
    end
  end
end

附加信息:

  • ruby 版本: ruby 2.7.4p191(2021-07-07 修订版 a21a3b7d23)[x64-mingw32]
  • jekyll 版本: jekyll 4.2.1
  • 操作系统:Windows 10
4

0 回答 0