FriendsOfFlarum / sitemap

Generate a sitemap.
https://discuss.flarum.org/d/14941
MIT License
14 stars 16 forks source link

Add pseudo resource for registering static URLs #47

Closed iPurpl3x closed 1 year ago

iPurpl3x commented 1 year ago

Changes proposed in this pull request: In this PR there is a new default Resource added to the Provider: StaticUrls. This is a pseudo-resource, as it isn't related to any model. It contains a list of route names that can be iterated to generate URLs to static pages of the app. By default there are 2 static pages: index and tags. Tags are only present in the list if the tags extension is activated.

A new Extender (FoF\Sitemap\Extend\RegisterStaticUrl) has been added, so that other extensions can add thier own static URLs to the list. Example:

new RegisterStaticUrl('reviews')

Other minor changes:

Reviewers should focus on:

Screenshot

<?xml version="1.0" encoding="UTF-8"?>

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <url>
    <loc>http://localhost:8888/all</loc>
            <lastmod>2023-04-05T08:27:44+00:00</lastmod>
                <changefreq>daily</changefreq>
                <priority>0.5</priority>
    </url>
    <url>
    <url>
    <loc>http://localhost:8888/tags</loc>
            <lastmod>2023-04-05T08:27:44+00:00</lastmod>
                <changefreq>daily</changefreq>
                <priority>0.5</priority>
    </url>
</urlset>

Confirmed

iPurpl3x commented 1 year ago

@clarkwinkelmann or @davwheat, would one of you have time to look at this and potentially release it? I had conceptually discussed these changes previously with @imorland, and he supported the main idea of this new pseudo resource for static URLs.

iPurpl3x commented 1 year ago

@imorland I added some documentation to the readme.