Skip to content

Commit

Permalink
Dynamic OGs Again Again 😭 (#178)
Browse files Browse the repository at this point in the history
* add a lineclamp in case of description

* add templates page case
  • Loading branch information
bryantgillespie authored Jan 7, 2025
1 parent 532fa2f commit e9e8c98
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion components/OgImage/Default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ defineProps<OgProps>();
</h1>
</div>
<div v-if="publishedAt" class="flex">
<div class="text-xl text-slate-500">
<div class="text-xl text-slate-500 line-clamp-2">
{{ publishedAt }}
</div>
</div>
Expand Down
12 changes: 12 additions & 0 deletions utils/og.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ export function getOgProps(baseUrl: string, collection: string, item = {} as any
};
}

case 'templates': {
return {
...props,
title: item.name ?? 'Directus Template',
imageUrl: `${baseUrl}/${item.image?.id}?format=jpeg&width=800`,
badgeLabel: 'Directus Template',
publishedAt: item.description,
authorName: userName(item.creator),
authorImage: `${baseUrl}/${item.creator?.avatar}?format=jpeg&width=800`,
};
}

default:
return props;
}
Expand Down

0 comments on commit e9e8c98

Please sign in to comment.