X-Git-Url: http://these/git/?a=blobdiff_plain;f=src%2Fshared%2Fcomponents%2Fcommon%2Fhtml-tags.tsx;h=80649fa119e85cfa8e0214065aeeaad2edf45a47;hb=53c3cfeade90150b07431386745a24aa699a25ec;hp=1997b4f8cee16e62e191f15558d0444c262d4761;hpb=cc90ded31ed5d7d1b61474872481824113f0933b;p=lemmy-ui.git diff --git a/src/shared/components/common/html-tags.tsx b/src/shared/components/common/html-tags.tsx index 1997b4f..80649fa 100644 --- a/src/shared/components/common/html-tags.tsx +++ b/src/shared/components/common/html-tags.tsx @@ -1,30 +1,40 @@ -import { Option } from "@sniptt/monads"; +import { httpExternalPath } from "@utils/env"; +import { htmlToText } from "html-to-text"; import { Component } from "inferno"; import { Helmet } from "inferno-helmet"; -import { httpExternalPath } from "../../env"; -import { md } from "../../utils"; +import { md } from "../../markdown"; +import { I18NextService } from "../../services"; interface HtmlTagsProps { title: string; path: string; - description: Option; - image: Option; + canonicalPath?: string; + description?: string; + image?: string; } /// Taken from https://metatags.io/ export class HtmlTags extends Component { render() { - let url = httpExternalPath(this.props.path); + const url = httpExternalPath(this.props.path); + const canonicalUrl = + this.props.canonicalPath ?? httpExternalPath(this.props.path); + const desc = this.props.description; + const image = this.props.image; return ( + + {["title", "og:title", "twitter:title"].map(t => ( - + ))} {["og:url", "twitter:url"].map(u => ( - + ))} + + {/* Open Graph / Facebook */} @@ -32,18 +42,19 @@ export class HtmlTags extends Component { {/* Optional desc and images */} - {this.props.description.isSome() && - ["description", "og:description", "twitter:description"].map(n => ( - - ))} - - {this.props.image.isSome() && - ["og:image", "twitter:image"].map(p => ( - - ))} + {["description", "og:description", "twitter:description"].map( + n => + desc && ( + + ) + )} + {["og:image", "twitter:image"].map( + p => image && + )} ); }