Skip to content

Commit

Permalink
Add OG image support
Browse files Browse the repository at this point in the history
  • Loading branch information
Dobefu committed Apr 28, 2024
1 parent e067e60 commit dd061ea
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 6 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"require": {
"composer/installers": "^2.0",
"cweagans/composer-patches": "~1.0",
"dobefu/nuxtify_profile": "^1.0.x-dev",
"dobefu/nuxtify_profile": "^1.0@beta",
"drupal/core-composer-scaffold": "^10.2",
"drupal/core-recommended": "^10"
},
Expand Down
7 changes: 3 additions & 4 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions frontend/base/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ async function onBeforeEnter() {
lang.value = i18nHead.value.htmlAttrs.lang
dir.value = i18nHead.value.htmlAttrs.dir
}
defineOgImageComponent('LayoutOgImage')
</script>

<template>
Expand Down
32 changes: 32 additions & 0 deletions frontend/base/components/layout/LayoutOgImage.server.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<script setup lang="ts">
defineProps<{
title?: string
description?: string
}>()
const config = useRuntimeConfig()
</script>

<template>
<div class="w-full h-full px-12 text-2xl">
<div class="flex items-center gap-4 py-8 mb-12 border-b border-gray-200">
<img
src="/logo-512.png"
height="96px"
width="96px"
alt=""
>
<h1>
{{ config.public.siteName }}
</h1>
</div>

<h2 class="mt-0 mb-4 font-normal">
{{ title }}
</h2>

<p class="mt-0 leading-10 text-justify text-ellipsis line-clamp-4">
{{ description }}
</p>
</div>
</template>
6 changes: 5 additions & 1 deletion frontend/base/pages/user/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ function setUserData() {
setUserData()
useHead({
title: userData.value?.name,
})
const unwatchData = watch(data, () => {
setUserData()
})
Expand All @@ -54,7 +58,7 @@ onBeforeRouteLeave((to, from) => {
<template>
<div class="max-w-6xl m-auto">
<div v-if="userData" class="flex flex-col gap-8">
<div class="flex justify-between flex-wrap items-center">
<div class="flex flex-wrap items-center justify-between">
<BasePageTitle>
{{ userData.name }}
</BasePageTitle>
Expand Down
31 changes: 31 additions & 0 deletions frontend/themes/default/components/layout/LayoutOgImage.server.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<script setup lang="ts">
defineProps<{
title?: string
description?: string
}>()
const config = useRuntimeConfig()
</script>

<template>
<div class="w-full h-full text-3xl leading-6 text-white bg-stone-900">
<div
class="flex items-center gap-8 px-12 py-8 mb-12 border-b bg-stone-800 border-stone-700"
>
<img src="/logo-512.png" height="96px" width="96px" alt="">
<h1>
{{ config.public.siteName }}
</h1>
</div>

<div class="px-12">
<h2 class="mt-0 mb-8">
{{ title }}
</h2>

<p class="mt-0 leading-10 text-justify text-ellipsis line-clamp-4">
{{ description }}
</p>
</div>
</div>
</template>

0 comments on commit dd061ea

Please sign in to comment.