From f00506074dd34ed5ff2901d3f1abcdc07343399c Mon Sep 17 00:00:00 2001 From: did Date: Sat, 28 Nov 2015 23:10:17 +0100 Subject: [PATCH] fix issue #45: Localization and page meta_description --- .../adapters/filesystem/yaml_loaders/page.rb | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/locomotive/steam/adapters/filesystem/yaml_loaders/page.rb b/lib/locomotive/steam/adapters/filesystem/yaml_loaders/page.rb index aacedeeb..e19a4285 100644 --- a/lib/locomotive/steam/adapters/filesystem/yaml_loaders/page.rb +++ b/lib/locomotive/steam/adapters/filesystem/yaml_loaders/page.rb @@ -42,14 +42,19 @@ def build(filepath, fullpath, locale) slug = fullpath.split('/').last attributes = get_attributes(filepath, fullpath) - { + _attributes = { title: { locale => attributes.delete(:title) || (default_locale == locale ? slug.humanize : nil) }, slug: { locale => attributes.delete(:slug) || slug.dasherize }, template_path: { locale => template_path(filepath, attributes, locale) }, - redirect_url: { locale => attributes.delete(:redirect_url) }, editable_elements: build_editable_elements(attributes.delete(:editable_elements), locale), _fullpath: fullpath - }.merge(attributes) + } + + [:redirect_url, :seo_title, :meta_description, :meta_keywords].each do |name| + _attributes[name] = { locale => attributes.delete(name) } + end + + _attributes.merge!(attributes) end def update(leaf, filepath, fullpath, locale) @@ -59,7 +64,10 @@ def update(leaf, filepath, fullpath, locale) leaf[:title][locale] = attributes.delete(:title) || slug.humanize leaf[:slug][locale] = attributes.delete(:slug) || slug.dasherize leaf[:template_path][locale] = template_path(filepath, attributes, locale) - leaf[:redirect_url][locale] = attributes.delete(:redirect_url) + + [:redirect_url, :seo_title, :meta_description, :meta_keywords].each do |name| + leaf[name][locale] = attributes.delete(name) + end update_editable_elements(leaf, attributes.delete(:editable_elements), locale)