johannschopplich / kirby-nuxt-starterkit

💚 Kirby's sample site – ported to Nuxt and Kirby Query Language
https://kirby-nuxt-starter.pages.dev
MIT License
51 stars 2 forks source link

Possible to access `kirby.collections`? #4

Closed Jorckx closed 11 months ago

Jorckx commented 11 months ago

Hi there :) What a good framework you've build! Everything works like charm for me. It's also very flexible to make it my own. However, I wondered if it's possible to acces a kirby collections? it seems like I can only query the pages and the site.

johannschopplich commented 11 months ago

Hi there!

Sure, Kirby collections are supported via KQL. You can use all the KQL methods in Nuxt KQL:

const { data } = await useKql(
  {
    query: 'collection("articles/latest")',
    pagination: {
      page: 1,
      limit: 8,
    },
    select: {
      uri: true,
      title: true,
      isListed: true,
    },
  },
  { language: locale.value },
)

Use collection() instead of kirby.collection and it will work.

P. S.: This is just the starter kit. If you have further questions, please raise it over at the Nuxt KQL module repo. Thanks!

Jorckx commented 11 months ago

Oh, it was as simple as that. wonderful! I'll take note. Thanks for the quick response. And oops, wrong repository indeed :)