Are you sick of manually adding SEO fields to every object and page that need them? So are we. The following illustrates how to add this to an existing scaffolded resource, but there is a custom generator field type available that will do all of this for you when you do the initial scaffold generation now, e.g.:
rails g fae:scaffold Thing name:string seo:seo_set
Fae provides a model for SEO: Fae::SeoSet
. This model contains a few very common SEO-related fields and can be polymorphically associated to your application models.
has_fae_seo :seo # Can be called anything.
The SEO model will have to be instantiated as follows in the build_assets
method that will look familiar for FAE's image/file upload handling:
module Admin
class WinesController < Fae::BaseController
private
def build_assets
if @item.seo.blank?
@item.build_seo
@item.seo.build_social_media_image
end
end
end
end
section.content
h2 SEO
= fae_seo_set_form f, :seo
= object.seo.seo_title
= object.seo.seo_description
= object.seo.social_media_title
= object.seo.social_media_description
= object.seo.social_media_image.asset.url
If your app is GraphQL-enabled, a type will automatically be generated.