承接 gwd/seo-meta-nova-field 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

gwd/seo-meta-nova-field

Composer 安装命令:

composer require gwd/seo-meta-nova-field

包简介

A Laravel Nova field which adds all SEO related meta fields to an Resource.

关键字:

README 文档

README

This custom nova field, can add SEO related fields to any Model through a morph relationship within one single trait.

How to install

To install the package run the install below:

composer require gwd/seo-meta-nova-field

And then run the migrations:

php artisan migrate

And then publish the configs:

php artisan vendor:publish --provider="Gwd\SeoMeta\FieldServiceProvider"

How to use the field

Find the model you want to have the SEO fields on, example could be App\Models\Page, then add the SeoMetaTrait trait:

...
use Gwd\SeoMeta\Traits\SeoMetaTrait;

class Page extends Model
{
    use SeoMetaTrait;
    ...
}

Then use the field in the nova resource App\Nova\Page:

...
use Gwd\SeoMeta\SeoMeta;

class Page extends Resource
{
  ...
  public function fields(Request $request)
  {
    return [
      ...,
      SeoMeta::make('SEO', 'seo_meta')
        ->disk('s3-public') //disk to store seo image, default is public
    ];
  }
}

Then go to the top of your layout blade as default it's resources/views/welcome.blade.php:

...
<head>
    @include('seo-meta::seo')
    ...
</head>

Where the @include('seo-meta::seo', ['page' => $page]), should have the model instance with the relation to the SeoMetaTrait trait.

If you dont have any selected model/resource on the current page, then get the given SEO data for the page like this:

use Gwd\SeoMeta\Helper\Seo;
...
Route::get('/tester', function(){
    return view('page', [
        'seo' => Seo::renderAttributes('SEO title', 'SEO description', 'SEO keywords', 'SEO image', 'index, follow'), // Builds the seo array
    ]);
});

Here is how the Seo::renderAttributes static method looks like:

Setup default values for a model

If the SEO values should have the same structure every time, then you are able to set the up with the following methods in the trait:

// Return the SEO title for the model
public function getSeoTitleDefault(): string

// Return the SEO description for the model
public function getSeoDescriptionDefault(): string

// Return the SEO keywords for the model
public function getSeoKeywordsDefault(): string

// Return the SEO image for the model
public function getSeoImageDefault(): string

// Return the SEO follow type for the model
public function getSeoFollowDefault(): string

Setup Sitemap functionality

If you want the sitemap functionality then activate the sitemap by changing the seo.sitemap_status config to true. Then add the models which has the SeoSitemapTrait trait to the seo.sitemap_models array, like this:

    ...
    'sitemap_status' => env('SITEMAP_STATUS', true),

    ...
    'sitemap_models' => [
        App\Models\Page::class
    ],

Add Sitemap trait to models

When you want the eloquent model to be shown in the sitemap then you need to add the SeoSitemapTrait trait to it:

...
use Gwd\SeoMeta\Traits\SeoSitemapTrait;

class Page extends Model
{
    use SeoMetaTrait, SeoSitemapTrait;
    ...

    /**
     * Get the Page url by item
     *
     * @return string
     */
    public function getSitemapItemUrl()
    {
        return url($this->slug);
    }

    /**
     * Query all the Page items which should be
     * part of the sitemap (crawlable for google).
     *
     * @return Builder
     */
    public static function getSitemapItems()
    {
        return static::all();
    }
}

Know you should be able to go to the seo.sitemap_path which is /sitemap as default. Then you should get an xml in the correct sitemap structure for Google Search Console.

How does it look in Laravel Nova

If the field is shown in the index view of the Resource, then you should see a column with a dot: alt text

In detail view you will see a text saying You need some SEO data if no SEO is setup yet. But if you have any then, you will get the toggle button, which will show you an example how it will look like on Google and on Facebook: alt text alt text

In form view you should see all the SEO input fields: alt text

gwd/seo-meta-nova-field 适用场景与选型建议

gwd/seo-meta-nova-field 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 94.61k 次下载、GitHub Stars 达 24, 最近一次更新时间为 2019 年 10 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「nova」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 gwd/seo-meta-nova-field 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 gwd/seo-meta-nova-field 我们能提供哪些服务?
定制开发 / 二次开发

基于 gwd/seo-meta-nova-field 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 94.61k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 24
  • 点击次数: 5
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 24
  • Watchers: 1
  • Forks: 27
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-10-01