roelofjan-elsinga / flat-file-cms-publish
1.0.0
2020-02-19 12:23 UTC
Requires
Requires (Dev)
- brainmaestro/composer-git-hooks: ^2.7
- friendsofphp/php-cs-fixer: ^2.15
- mikey179/vfsstream: ^1.6
- orchestra/testbench: ^3.8
- phpunit/phpunit: ^8.3
- spatie/phpunit-watcher: ^1.11
README
这是为 Flat File CMS 定制的自发布模块。
安装
您可以通过Composer使用以下命令包含此软件包
composer require roelofjan-elsinga/flat-file-cms-publish
如果您想自定义文件夹结构,则可以通过以下命令发布配置
php artisan vendor:publish --provider="AloiaCms\\Publish\\ServiceProvider"
重写 sitemap 命令
您可以重写 sitemap 命令,因为这个命令默认只支持文章和页面。为此,您需要自己实现该命令并在服务提供者中注册,如下所示
namespace App\Console\Commands; use SitemapGenerator\SitemapGenerator; class SitemapCreator extends \AloiaCms\Publish\Console\SitemapCreator { /** * Overwrite the base implementation and add additional URL's * * @param SitemapGenerator $generator */ protected function appendAdditionalUrls(SitemapGenerator $generator): void { foreach($this->getArrayOfOtherUrlsToAdd() as $url) { $generator->add($url, 0.8, $this->lastmod, 'monthly'); } } /** * Get the urls of the portfolio items * * @return array */ private function getArrayOfOtherUrlsToAdd(): array { return [ '/contact', '/services', '/any-other-urls-you-wish' ]; } }
并在 AppServiceProvider 中注册这个新命令
public function register() { $this->app->bind(\AloiaCms\Publish\Console\SitemapCreator::class, function () { return new \App\Console\Commands\SitemapCreator(); }); }
现在您可以向 sitemap 中添加任何自定义 URL。
测试
您可以通过在终端中运行 ./vendor/bin/phpunit
来运行包含的测试。