Skip to content

Commit e9e8c98

Browse files
Dynamic OGs Again Again 😭 (#178)
* add a lineclamp in case of description * add templates page case
1 parent 532fa2f commit e9e8c98

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

‎components/OgImage/Default.vue‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ defineProps<OgProps>();
8989
</h1>
9090
</div>
9191
<div v-if="publishedAt" class="flex">
92-
<div class="text-xl text-slate-500">
92+
<div class="text-xl text-slate-500 line-clamp-2">
9393
{{ publishedAt }}
9494
</div>
9595
</div>

‎utils/og.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,18 @@ export function getOgProps(baseUrl: string, collection: string, item = {} as any
5555
};
5656
}
5757

58+
case 'templates': {
59+
return {
60+
...props,
61+
title: item.name ?? 'Directus Template',
62+
imageUrl: `${baseUrl}/${item.image?.id}?format=jpeg&width=800`,
63+
badgeLabel: 'Directus Template',
64+
publishedAt: item.description,
65+
authorName: userName(item.creator),
66+
authorImage: `${baseUrl}/${item.creator?.avatar}?format=jpeg&width=800`,
67+
};
68+
}
69+
5870
default:
5971
return props;
6072
}

0 commit comments

Comments
 (0)