groqd icon indicating copy to clipboard operation
groqd copied to clipboard

WIP: added `q.contentBlocks` utility

Open scottrippey opened this issue 7 months ago • 5 comments

Still a WIP

scottrippey avatar Apr 14 '25 18:04 scottrippey

⚠️ No Changeset found

Latest commit: aa2c3df199554152b6a4157760da5a224b2692f7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

changeset-bot[bot] avatar Apr 14 '25 18:04 changeset-bot[bot]

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
groqd ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 14, 2025 6:49pm

vercel[bot] avatar Apr 14 '25 18:04 vercel[bot]

@scottrippey Hey mate, just wanted to say this would be a great feature to have in the package! Thanks for your hard work.

Rhym avatar Nov 14 '25 03:11 Rhym

@Rhym I don't currently have the resources to work on this PR, but I'd be happy to accept contributions if you're able.

scottrippey avatar Nov 14 '25 15:11 scottrippey

Thanks for the reply, @scottrippey . I fully understand. If possible, I just have one issue left with my migration. I can't for the life of me figure out how to split the content here into a fragment for reuse. I have tried so many different ways, and it just doesn't like it:

import { runQuery } from "@/lib/sanity";

import { q, type InferFragmentType } from "./groqd-client";
import { linkExternalFragment } from "./fragments/link-external";
import { linkInternalFragment } from "./fragments/link-internal";

const fragment = q.fragmentForType<"contactPage">().project((sub) => ({
  title: true,
  ogTitle: true,
  ogDescription: true,
  content: sub.field("content[]").project((contentSub) => ({
    "...": true,
    markDefs: contentSub.field("markDefs[]").project((markDefsSub) => ({
      "...": true,
      ...markDefsSub.conditionalByType({
        "annotation.link": {
          _type: true,
          _key: true,
          links: markDefsSub
            .field("links[]")
            .project((linksSub) => ({
              ...linksSub.conditionalByType({
                linkInternal: linkInternalFragment,
                linkExternal: linkExternalFragment,
              }),
            }))
            .slice(0),
        },
      }),
    })),
  })),
}));

export type SanityContactPage = InferFragmentType<typeof fragment>;

export const getContactPageQuery = () =>
  runQuery(q.star.filterByType("contactPage").slice(0).project(fragment), {});

Rhym avatar Nov 14 '25 21:11 Rhym