Giter Site home page Giter Site logo

Comments (3)

aileen avatar aileen commented on May 31, 2024

That would be a very nice feature!!! PRs are very welcome 😃

from gatsby-plugin-advanced-sitemap.

fmaiabatista avatar fmaiabatista commented on May 31, 2024

I have the opposite problem - I have one query and want to be able to split it into multiple sitemaps. Can this be achieved?

Example:

query: `
  allSitePage { ... }
`,
mapping: {
  allSitePage: {
    sitemap: `products`, // by filtering the query result with some logic
    sitemap: `category`, // by filtering the query result with some logic
    sitemap: ...
  }
}

Also let me know if this belongs to a new Issues entry!

from gatsby-plugin-advanced-sitemap.

tbaustin avatar tbaustin commented on May 31, 2024

@fmaiabatista you could theoritically just use aliases in your gql to bypass this I think.

query: `{
  products: allSitePage { ... }
  category: allSitePage { ... }
}`

I agree with the OP. Being able to combine queries into one would be super useful. Only way around this I can think of would be to create a new set of nodes using sourceNodes with the combined queries then querying those new nodes that way.
@aileen would that work?

This could also be solved by allowing a top level serializer rather than on each individual query, so on the top level query, which you would then return the objects for creating the sitemaps.

It would go something like:

query: `{ 
  categories: {...}
  products: {...}
}`,
serializer: (({ products, categories }) => {
  const productMap = products.map(...)
  const categoriesMap = categories.map(...)
  
  return {
     ["name_of_sitemap"]: productMap,
     ["categories_sitemap"]: categoriesMap
    }
}) 

Just as an example.

from gatsby-plugin-advanced-sitemap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.