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

feat: add captioned image component #440

Merged
merged 4 commits into from
Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: add header caption
  • Loading branch information
oddgrd committed Oct 27, 2022
commit 8e5394e9fc10bf20827d10145dae9e0bbb77fc30
2 changes: 2 additions & 0 deletions www/_blog/2022-10-21-shuttle-beta.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ author: brokad
tags: [rust, startup, beta, backend]
thumb: shuttle-beta.png
cover: shuttle-beta.png
caption: 'An oil paining of an orange shuttle taking off with a container exploding in the background - DALL·E 2'
date: "2022-10-21T15:00:00"
---

<TLDR>
<p>Containers have improved development in a lot of ways, but over time they have also created a lot of problems. We believe it's time to take a bold view and rethink the way we do backend development.</p>
<p>We're announcing [shuttle-next](https://shuttle.rs/beta): a next-generation backend development framework that has up to **100x smaller images** and **deploys end-to-end in under a second**.</p>
Expand Down
2 changes: 1 addition & 1 deletion www/lib/posts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface Post {
readonly title: string;
readonly date: string;
readonly cover?: string;
readonly caption?: string;
readonly coverAspectRatio?: string;
readonly author?: string;
readonly author_url?: string;
Expand Down Expand Up @@ -51,7 +52,6 @@ export function getSortedPosts(
//Extracts contents of the MDX file
const fileContents = fs.readFileSync(fullPath, "utf8");
const { data, content } = matter(fileContents);

const options: Intl.DateTimeFormatOptions = {
month: "long",
day: "numeric",
Expand Down
28 changes: 18 additions & 10 deletions www/pages/blog/[year]/[month]/[day]/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ const mdxComponents: MDXRemoteProps["components"] = {
return (
<div className="grid grid-cols-1 justify-items-center">
<img src={props.src} alt={props.src}></img>
<span className="-mt-6 text-sm dark:text-gray-200">
<span className="-mt-6 text-sm text-[#828282] dark:text-gray-300">
{props.caption}
</span>
</div>
Expand Down Expand Up @@ -311,17 +311,25 @@ export default function BlogPostPage(props: Props) {
{/* Content */}
<div className="flex-1 overflow-hidden">
{(props.blog.thumb ?? props.blog.cover) && (
<div
className="relative mb-8 aspect-[4/3] overflow-auto rounded"
style={{
aspectRatio: props.blog.coverAspectRatio,
}}
>
<Image
<div className="mb-8 grid grid-cols-1 justify-items-center">
{/* todo: fix this temporary hack to fix the caption */}
<img
className="rounded"
src={"/images/blog/" + (props.blog.cover ?? props.blog.thumb)}
layout="fill"
objectFit="cover"
alt="Cover image"
/>
{/* <Image
src={
"/images/blog/" + (props.blog.cover ?? props.blog.thumb)
}
layout="fill"
objectFit="contain"
/> */}
{props.blog.caption && (
<span className="mt-2 text-sm text-[#828282] dark:text-gray-300">
{props.blog.caption}
</span>
)}
</div>
)}
<article
Expand Down