承接 8black/wn-seo-plugin 相关项目开发

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

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

8black/wn-seo-plugin

Composer 安装命令:

composer require 8black/wn-seo-plugin

包简介

Winter CMS plugin for managing SEO tags

README 文档

README

Easily handle Search Engine Optimization in your Winter CMS projects. Inspired by https://github.com/bennothommo/wn-meta-plugin.

Future plans including support for easily generating structured data and automatically attaching SEO meta fields to CMS pages, Winter.Pages pages, & generically to any Winter CMS model. Check the TODO list in Plugin.php for more planned features.

Installation

composer require winter/wn-seo-plugin

Then add the [seoTags] component to your <head> in your theme, ideally right after the standard encoding and responsiveness tags.

Suggested implementation:

Layout or header partial:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        {% partial "meta/seo" %}
    </head>

partials/meta/seo.htm:

[seoTags]
==
<?php
use Backend\Models\BrandSetting;
use System\Classes\MediaLibrary;
use Winter\SEO\Classes\Link;
use Winter\SEO\Classes\Meta;
function onStart()
{
    $this['page_title'] = $this->page->title ?? Meta::get('og:title') ?? '';
    $this['app_name'] = BrandSetting::get('app_name');

    // Set the cannonical URL
    Link::set('canonical', \URL::current());

    // Parse the meta_image as a media library image
    if (!empty($this->page->meta_image)) {
        $this->page->meta_image = MediaLibrary::url($this->page->meta_image);
    }

    // Handle the nofollow meta property being set
    if (!empty($this->page->meta_nofollow)) {
        Link::set('robots', 'nofollow');
    }

    // Set the meta tags based on the current page if not set
    $metaMap = [
        Meta::class => [
            'og:title' => 'meta_title',
            'og:description' => 'meta_description',
            'og:image' => 'meta_image',
        ],
        Link::class => [
            'prev' => 'paginatePrev',
            'next' => 'paginateNext',
        ],
    ];
    foreach ($metaMap as $class => $map) {
        foreach ($map as $name => $pageProp) {
            if (!empty($this->page->{$pageProp}) && empty($class::get($name))) {
                $class::set($name, $this->page->{$pageProp});
            }
        }
    }

    $this['raw_title'] = Meta::get('title');
}
?>
==
<title>
    {%- placeholder page_title default %}
        {%- if raw_title %}{{ raw_title | striptags }}{% elseif page_title %}{{ page_title | striptags }} | {{ app_name }}{% else %}{{ app_name }}{% endif -%}
    {% endplaceholder -%}
</title>
{% component seoTags %}

Configuration

Configuration for this plugin is handled through a configuration file. In order to modify the configuration values and get started you can copy the plugins/winter/seo/config/config.php file to config/winter/seo/config.php and make your changes there.

Usage

Meta Tags

Use the Meta class to add <meta> tags that will be rendered by the [seoTags] component. Examples:

use Winter\SEO\Classes\Meta;

// Adds <meta name="og:type" content="article">
Meta::set('og:type', 'article');

// Appends a meta tag to the collection; allowing for full control of the
// attributes used as well as preventing it from being overridden and / or
// enabling multiple tags with the same name to be added.
Meta::append([
    'name' => 'og:type',
    'content' => 'article',
    'example_attribute' => 'the_cake_is_a_lie',
]);

// Overrides `og:type` because it was set later in the request
Meta::set('og:type', 'article');

// Retreive a specific meta tag by its name
Meta::get('og:type');

// Retrieve all meta tags currently set in this request
Meta::all()

// Clear all previously set meta tags and start fresh from this point on in the request
Meta::refresh();

Link Tags

Use the Link class to add <link> tags that will be rendered by the [seoTags] component. Examples:

use Winter\SEO\Classes\Link;

// Adds <link rel="base_url" rel="https://example.com">
Link::set('base_url', 'https://example.com');

// Appends a link tag to the collection; allowing for full control of the
// attributes used as well as preventing it from being overridden and / or
// enabling multiple tags with the same name to be added.
Link::append([
    'rel' => 'preload',
    'href' => 'https://example.com/logo.png',
    'as' => 'image',
]);

// Overrides `base_url` because it was set later in the request
Link::set('base_url', url()->current());

// Retreive a specific link tag by its name
Link::get('base_url');

// Retrieve all link tags currently set in this request
Link::all()

// Clear all previously set link tags and start fresh from this point on in the request
Link::refresh();

8black/wn-seo-plugin 适用场景与选型建议

8black/wn-seo-plugin 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 04 月 09 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 8black/wn-seo-plugin 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 8
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-04-09