Ria Choi
← Portfolio

Blog

A personal publishing platform designed to let editorial updates, site rendering, and contact delivery evolve independently.

Blog

I built this site so I could publish technical writing and update portfolio entries without editing the frontend for every article. I also wanted changes in the CMS to have a predictable path to the public site, and enquiries to reach an inbox without tying the delivery provider to the UI.

Making a CMS edit visible at the right time

Sanity stores structured articles, categories, and projects. Next.js renders the content, including Portable Text blocks, and shares the post lookup between page content and metadata through React cache. The fetch uses a shared Next.js cache tag, which a signed CMS webhook can invalidate on a content change.

JavaScript
// Keep CMS data until a signed Sanity webhook invalidates this shared tag.
const options = {
  next: { revalidate: false, tags: ["sanity-content"] },
  cache: "force-cache",
};

export const getPosts = cache(() => client.fetch(POSTS_QUERY, {}, options));
export const getCategories = cache(() => client.fetch(CATEGORY_QUERY, {}, options));
// Share the post lookup between metadata and page rendering.
export const getPost = cache((slug) =>
  client.fetch(POST_BY_SLUG_QUERY, { slug }, options)
);

Keeping enquiry delivery behind a small server boundary

The Resend helper sends from a verified address and puts the visitor’s email in Reply-To. That makes replies go to the right person while keeping the configured sender on the server. Missing configuration returns an explicit unavailable result, giving the form a separate failure state to handle.

JavaScript
export async function sendContactEmail({ email, message }) {
  const from = process.env.RESEND_FROM_EMAIL;
  const to = process.env.ADMIN_EMAIL;
  if (!process.env.RESEND_API_KEY || !from || !to) {
    return { success: false, unavailable: true };
  }

  const { resend } = await import("@/lib/resend");
  const { data, error } = await resend.emails.send({
    from,
    to: [to],
    replyTo: email,
    subject: "New website enquiry",
    text: `From: ${email}\n\n${message}`,
  });
  return { success: !error && Boolean(data?.id) };
}

What I learned

The seams I wanted were practical: one for editing content, one for deciding when it needs refreshing, and one for handling delivery. Each can be changed without rebuilding the others.

Related articles

How I Built this Blog

Subscription & Email in Next.js