badaso / sitemap-module
badaso博客系统零开发
赞助包维护!
Open Collective
uasoft-indonesia
2.0.0-rc.1
2021-07-08 16:04 UTC
Requires
- symfony/var-exporter: ^5.2.0
This package is auto-updated.
Last update: 2024-08-29 05:44:10 UTC
README
安装
- 从laravel项目安装Badaso
- 安装badaso sitemap模块
composer require badaso/sitemap-module
- 设置环境变量
MIX_DEFAULT_MENU=admin
MIX_BADASO_MENU=${MIX_DEFAULT_MENU},sitemap-module
MIX_BADASO_PLUGINS=sitemap-module
- 调用命令
php artisan badaso-sitemap:setup
- 运行laravel项目并调用url
http://your-laravel-host/sitemap.xml
配置
配置文件 config.php
return [
'max_content_paginate' => 500,
'prefix' => '/',
'sitemap' => [
'badaso-blog' => [
'table' => 'posts',
'web-access' => [
'url' => env('MIX_BLOG_POST_URL_PREFIX').'/:slug',
// :slug is a field in table posts
// this url auto generate according to the number of table rows
],
],
...
],
'custom_sitemap' => [
'root' => [
'/' => [
'lastmod' => '2021-05-24T09:32:52.785Z',
],
'sub-path' => [
'lastmod' => '2021-05-24T09:32:52.785Z',
],
'sub-path/sub-path-other' => [
'lastmod' => '2021-05-24T09:32:52.785Z',
],
...
],
...
],
];
你可以获取外键表属性
...
'sitemap' => [
'badaso-blog' => [
'table' => 'posts',
'web-access' => [
'url' => env('MIX_BLOG_POST_URL_PREFIX').'/:posts.category_id,category.id,category.title',
// posts.category_id => foreign key posts table field category_id
// category.id => posts table category_id field reference to table category field id
// category.title => output value to path url from category table title field
// output : http://{HOST}/{MIX_BLOG_POST_URL_PREFIX}/business
],
],
...
],
...
你可以创建自定义的sitemap URL
...
'custom_sitemap' => [
// group by http://{HOST}/roo/sitemap.xml
'root' => [
// http://{HOST}/root
'/' => [
'lastmod' => '2021-05-24T09:32:52.785Z',
],
// http://{HOST}/sub-path
'sub-path' => [
'lastmod' => '2021-05-24T09:32:52.785Z',
],
// http://{HOST}/sub-path/sub-path-othe
'sub-path/sub-path-other' => [
'lastmod' => '2021-05-24T09:32:52.785Z',
],
...
],
...
],
...