Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude excludes more than exact matches #114

Open
YoungiiJC opened this issue Nov 30, 2020 · 1 comment
Open

Exclude excludes more than exact matches #114

YoungiiJC opened this issue Nov 30, 2020 · 1 comment

Comments

@YoungiiJC
Copy link

YoungiiJC commented Nov 30, 2020

Hey there. It seems the exclude method is not working correctly. When I exclude /team, pages such as /submit-your-team or /request-a-team are excluded as well.

Line 186 of gatsby-node.js is:

return slug.indexOf(excludedRoute) >= 0

/* logged output
{
  excludedRoute: 'team/',
  slug: 'suggest-a-team/',
  match: true,
}
*/

This might be by design, so correct me if I'm wrong 😄 But looks like slug and excludedRoute are transposed. indexOf should return a strict equality match. We get a strict match if we do :

return excludedRoute.indexOf(slug) >= 0

/* logged output
{
  excludedRoute: 'team/',
  slug: 'suggest-a-team/',
  match: false,
}
*/

Note: this fix breaks the default exclusion of /dev-404-page/`, `/404/`, `/404.html.

In case this helps, I'm on "gatsby": "^2.12.1" and here's my config:

    {
      resolve: `gatsby-plugin-advanced-sitemap`,
      options: {
        exclude: [`/team`, `/team/`, `/dev-404-page/`, `/404/`, `/404.html`],
        query: `{
          allPublishedTeams {
            edges {
              node {
                slug
                image
              }
            }
          }
        }`,
        mapping: {
          allPublishedTeams: {
            sitemap: `teams`,
          },
        },
        addUncaughtPages: true,
      },
    },

I'm happy to open a PR for this change. Let me know :)

@francesco-serialparts
Copy link

I have a similar problem about the not exact match between URL. I have several sitemaps with URL queried from different queries, one of that is from an custom post in an headless WP source allWordpressWpGuide.
When I use the plugin, some posts of this query go between the UncaughtPages and are been replaced from other posts (from blog or custom post) with similar URL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants