cviebrock/laravel-news-sitemap

为 Laravel 设计的简单 Google 新闻 Sitemap 生成器。

0.9.1 2014-10-07 18:42 UTC

This package is auto-updated.

Last update: 2024-09-05 18:44:02 UTC


README

Laravel 4 的 Google 新闻 Sitemap 生成器。

Build Status Total Downloads Latest Stable Version

安装

将包添加到您的 composer.json 文件中

'cviebrock/laravel-news-sitemap' => 'dev-master'

将服务提供者添加到 app/config/app.php

'providers' => array(
    ...
    'Cviebrock\LaravelNewsSitemap\ServiceProvider',
);

发布配置文件

php artisan config:publish cviebrock/laravel-news-sitemap

示例用法

// create a new sitemap instance
$sitemap = \App::make('Cviebrock\LaravelNewsSitemap\NewsSitemap');

// if it's not cached, then populate with entries
if (!$sitemap->isCached()) {

    foreach (Posts::all() as $post) {

		$extras = [];
		$images = [];

		foreach ($post->images as $image) {
			$images[] = [
			    'loc' => $image->url,
			    'caption' => $image->caption
            ];
		}

		$extras['keywords'] = $post->topics->lists('name');

		$this->sitemap->addEntry($post->url, $post->title, $post->published_at, $extras, $images);
	}

}

// returns an XML response
return $sitemap->render();

错误、建议和贡献

请使用 Github 报告错误、评论和建议。

  1. 分支项目。
  2. 创建您的错误修复/功能分支并编写您的(注释良好的)代码。
  3. 提交您的更改并将它们推送到您的仓库。
  4. 创建一个针对此项目 master 分支的新 pull request。

版权和许可证

laravel-news-sitemap 由 Colin Viebrock 编写并发布在 MIT 许可下。有关详细信息,请参阅 LICENSE 文件。

版权 2014 Colin Viebrock