strapi-plugin-sitemap icon indicating copy to clipboard operation
strapi-plugin-sitemap copied to clipboard

[FEAT] Allow for queries/filters on collections when generating the sitemap

Open Kyle772 opened this issue 2 years ago • 5 comments

What does it do?

This implements conditions into the collections queries.

Below is a SS of the UI change.

image

Why is it needed?

The general idea here is to make the sitemaps more flexible. In my case, I wanted to filter out anything that was removed from the website when an entry was marked as deleted (but not unpublished so we can retain data where necessary; ie invoicing).

How to test it?

Nothing major was added so you should be able to run this as you normally would

Related issue(s)/PR(s)

Let us know if this is related to any issue/pull request

I think this only impacts the below issue but there may be some others.

#99

Kyle772 avatar Mar 01 '23 04:03 Kyle772

this is amazing. just want to thank @Kyle772 for this feature, i had a hard time to extend the plugin to do the same thing <3

cipick avatar Jul 18 '23 13:07 cipick

I figured this feature deserves it's own section. So I've split up the modal in tabs, where the "Filters" tab contains this feature.

Scherm­afbeelding 2023-07-19 om 10 48 44

boazpoolman avatar Jul 19 '23 09:07 boazpoolman

I've updated the settings schema a bit.

The PR was initially propsed with a settings object that might look like this:

{
  "contentTypes": {
    "api::page.page": {
      "languages": { "und": {
        "pattern": "/pages/[id]",
        "condition1": "slug",
        "condition1Operator": "$not",
        "condition1Value": "test"
      }
    }
  }
}

I've updated the PR so that the filters will be saved separately from the other pattern settings. Which could lead to a settings object that might look like this:

{
  "contentTypes": {
    "api::page.page": {
      "languages": { "und": { "pattern": "/pages/[id]" },
      "filters": {
        "0": {
          "field": "slug",
          "operator": "$not",
          "value": "test"
        }
      }
    }
  }
}

boazpoolman avatar Jul 19 '23 09:07 boazpoolman

Hi @Kyle772

Have you been able to take a look at the feedback I've posted on the PR? I'd love to get this feature merged.

boazpoolman avatar Mar 13 '24 09:03 boazpoolman

Hi @Kyle772

Have you been able to take a look at the feedback I've posted on the PR? I'd love to get this feature merged.

Wow I'm so sorry I don't ever check my github inbox lol. I'll try to address these changes sometime over the next couple of weeks. Sort of slammed at the moment but would love for this to get merged as I use my own fork on my sites

Kyle772 avatar Apr 12 '24 19:04 Kyle772