Skip to content

Commit

Permalink
feat: optimizes category og images
Browse files Browse the repository at this point in the history
  • Loading branch information
akoenig committed Apr 6, 2024
1 parent b76707e commit 3457aba
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 9 deletions.
6 changes: 4 additions & 2 deletions app/routes/_frontend.$category.$slug.details/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import { getBaseUrl } from "~/utils/get-base-url.server";
import { getModel } from "./query";

export const meta: MetaFunction<typeof loader> = ({ data }) => {
const name = `${data?.currentWorkflow.title} - getactions.dev`;

return [
{
title: `GitHub Actions Starter Workflows: ${data?.currentWorkflow.title} - getactions.dev`,
Expand All @@ -39,7 +41,7 @@ export const meta: MetaFunction<typeof loader> = ({ data }) => {
},
{
property: "og:title",
content: data?.currentWorkflow.title,
content: name,
},
{
property: "og:description",
Expand All @@ -59,7 +61,7 @@ export const meta: MetaFunction<typeof loader> = ({ data }) => {
},
{
property: "twitter:title",
content: data?.currentWorkflow.title,
content: name,
},
{
property: "twitter:description",
Expand Down
2 changes: 1 addition & 1 deletion app/routes/_frontend.$category._index/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export async function getWorkflows(request: Request, category: string) {
daos.map((dao) => ({
id: dao.id,
name: dao.name,
category: dao.category,
category: category,
title: dao.title,
description: dao.description,
})),
Expand Down
50 changes: 49 additions & 1 deletion app/routes/_frontend.$category._index/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,65 @@ import type { LoaderFunctionArgs, MetaFunction } from "@remix-run/node";
import { Link, json, redirect, useLoaderData } from "@remix-run/react";
import { WorkflowCard } from "~/components/workflow-card";
import { WorkflowSwitcher } from "~/components/workflow-switcher";
import { getBaseUrl } from "~/utils/get-base-url.server";
import { getWorkflows } from "./query";

export const meta: MetaFunction<typeof loader> = ({ params, data }) => {
const name = `${data?.category?.name} Workflows - getactions.dev`;

return [
{
title: `GitHub Actions Starter Workflows: ${data?.category?.name} Workflows - getactions.dev`,
},
{
name: "description",
content: data?.category?.description,
},
{
property: "og:site_name",
content: "getactions.dev",
},
{
property: "og:type",
content: "article",
},
{
property: "og:title",
content: name,
},
{
property: "og:description",
content: data?.category?.description,
},
{
property: "og:url",
content: `${data?.baseUrl}/${data?.category?.id}`,
},
{
property: "og:image",
content: `${data?.baseUrl}/api/${data?.category?.id}.png`,
},
{
property: "twitter:card",
content: "summary_large_image",
},
{
property: "twitter:title",
content: name,
},
{
property: "twitter:description",
content: data?.category?.description,
},
{
property: "twitter:image",
content: `${data?.baseUrl}/api/${data?.category?.id}.png`,
},
];
};

export async function loader({ request, params }: LoaderFunctionArgs) {
const baseUrl = getBaseUrl(request);
const requestedCategory = String(params.category);

if (!requestedCategory) {
Expand Down Expand Up @@ -42,7 +90,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
(category) => category.id === requestedCategory,
);

return json({ category, categories, workflows });
return json({ baseUrl, category, categories, workflows });
}

export default function Index() {
Expand Down
1 change: 1 addition & 0 deletions app/routes/api.$category[.png]/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ import { z } from "zod";
export const Model = z.object({
id: z.string(),
name: z.string(),
description: z.string(),
});
1 change: 1 addition & 0 deletions app/routes/api.$category[.png]/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export async function getModel(category: string) {
const model = Model.safeParse({
id: dao?.id,
name: dao?.name,
description: dao?.description,
});

if (!model.success) {
Expand Down
3 changes: 1 addition & 2 deletions app/routes/api.$category[.png]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ export async function loader(args: LoaderFunctionArgs) {

const resultOfGeneratingImage = await createOgImage({
title: `${model.name} Workflows`,
subtitle:
"Jumpstart your next project effortlessly without the hassle of constructing complex GitHub Actions workflows.",
subtitle: model.description,
});

if (resultOfGeneratingImage.isErr()) {
Expand Down
2 changes: 1 addition & 1 deletion app/utils/create-og-image.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export function makeGenerateOgImage() {
>
<div tw="flex items-start justify-start h-full">
<div tw="flex flex-col justify-between w-full h-full p-4">
<div tw="flex flex-col bg-white/70 h-full rounded-3xl justify-center">
<div tw="flex flex-col bg-white/90 h-full rounded-3xl justify-center">
<h2 tw="flex justify-center text-7xl font-extrabold opacity-90 tracking-tight leading-tight text-center px-10">
{request.title}
</h2>
Expand Down
3 changes: 2 additions & 1 deletion workflows/ci/category.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"id": "ci",
"name": "Continuous Integration"
"name": "Continuous Integration",
"description": "Easy to use continuous integration workflows for GitHub Actions."
}
3 changes: 2 additions & 1 deletion workflows/deployment/category.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"id": "deployment",
"name": "Deployment"
"name": "Deployment",
"description": "Easy to use deployment workflows for GitHub Actions."
}
1 change: 1 addition & 0 deletions workflows/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const categories = categoryDirectories.map((categoryDirectory) => {
const category = JSON.parse(contents) as Readonly<{
id: string;
name: string;
description: string;
}>;

return category;
Expand Down

0 comments on commit 3457aba

Please sign in to comment.