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

add support for multiple instances #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mrtndwrd
Copy link

@mrtndwrd mrtndwrd commented Nov 2, 2017

Nothing seems to stand in the way of that, and I need it for a multilingual website. I want to have two search.json's: one for each language. This way I can include the Dutch search in the Dutch website, and the English search in the English website.

I have this in my config.rb:

# First locale is considered root path
locales = [:en, :nl]
activate :i18n do |i18n|
  i18n.templates_dir = "pages"
  i18n.locales = locales
end

locales.each do | locale |
  activate :search do |search|
    search.resources = ["blog/#{locale}", "#{locale}/helpdesk/"]
    search.index_path = "search/lunr-index-#{locale}.json"
    search.fields = {
      title:   {boost: 100, store: true, required: true},
      content: {boost: 50},
      url:     {index: false, store: true},
      author:  {boost: 30}
    }
  end
end

(note that we're also using blog, if you think it's relevant:)

locales.each_with_index do | locale, index |
  # Blog
  activate :blog do | blog |
    # Locale path: first locale is mounted at root
    path = index > 0 ? "#{locale}/" : ""
    blog.name      = "blog_#{locale}"
    blog.permalink = "#{path}blog/{year}/{month}/{day}/{title}.html"
    # Matcher for blog source files
    blog.sources = "blog/#{locale}/{year}-{month}-{day}-{engtitle}.html"
    blog.layout    = "blog"

    # Pagination
    blog.paginate  = true
    blog.page_link = "page/{num}"
    blog.per_page  = 15

    # Calendar
    blog.calendar_template = "blog/calendar.html"
    blog.year_link         = "#{path}blog/{year}.html"
    blog.month_link        = "#{path}blog/{year}/{month}.html"
    blog.day_link          = "#{path}blog/{year}/{month}/{day}.html"

    # Tags
    blog.tag_template = "blog/tag.html"
    blog.taglink      = "#{path}blog/tag/{tag}.html"
    # Use the global Middleman I18n.locale instead of the lang in the
    # article's frontmatter
    blog.preserve_locale = true
  end
end

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

Successfully merging this pull request may close these issues.

None yet

1 participant