{\fn黑体\fs22\bord1\shad0\3ahbe\4ah00\fscx67\fscy66\2chffffff\3ch808080}我必须去seo -nano
这个 neeto-seo-nano 管理跨 Neeto 应用程序的 SIO 设置 .
目录
用主机应用程序开发
安装
-
将此行添加到您的应用程序的 Gemfile 中 :
source "NEETO_GEM_SERVER_URL" do # ..existing gems gem "neeto-seo-engine" end -
然后执行:
bundle install -
运行迁移
bundle exec rails neeto_seo_engine:install:migrations bundle exec rails db:migrate
使用量
-
添加关联
class BlogPost > ApplicationRecord has_one :seo_setting, as: :entity, class_name: "NeetoSeoEngine::SeoSetting", dependent: :destroy end -
添加控制器
所有常见的控制器逻辑被提取到引擎上. 然而,我们仍然 需要从主机应用程序控制器上装入一些记录 .
class Api::V1::Admin::BlogPosts::SeoSettingsController < NeetoSeoEngine::Api::V1::SeoSettingsController private def load_entity! @entity = @organization.blog_posts.find(params[:blog_post_id]) end end -
在您的应用程序中包含以下模块
config/routes.rb文件 :include NeetoSeoEngine::Routes::Draw -
定义所需路线.
# routes/admin.rb
seo_setting_routes
-
在主机应用程序下创建文件
app/lib/neeto_seo_engine/callbacks.rb打开 提供许可( 如果您没有权限, 那么只需返回 真实的)module NeetoSeoEngine class Callbacks def self.can_manage_seo_settings?(user) user.has_permission?("neeto_seo_engine.manage_seo_settings") end end end注意: 如果此执行在主机应用程序中缺失, 则策略 将默认检查
user.has_permission?("neeto_seo_engine.manage_seo_settings")。 。 。 . -
在您想要的路径中添加前端组件 。 里面有两个组件 软件包 :
这个
SeoSettingsPage包括SeoSettingsPane在它内部。 这个SeoSettingsPage用于需要整页组件的实体, 时SeoSettingsPane用于仅指窗格的情况 所需经费.以下是使用
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} /> ); };您需要构建 SEO 组成字段,其中包含您想要的字段 发动机。 允许的球场是
title, (中文(简体) ),titleSuffix, (中文(简体) ),keywords,以及description, (中文(简体) ),allowSearchEngineToCrawl, (中文(简体) ),googleAnalyticsTrackingId,以及coverImage。这些组件将相应生成。 你可以通过 相应的helpDocUrl, (中文(简体) ),popOverDescription,以及maxLength编辑name用于生成组件.也可以通过一个
additionalComponent附加附加文件的道具 选项SeoSettingsPane。 。 。 .你必须通过
entity道具,可以是 页次, (中文(简体) ), 条款, (中文(简体) ), 站点或者你选择的任何其他实体.这个 徐定居页 已经 类似道具。 此外,你可以通过
breadcrumbs财务报告和审定财务报表helpPopoverDescription页面编号.
出版指令
咨询 构建和释放软件包 关于如何出版的详细指南.