Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from local data to Sanity #3

Open
9 of 13 tasks
tinymachine opened this issue Jul 22, 2024 · 3 comments
Open
9 of 13 tasks

Switch from local data to Sanity #3

tinymachine opened this issue Jul 22, 2024 · 3 comments

Comments

@tinymachine
Copy link
Contributor

tinymachine commented Jul 22, 2024

  • Place all current data calls in index.astro instead of spread throughout components. #11
  • Determine correct GROQ query to retrieve project data (including referenced image metadata for the 'stills') and add the query as a comment on this issue below
  • Install Astro's Sanity plugin?
  • Replace .md files with Sanity as data source
    • Update About section
      • Image
      • Social and other links
      • Text
    • Update Reel (and stills) at top of page
    • Update projects
      • Fetch projectSet data from Sanity
      • Loop through projectSets to display projects in correct groupings and order
  • Remove any unused npm packages (e.g. @sanity/image-url, @sanity/visual-editing)
@tinymachine
Copy link
Contributor Author

tinymachine commented Aug 30, 2024

Reel query:

*[_type=="reel"][0]

or (with image dereferenced)


*[_type=="reel"][0] {
  ...,
  placeholderStills[]{
    ...,
    asset->
  }
}

Settings query:

*[_type=="settings"][0] {
  ...,
  projectSets[]->
}

About query:

*[_type=="about"][0]

or (with image dereferenced)

*[_type=="about"][0] {
  ...,
  image{
    ...,
    asset->
  }
}

with null check

*[_type == "about"][0] {
  ...,
  image != null => { 
    "image": {
      ...image,
      "asset": image.asset->,
    }
  }
}

Project sets query:

*[_type=="project"][] {
  ...,
  projectSet->,
  featuredStill {
    ...,
    asset->
  },
  stills[] {
    ...,
    asset->
  }
}

@tinymachine
Copy link
Contributor Author

Reference GROQ from my other project that you can modify:

  *[_type == "household" && isActive] {
      ...,
      photo != null => { "photo": {
        ...photo,
        "dimensions": photo.asset->metadata.dimensions,
        "url": photo.asset->url,
      }}
    } | order(primarySurname asc, primaryAdultFirstNames asc)

@OshanBathiya
Copy link
Collaborator

OshanBathiya commented Dec 14, 2024

Custom renderPortableText Function VS Astro Portable Text

renderPortableText function can only render

  • Text
  • Bold
  • Italic
  • Links

while Astro Portable Text package can handle

  • Headings, Nested lists, Custom blocks, Code, Images and more.

astro-portabletext

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants