Giter VIP home page Giter VIP logo

Comments (5)

Haroenv avatar Haroenv commented on May 25, 2024 1
const queries = [
  {
    query: myQuery,
    transformer: ({ data }) => data.allSitePage.edges.map(({ node }) => node), // optional
    indexName: 'index name to target', // overrides main index name, optional
    settings: {
      // optional, any index settings
      hitsPerPage: 9
    },
  },
];

module.exports = {
  plugins: [
    {
      resolve: `gatsby-plugin-algolia`,
      options: {
        appId: process.env.ALGOLIA_APP_ID,
        apiKey: process.env.ALGOLIA_API_KEY,
        indexName: process.env.ALGOLIA_INDEX_NAME, // for all queries
        queries,
        chunkSize: 10000, // default: 1000
      },
    },
  ],
};

OR in the frontend:

<Configure hitsPerPage={9} />

from gatsby-plugin-algolia.

Haroenv avatar Haroenv commented on May 25, 2024

the hits per page is supposed to go in the settings key (in each query), does that fix it for you? The hitsPerPage where you put it isn't an option :)

from gatsby-plugin-algolia.

arhoy avatar arhoy commented on May 25, 2024

I am not sure what you mean by settings key in each query Do you have a code example or screenshot I can follow?

Thank you. Currently I am limiting like so, but I not sure if it is best practice

const ProductSearchPreview = ({ hit }) => {
  if (hit && hit.__position <= 9) {
    return (
      <Container>
        <CustomLink to={`/product/${hit.handle}`}>
          <h4>{hit.title}</h4>
        </CustomLink>
      </Container>
    );
  } else {
    return null;
  }
};

from gatsby-plugin-algolia.

arhoy avatar arhoy commented on May 25, 2024

I would prefer to limit it in some settings to limit my algolia index usage.

from gatsby-plugin-algolia.

arhoy avatar arhoy commented on May 25, 2024

Thank you that is very helpful!

from gatsby-plugin-algolia.

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.