Giter Site home page Giter Site logo

bkwld / cloak-algolia Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 708 KB

Nuxt module for syncing records to Algolia and bootstrapping Instantsearch.js

Home Page: https://cloak-algolia.netlify.app

License: MIT License

JavaScript 100.00%
algolia nuxt

cloak-algolia's People

Contributors

mattaebersold avatar weotch avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

cloak-algolia's Issues

Implement syncing module

This roughly refactoring algolia-sync.coffee

  • Set configuration via Nuxt module options
  • Figure out how to transpile .gql files so card fragments can be reused
    • Use Webpack's node module to produce chunks to in memory filesystem and then read strings out, like in this demo
    • I think this work goes into @cloak-app/utils as like loadGql(path)
  • Add option for setting the hook to use
  • Add CLI interface (useful for executing while dev-ing the package)
  • Include docs on expectation on where fragments live and what the files are named. And how you need one of query, fragmentPath, or records
  • Use dotenv in cli for use in like the indexName creation
  • Sync Craft records
  • Support mergeShopifyProducts
  • Test syncing from demo site
  • Make a demo showing results
    • Make a helper for prefixing index name

Example configuration option API:

export default {
  cloak: {
    algolia: {
      sync: async ({ $craft, $storefront }) => {

        // Most Craft-only indexes can be built using configuration strings
        // or objects
        const simpleRules = [

          // If just a string, will query Craft for entries of this section name
          // using a fragment from ~/queries/fragments/articles.gql. Index
          // configuration is done through the dashboard.
          'articles',

          // If an object, lets you customize the sync options a bit. TBD what
          // the options are.
          {
            indexHandle: 'blogs',
            section: 'blogPosts',
          },

        ]

        // You can also generate dynamic indices, like for collections
        const collections = await $craft.getEntries({
          query: `
            query {
              entries(section: "collections") {
                ...collection
              }
            }
          ` + collectionFragment
        })
        const productsRules = await Promise.all(collections.map(
          async (collection) => {
            const craftProducts = await $craft.getEntries({
              query: `
                query($collection:String) {
                  entries(section: "products",) {
                    ...product
                  }
                }
              ` + productFragment,
            })
            return {
              indexHandle: `collection-${collection.slug}`,
              settings: {}, // Algolia settings object
              records: await $storefront.mergeProducts(craftProducts)
            }
        }))

        return [ ...simpleRules, ...productsRules ]
      }
    }
  }
}

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.