Skip to content

Commit

Permalink
Merge pull request #16 from leon-luna-ray/dev
Browse files Browse the repository at this point in the history
add image alt text from cms
  • Loading branch information
leon-luna-ray committed Feb 11, 2024
2 parents be78cae + 8444754 commit e208252
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Alpine.store("darkMode", {
Alpine.store("data", {
skills: skills || [],
profile: profile,
image: profile.image ? getThumbnailUrl(profile.image) : "#",
image: profile.image,
projectsIntro: portableTextToHTML(projects.description) || "",
projects: projects.projects || [],
getThumbnailUrl,
Expand Down
10 changes: 9 additions & 1 deletion src/js/sanity.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@ export function getImageUrl(source) {
}

export async function fetchProfile() {
const query = `*[_type == "profileDetails"][0]`;
const query = `*[_type == "profileDetails"][0]{
...,
"image": image.asset->{
_id,
title,
altText,
description,
},
}`;
const profile = await client.fetch(query);

return profile;
Expand Down
4 changes: 2 additions & 2 deletions src/pages/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ <h2>About Me</h2>
<h3 x-text="$store.data.profile.greeting" class="font-orbitron h4 dark:!text-alpine-20 font-[100]"></h3>
</div>
<div class="flex-col-2 md:col-span-2">
<img :src="$store.data.image" alt="Profile picture"
<img :src="$store.data.getThumbnailUrl($store.data.image)" :alt="$store.data.image.altText || 'Profile picture'"
class="object-cover aspect-square md:aspect-video xl:aspect-[21/9] rounded-border" />
<p x-text="$store.data.profile.bio" class="flex-1 text-[1.25rem] leading-[2.2rem]"></p>
</div>
Expand All @@ -54,7 +54,7 @@ <h2 class="">Projects</h2>
<template x-for="project in $store.data.projects">
<a native :href="project.url" target="_blank"
class="flex-col-1 hover:no-underline hover:!text-inherit zoom-in-out">
<img :src="$store.data.getThumbnailUrl(project.mainImage)" :alt="project.title"
<img :src="$store.data.getThumbnailUrl(project.mainImage)" :alt="project.mainImage.altText"
class="aspect-[16/9] object-cover rounded-border" />
<div class="flex-col-05">
<h3 x-text="project.title" class="font-dm font-bold h4 dark:!text-alpine-20 opacity-90">
Expand Down

0 comments on commit e208252

Please sign in to comment.