nickpeirson/sculpin-sitemap-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

nickpeirson/sculpin-sitemap-bundle

Composer 安装命令:

composer require nickpeirson/sculpin-sitemap-bundle

包简介

Sculpin sitemap bundle

README 文档

README

Software License

Sculpin bundle that adds a data provider for sitemap data.

The sitemap generator will iterate over all sculpin sources that aren't used internally by sculpin via a file reference. This is intended to prevent assets from being included.

Known limitations

  • I'm not using any content types in my sculpin site, so this bundle is untested with content types. You never know, it may work out of the box, but it's untested so be warned.
  • As mentioned above, only sources that sculpin doesn't internally use a file reference for will be included. If this skips anythng that you want to include in your sitemap the workaround is to manually add it to your sitemap template.

Installation

  • Add the following to your sculpin.json file:
{
  "require": {
    "nickpeirson/sculpin-sitemap-bundle": "~0.1.1"
  }
}
  • Run sculpin update.
  • Add the bundle to your kernel app/SculpinKernel.php:
<?php
use Sculpin\Bundle\SculpinBundle\HttpKernel\AbstractKernel;

class SculpinKernel extends AbstractKernel
{
    protected function getAdditionalSculpinBundles()
    {
        return [
            'Nickpeirson\Sculpin\Bundle\SitemapBundle\SculpinSitemapBundle'
        ];
    }
}

Usage

The bundle provides a sculpin data provider called sitemap. To use it, add the following to your YAML frontmatter:

use:
  -sitemap

This will make data.sitemap available to your template.

data.sitemap will be populated with an entry for each page, subject to the limitations above. Each entry will have a loc field which is set the the relative URL that sculpin assigns to the source and a lastmod field which is set based either on the last modified time of the file or on the time the sitemap was built if the modified time isn't available.

The generator is currently hardcoded to override the loc field with page.canonical if it exists. This is to ensure only canonical urls are added to the sitemap. In future I intend to make this configurable via maps (see below for more information).

It's also possible to add new parameters, and override the default parameters, in data.sitemap for a given source by defining a sitemap parameter in the sources YAML frontmatter, e.g. the following will override lastmod and add changefreq and priority:

sitemap:
  lastmod: 2016-01-01 
  changefreq: monthly
  priority: 0.8

It is also possible to exclude files from the sitemap by adding the _exclude key to the pages sitemap parameter with any truthy value, e.g.:

sitemap:
  _exclude: 1

The primary use case for data.sitemap is for use in an XML sitemap template, but you could also use this data for generating a HTML sitemap if you anotated the sitemap data appropriately.

It's also worth being aware that the sitemap data is keyed by the loc field, so if you have multiple sources that result in the same loc, the last one will be present in the data.

Example sitemap.xml file

---
permalink: none
use:
 - sitemap
---
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{% for url in data.sitemap %}
  <url>
    <loc>{{ site.url }}{{ url.loc }}</loc>
    <lastmod>{{ url.lastmod }}</lastmod>
{% if url.changefreq %}
    <changefreq>{{ url.changefreq }}</changefreq>
{% endif %}
{% if url.priority %}
    <priority>{{ url.priority }}</priority>
{% endif %}
  </url>
{% endfor %}
</urlset>

Contributing

PRs greatfully recieved

Roadmap

  • Add configuration to allow adding fields from source data to the sitemap. This would allow for reuse of existing data rather than needing to be duplicated in the source's sitemap data, e.g. title.
  • Further to using existing source data, allow mapping from source data to sitemap. This would allow for overriding sitemap fields with existing data, e.g. mapping page.canonical_url override url for entries in data.sitemap.

License

The MIT License (MIT). Please see License File for more information.

nickpeirson/sculpin-sitemap-bundle 适用场景与选型建议

nickpeirson/sculpin-sitemap-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 16.15k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2016 年 10 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 nickpeirson/sculpin-sitemap-bundle 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 16.15k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 8
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 0
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-10-04