Skip to content

Commit

Permalink
fix: twitter meta images
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien-R44 committed Jan 25, 2024
1 parent 92fa73d commit c24b248
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions providers/app_provider.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import edge from 'edge.js'
import { join } from 'node:path'
import { readFile } from 'node:fs/promises'
import { getDirname } from '@poppinss/utils'
Expand Down Expand Up @@ -25,5 +26,10 @@ export default class AppProvider {
this.app.container.bind(PackagesFetcher, async (resolver) => {
return new PackagesFetcher(await resolver.make(PackageFetcher), packagesFile)
})

/**
* Helper for removing double slashes from urls
*/
edge.global('cleanUrl', (url: string) => url.replace(/([^:]\/)\/+/g, '$1'))
}
}
6 changes: 3 additions & 3 deletions resources/views/components/meta.edge
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@assign(title = title ?? 'AdonisJS Packages')
@assign(description = description ?? 'Discover our list of packages to supercharge your AdonisJS project. Created by the AdonisJS team and community.')
@assign(image = image ?? 'https://packages.adonisjs.com/preview.png')
@assign(image = image ?? '/preview.png')

<title inertia>{{ `${title} - AdonisJS Packages` }}</title>
<meta name="title" content="{{ `${title} - AdonisJS Packages` }}">
Expand All @@ -11,12 +11,12 @@
<meta property="og:url" content="https://package.adonisjs.com" />
<meta property="og:title" content="{{ title }}" />
<meta property="og:description" content="{{ description }}" />
<meta property="og:image" content="{{ image }}" />
<meta property="og:image" content="{{ cleanUrl(`https://packages.adonisjs.com/${image}`) }}" />

{{-- Twitter --}}
<meta name="twitter:card" content="summary_large_image">
<meta property="twitter:domain" content="boundary-msg-produced-lifestyle.trycloudflare.com">
<meta property="twitter:url" content="https://package.adonisjs.com">
<meta name="twitter:title" content="AdonisJS Packages">
<meta name="twitter:description" content="Discover our list of packages to supercharge your AdonisJS project. Created by the AdonisJS team and community.">
<meta name="twitter:image" content="{{ image }}">
<meta name="twitter:image" content="{{ cleanUrl(`https://packages.adonisjs.com/${image}`) }}">

0 comments on commit c24b248

Please sign in to comment.