uasoft-indonesia/badaso-sitemap-module

此包已被弃用,不再维护。作者建议使用badaso/sitemap-module包。

badaso博客系统无开发

2.0.0-rc.1 2021-07-08 16:04 UTC

This package is auto-updated.

Last update: 2022-09-01 08:49:11 UTC


README

安装

  1. 从laravel项目安装Badaso
  2. 安装badaso sitemap模块 composer require badaso/sitemap-module
  3. 设置环境变量
MIX_DEFAULT_MENU=admin
MIX_BADASO_MENU=${MIX_DEFAULT_MENU},sitemap-module
MIX_BADASO_PLUGINS=sitemap-module
  1. 调用命令 php artisan badaso-sitemap:setup
  2. 运行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',
        ],
        ...
    ],
    ...
],
...