]> git.localhorst.tv Git - alttp.git/commitdiff
tech meta image
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Fri, 25 Aug 2023 21:27:34 +0000 (23:27 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Fri, 25 Aug 2023 21:27:34 +0000 (23:27 +0200)
app/Http/Controllers/TechniqueController.php
resources/js/components/pages/Technique.js
resources/views/app.blade.php

index 1d51aff846f6f48910be8ae82c0e5e0d5483838a..b88b5a3c21645a94f2370b4ff2b76ab324f96d2a 100644 (file)
@@ -72,9 +72,15 @@ class TechniqueController extends Controller
        public function web(Request $request, $type, $name) {
                $tech = Technique::where('type', '=', $type)->where('name', '=', $name)->first();
                if ($tech) {
-                       return view('app')
+                       $view = view('app')
                                ->with('title', $tech->getTranslatedProperty('title'))
                                ->with('description', $tech->getTranslatedProperty('short'));
+                       if ($tech->image) {
+                               $view = $view->with('image', url($tech->image));
+                       } else if ($tech->gif) {
+                               $view = $view->with('image', url($tech->gif));
+                       }
+                       return $view;
                }
                $url_map = [
                        'dungeon' => 'dungeons',
index 30eed5b03a4104634ac5f806f3c7a563693b76cb..a24b8797ae560ae8d845ecf46dc279d435d6db37 100644 (file)
@@ -90,6 +90,14 @@ const Technique = ({ basepath, type }) => {
                        <title>{getTranslation(technique, 'title', i18n.language)}</title>
                        <meta name="description" content={getTranslation(technique, 'short', i18n.language)} />
                </Helmet>
+               {technique.image ? <Helmet>
+                       <meta property="og:image" content={technique.image} />
+                       <meta property="twitter:image" content={technique.image} />
+               </Helmet> : null}
+               {!technique.image && technique.gif ? <Helmet>
+                       <meta property="og:image" content={technique.gif} />
+                       <meta property="twitter:image" content={technique.gif} />
+               </Helmet> : null}
                <CanonicalLinks
                        base={`/${basepath}/${technique.name}`}
                        lang={getMatchedLocale(technique, i18n.language)}
index 63acef34ff5450493fa0294d1a85b05c04ed30ce..89a48a292af4ac5b1d2e35a5ea57ff6601570e7a 100644 (file)
@@ -9,6 +9,10 @@
 @isset($description)
                <meta name="description" content="{{ $description }}">
 @endisset
+@isset($image)
+               <meta property="og:image" content="{{ $image }}">
+               <meta property="twitter:image" content="{{ $image }}">
+@endisset
 
                <script src="{{ mix('js/manifest.js') }}" defer></script>
                <script src="{{ mix('js/vendor.js') }}" defer></script>