d4l-data4life / kirby3-static-site-generator

Static site generator plugin for Kirby 3+. With this plugin you can create a directory with assets, media and static html files generated from your pages. The result is an even faster site with less potential vulnerabilities.
MIT License
138 stars 7 forks source link

Unable to generate sitemap #59

Closed robbertrosario closed 2 years ago

robbertrosario commented 2 years ago

Expected Behavior

I am using this sitemap snippet: https://getkirby.com/docs/cookbook/content/sitemap by Bastian. But it doesn't generate an actual sitemap.xml file it just starts rendering the xml when you access the route.

I've tried using the ready function as per README, but the custom_routes expect a page id, but the above sitemap snippet is not an actual page? and therefore has no page id?

Current Behavior

Sitemap is not generated

Context

Kirby version: 3.7 Plugin version: 1.5.1

Installed using composer

ShallowRed commented 2 years ago

To generate a static sitemap I use new Page() in the plugin's config ready option :

// config.php
return [
    'ready' => function() {
        return [
            'd4l.static_site_generator' => [
                'custom_routes' => return [[
                    'path' => '/sitemap.xml',
                    'page' => new Page([
                        'template' => 'sitemap',
                        'slug' => 'sitemap',
                    ]),
                ]];
            ],
        ];
    }
];

I have a sitemap.php in the template folder, I don't what you should do with your snippet from the cookbook. Creating a sitemap.php template which just calls your snippet should work.

robbertrosario commented 2 years ago

That seems to work thanks!