Giter Site home page Giter Site logo

Comments (7)

WhippetsAintDogs avatar WhippetsAintDogs commented on August 19, 2024 2

Hi @sudhanshu16, you got it.

When you make an 'all' query, the way to filter by the lang is filter - lang - eq - LOCALE and when you do a regular query, you'll specify cockpitId - eq - ID, lang - eq - LOCALE. The LOCALE can be any value you put in the locales option or any.

I even tried adding locales: ["en"] to the config but no luck so far.
By the way, I have not defined any language in Cockpit (I dont even know how to do that :P)

The locales option have to be identical to your Cockpit configuration, so if you have locales: ["en"], you should have that Cockpit configuration (config.php):

<?php

$configs = [];

$configs['languages'] = [
    'default' => 'English',
];

return $configs;

from fika-gatsby-source-cockpit.

WhippetsAintDogs avatar WhippetsAintDogs commented on August 19, 2024

Hi @danielmilner,

if you have at least one locale defined in the plugin configuration, you'll get a node for the default language and one for each locale defined (with each localized field translated in the corresponding language). Print or filter by the lang attribute and you should have only unique nodes ☺.

from fika-gatsby-source-cockpit.

WhippetsAintDogs avatar WhippetsAintDogs commented on August 19, 2024

For the default language, use the lang value any or any locale defined in the plugin configuration.

from fika-gatsby-source-cockpit.

danielmilner avatar danielmilner commented on August 19, 2024

@WhippetsAintDogs That was it! If I set the local to an empty array in the config, I get one of each node. Thanks!

from fika-gatsby-source-cockpit.

WhippetsAintDogs avatar WhippetsAintDogs commented on August 19, 2024

You're welcome! ☺

from fika-gatsby-source-cockpit.

sudhanshug16 avatar sudhanshug16 commented on August 19, 2024

Hey guys,
Can you give an example for the query to run?

I added lang parameter to my query as such:

allCockpitWorks(lang: { eq: "en" }) {
  edges {
    node {
      Title {
        value
      }
      Image {
        value {
          childImageSharp {
            fluid {
              ...GatsbyImageSharpFluid
            }
          }
        }
      }
      Description {
        value
      }
      Featured {
        value
      }
    }
  }
}

This is giving me the following error:
Unknown argument "lang" on field "allCockpitWorks" of type "Query"

My config looks like this:

{
  resolve: "@fika/gatsby-source-cockpit",
  options: {
    token: "0160ee9ee9f43905a38abe64040c28",
    baseUrl: "http://localhost:8888",
    collections: []
  },
},

I even tried adding locales: ["en"] to the config but no luck so far.

By the way, I have not defined any language in Cockpit (I dont even know how to do that :P)

from fika-gatsby-source-cockpit.

sudhanshug16 avatar sudhanshug16 commented on August 19, 2024

About the previous comment, I made the query work with the following snippet:
allCockpitWorks(filter: { lang: { eq: "en" } }) {...}
This is what was intended, right? Or is there something else to it too?

from fika-gatsby-source-cockpit.

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.