]> Untitled Git - lemmy-ui.git/commitdiff
Simplifying html tags code.
authorDessalines <tyhou13@gmx.com>
Wed, 16 Dec 2020 00:34:14 +0000 (18:34 -0600)
committerDessalines <tyhou13@gmx.com>
Wed, 16 Dec 2020 00:34:14 +0000 (18:34 -0600)
src/shared/components/html-tags.tsx

index ff30fb30a97d4c923a414585d4b17405e4858111..fbde148e8442052467c04929f57afa2dcd5623ac 100644 (file)
@@ -17,39 +17,29 @@ export class HtmlTags extends Component<HtmlTagsProps, any> {
 
     return (
       <Helmet title={this.props.title}>
-        {/* Primary Meta Tags */}
-        <meta name="title" content={this.props.title} />
+        {['title', 'og:title', 'twitter:title'].map(t => (
+          <meta property={t} content={this.props.title} />
+        ))}
+        {['og:url', 'twitter:url'].map(u => (
+          <meta property={u} content={url} />
+        ))}
 
         {/* Open Graph / Facebook */}
         <meta property="og:type" content="website" />
-        <meta property="og:url" content={url} />
-        <meta property="og:title" content={this.props.title} />
 
         {/* Twitter */}
         <meta property="twitter:card" content="summary_large_image" />
-        <meta property="twitter:url" content={url} />
-        <meta property="twitter:title" content={this.props.title} />
 
         {/* Optional desc and images */}
-        {this.props.description && [
-          <meta
-            name="description"
-            content={md.renderInline(this.props.description)}
-          />,
-          <meta
-            property="og:description"
-            content={md.renderInline(this.props.description)}
-          />,
-          <meta
-            property="twitter:description"
-            content={md.renderInline(this.props.description)}
-          />,
-        ]}
+        {this.props.description &&
+          ['description', 'og:description', 'twitter:description'].map(n => (
+            <meta name={n} content={md.renderInline(this.props.description)} />
+          ))}
 
-        {this.props.image && [
-          <meta property="og:image" content={this.props.image} />,
-          <meta property="twitter:image" content={this.props.image} />,
-        ]}
+        {this.props.image &&
+          ['og:image', 'twitter:image'].map(p => (
+            <meta property={p} content={this.props.image} />
+          ))}
       </Helmet>
     );
   }