@bigbinary/neeto-seo-frontend v3.0.3
neeto-seo-nano
The neeto-seo-nano manages SEO settings across Neeto applications.
Contents
Development with Host Application
Installation
Add this line to your application's Gemfile:
source "NEETO_GEM_SERVER_URL" do # ..existing gems gem "neeto-seo-engine" endAnd then execute:
bundle installRun migrations
bundle exec rails neeto_seo_engine:install:migrations bundle exec rails db:migrate
Usage
Add association
class BlogPost > ApplicationRecord has_one :seo_setting, as: :entity, class_name: "NeetoSeoEngine::SeoSetting", dependent: :destroy endAdd controller
All common controller logic is extracted to the engine. However, we still need to load some records from the host app controller.
class Api::V1::Admin::BlogPosts::SeoSettingsController < NeetoSeoEngine::Api::V1::SeoSettingsController private def load_entity! @entity = @organization.blog_posts.find(params[:blog_post_id]) end endInclude the following module to your application's
config/routes.rbfile:include NeetoSeoEngine::Routes::DrawDefine required routes.
# routes/admin.rb
seo_setting_routesCreate a file in the host app under
app/lib/neeto_seo_engine/callbacks.rb& provide the permission (If you don't have permissions, then simply return true)module NeetoSeoEngine class Callbacks def self.can_manage_seo_settings?(user) user.has_permission?("neeto_seo_engine.manage_seo_settings") end end endNote: If this implementation is missing in the host application, the policy will default to checking
user.has_permission?("neeto_seo_engine.manage_seo_settings").Add the frontend component to your desired path. There are two components in the package:
The
SeoSettingsPageincludes theSeoSettingsPanewithin it. TheSeoSettingsPageis used for entities that require a full-page component, while theSeoSettingsPaneis intended for cases where only a pane is required.Here is an example of the usage of
SeoSettingsPane:const SeoSettings = ({ isOpen, onClose }) => { const { blogPostId } = useParams(); const SEO_FORM_FIELDS = [ { name: "title", helpDocUrl: "https://help.neetopublish.com/#1-page-title", maxLength: 80, }, { name: "description", altLabel: "Meta Description", altPlaceholder: "Enter meta Description", helpDocUrl: "https://help.neetopublish.com/#2-meta-description", maxLength: 150, }, { name: "keywords", helpDocUrl: "https://help.neetopublish.com/#3-keywords", maxLength: 150, popOverDescription: "Some description about Meta keywords", }, { name: "allowSearchEngineCrawl" }, { name: "googleAnalyticsTrackingId" }, { name: "coverImage" }, ]; return ( <SeoSettingsPane {...{ isOpen, onClose }} apiEndpointUrl={`${BASE_API_V1_URL}/admin/blog_posts/${blogPostId}/seo_setting`} defaultHelpDocUrl="https://help.neetopublish.com/search-engine-optimization" entity="Page" seoFormFields={SEO_FORM_FIELDS} /> ); };You need to build SEO form fields with the desired fields required in your engine. The allowed fields are
title,titleSuffix,keywords, anddescription,allowSearchEngineToCrawl,googleAnalyticsTrackingId, andcoverImage. These components will be generated accordingly. You can pass the correspondinghelpDocUrl,popOverDescription, andmaxLength. Thenameis mandatory to generate the component.You can also pass an
additionalComponentprop to append an additional component of your choice in theSeoSettingsPane.You must pass the
entityprop, which can be Page, Article, Site, or any other entity of your choice.The SeoSettingsPage has similar props. Additionally, you can pass the
breadcrumbsandhelpPopoverDescriptionof the page.
Instructions for Publishing
Consult the building and releasing packages guide for details on how to publish.