operate-first / operate-first.github.io-old

GNU General Public License v3.0
18 stars 42 forks source link

Speed up build #296

Closed tumido closed 2 years ago

tumido commented 3 years ago

The page takes ages to build (in both dev and prod) because our node layout is not ideal.

Any changes requires whole schema rebuild, because our navigation queries all possible routes via GraphQL and filters them on render. This filtering should happen during schema query instead:

https://github.com/operate-first/operate-first.github.io/blob/02b83ad2dd9d3d4031d3e9e93593164f3f4a9309/src/components/Layout/NavSidebar.js#L58-L75

Should be something like:

{
  allNavData(filter: {navItems: {elemMatch: {links: {elemMatch: {href: {regex: "/^$basePath/"}}}}}}) {
    edges {
      node {
        navItems {
          label
          links {
            href
            id
            label
          }
          id
          href
        }
      }
    }
  }
}

for that we need to refactor gatsby-node.js and enrich navItems with basePath property.