From 4af0381c407e88ff940e3cb2a5f4e931b013dc48 Mon Sep 17 00:00:00 2001 From: Maria Adriana <97130795+mariadriana-deemaze@users.noreply.github.com> Date: Fri, 29 Nov 2024 11:48:51 +0000 Subject: [PATCH] [SOA-46] Open Graph Tags (#47) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat ๐ธ (SEO): add abstracted head with open graph * test ๐งช (routes): refactor browser tests with izzy routes * fix โ : tag corrections * fix โ : domain url env as an inertia shared prop --- config/inertia.ts | 2 ++ inertia/components/generic/head_og.tsx | 27 ++++++++++++++++ inertia/components/users/nav.tsx | 2 +- inertia/pages/feed.tsx | 8 +++-- inertia/pages/home.tsx | 9 ++++-- inertia/pages/posts/show.tsx | 9 ++++-- inertia/pages/sign_in.tsx | 9 ++++-- inertia/pages/sign_up.tsx | 9 ++++-- inertia/pages/users/settings.tsx | 9 ++++-- inertia/pages/users/show.tsx | 15 +++++++-- public/assets/images/thumbnail.png | Bin 0 -> 182525 bytes start/routes.ts | 9 ++++-- tests/browser/admin_post_report.spec.ts | 4 +-- tests/browser/pages/feed.spec.ts | 39 +++++++++++++++++++----- tests/browser/pages/user_feed.spec.ts | 25 +++++++++++++-- tests/browser/post_report.spec.ts | 10 +++--- tests/browser/user/settings.spec.ts | 4 +-- 17 files changed, 154 insertions(+), 36 deletions(-) create mode 100644 inertia/components/generic/head_og.tsx create mode 100644 public/assets/images/thumbnail.png diff --git a/config/inertia.ts b/config/inertia.ts index d3957c5..2284973 100644 --- a/config/inertia.ts +++ b/config/inertia.ts @@ -1,5 +1,6 @@ import { UserResponse } from '#interfaces/user' import { UserService } from '#services/user_service' +import env from '#start/env' import { defineConfig } from '@adonisjs/inertia' import type { InferSharedProps } from '@adonisjs/inertia/types' @@ -24,6 +25,7 @@ const inertiaConfig = defineConfig({ }, queryParams: (ctx) => ctx.request.qs(), errors: (ctx) => ctx.session?.flashMessages.get('errors'), + domain: () => env.get('PRODUCTION_URL'), }, /** diff --git a/inertia/components/generic/head_og.tsx b/inertia/components/generic/head_og.tsx new file mode 100644 index 0000000..41413d1 --- /dev/null +++ b/inertia/components/generic/head_og.tsx @@ -0,0 +1,27 @@ +import { Head, usePage } from '@inertiajs/react' +import socialAdonisLogo from '../../../public/assets/images/thumbnail.png' + +interface HeadOGProps { + title: string + description: string + url: string + image?: string +} + +export default function HeadOG({ title, description, image, url }: HeadOGProps) { + const props = usePage().props + + const domain = props.domain + + return ( +
+ + + + + + + + + ) +} diff --git a/inertia/components/users/nav.tsx b/inertia/components/users/nav.tsx index c5d9346..706d398 100644 --- a/inertia/components/users/nav.tsx +++ b/inertia/components/users/nav.tsx @@ -87,7 +87,7 @@ export default function UserNavBar({ user }: { user: UserResponse | null }) { > Settings