Sha256: c17303cf59b7833e77ef0210969953b50a0ffa1d242ba82e7cdf7472038879c8

Contents?: true

Size: 717 Bytes

Versions: 7

Compression:

Stored size: 717 Bytes

Contents

# frozen_string_literal: true

# Full-text searches content, in both content and properties
#
# == Basic usage:
#    {%search q%}
#    {{search|size}} results
#    {%endsearch%}
#
# Note: It will only look at published content
class SearchTag < LiquidumBlock
  def render(context)
    super

    current_content = context.registers['content']
    request = context.registers['controller'].request

    contents = current_content.site.contents.published.search(request.params[argv1])

    result = ''
    context.stack do
      context['results'] = contents.map { |content| Scribo::ContentDrop.new(content) }
      result += render_body
    end
    result
  end
end

Liquid::Template.register_tag('search', SearchTag)

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
scribo-1.0.44 lib/scribo/liquid/tags/search_tag.rb
scribo-1.0.43 lib/scribo/liquid/tags/search_tag.rb
scribo-1.0.42 lib/scribo/liquid/tags/search_tag.rb
scribo-1.0.41 lib/scribo/liquid/tags/search_tag.rb
scribo-1.0.40 lib/scribo/liquid/tags/search_tag.rb
scribo-1.0.39 lib/scribo/liquid/tags/search_tag.rb
scribo-1.0.38 lib/scribo/liquid/tags/search_tag.rb