Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

monograph: add more meta tags and social image

Abdullah Atta6618a21a6361
diff --git a/apps/monograph/app/routes/$id.tsx b/apps/monograph/app/routes/$id.tsx
index ec491e8f1..8d8841ce6 100644
--- a/apps/monograph/app/routes/$id.tsx
+++ b/apps/monograph/app/routes/$id.tsx
@@ -27,6 +27,8 @@ import { isSpam, isSpamCached } from "../utils/spam-filter.server";
import { Header } from "../components/header";
import { Footer } from "../components/footer";
import { API_HOST, PUBLIC_URL } from "../utils/env";
+import { generateMetaDescriptors } from "../utils/meta";
+import { format } from "date-fns/format";
type Monograph = {
title: string;
@@ -53,12 +55,16 @@ export const meta: MetaFunction<typeof loader> = ({ data }) => {
date: data?.metadata?.datePublished || ""
}).toString()}`;
- return [
- { title: data?.metadata.title + " - Monograph" },
- { name: "description", content: data?.metadata.shortDescription },
- { name: "robots", content: "noindex" },
- { name: "og:image", content: imageUrl }
- ];
+ return generateMetaDescriptors({
+ titleFull: data?.metadata.title + " - Monograph",
+ titleShort: data?.metadata.title,
+ description: data?.metadata.shortDescription,
+ imageAlt: data?.metadata.fullDescription,
+ imageUrl: imageUrl,
+ url: data?.monograph ? `${PUBLIC_URL}/${data?.monograph.id}` : undefined,
+ publishedAt: data?.metadata.datePublished,
+ type: "article"
+ });
};
export async function loader({ params }: LoaderFunctionArgs) {
@@ -178,12 +184,7 @@ function getMonographMetadata(monograph?: Monograph): Metadata {
const shortDescription = trimDescription(text, 150, true);
const fullDescription = trimDescription(text, 300, true);
const datePublished = monograph
- ? new Date(monograph.datePublished).toLocaleDateString("en", {
- day: "2-digit",
- month: "long",
- year: "numeric",
- weekday: "long"
- })
+ ? format(monograph.datePublished, "YYYY-MM-dd HH:mm")
: "";
return {
title,
diff --git a/apps/monograph/app/routes/_index.tsx b/apps/monograph/app/routes/_index.tsx
index a59ffaaa8..26d8b0628 100644
--- a/apps/monograph/app/routes/_index.tsx
+++ b/apps/monograph/app/routes/_index.tsx
@@ -37,10 +37,15 @@ import { Icon } from "@notesnook/ui";
import { Footer } from "../components/footer";
import { Header } from "../components/header";
import { ForwardRef } from "@theme-ui/components/dist/declarations/src/types";
+import { PUBLIC_URL } from "../utils/env";
export const meta: MetaFunction = () => {
return generateMetaDescriptors({
- title: "Monograph",
+ titleShort: "Monograph",
+ titleFull: "Monograph",
+ type: "website",
+ url: PUBLIC_URL,
+ imageUrl: `${PUBLIC_URL}/social.png`,
description:
"Anonymous, secure and encrypted note sharing with password protection."
});
diff --git a/apps/monograph/app/utils/meta.ts b/apps/monograph/app/utils/meta.ts
index 28b7dac16..90edd94a7 100644
--- a/apps/monograph/app/utils/meta.ts
+++ b/apps/monograph/app/utils/meta.ts
@@ -19,12 +19,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { ServerRuntimeMetaDescriptor } from "@remix-run/server-runtime";
type MetaProps = {
- title: string;
- description: string;
+ titleFull: string;
+ titleShort?: string;
+ description?: string;
url?: string;
imageUrl?: string;
imageAlt?: string;
- author?: string;
+ publishedAt?: string;
+ type: "website" | "article";
};
export function generateMetaDescriptors(
@@ -32,28 +34,36 @@ export function generateMetaDescriptors(
): ServerRuntimeMetaDescriptor[] {
const descriptors: ServerRuntimeMetaDescriptor[] = [];
- descriptors.push({ title: props.title });
+ descriptors.push({ title: props.titleFull });
if (props.description)
descriptors.push({ name: "description", content: props.description });
if (props.imageUrl)
descriptors.push({ name: "og:image", content: props.imageUrl });
- descriptors.push({ name: "og:title", content: props.title });
+ descriptors.push({
+ name: "og:title",
+ content: props.titleShort || props.titleFull
+ });
if (props.imageAlt || props.description)
descriptors.push({
name: "og:image:alt",
content: props.imageAlt || props.description
});
if (props.url) descriptors.push({ name: "og:url", content: props.url });
- descriptors.push({ name: "og:type", content: "website" });
+ descriptors.push({ name: "og:type", content: props.type });
descriptors.push({ name: "og:site_name", content: "Monograph" });
+ if (props.publishedAt)
+ descriptors.push({
+ name: "article:published_time",
+ content: props.publishedAt
+ });
descriptors.push({ name: "author", content: "Monograph" });
descriptors.push({ name: "twitter:card", content: "summary_large_image" });
descriptors.push({ name: "twitter:site", content: "@notesnook" });
descriptors.push({ name: "twitter:creator", content: "@notesnook" });
- descriptors.push({ name: "twitter:title", content: props.title });
+ descriptors.push({ name: "twitter:title", content: props.titleShort });
descriptors.push({ name: "twitter:description", content: props.description });
if (props.imageUrl)
descriptors.push({ name: "twitter:image", content: props.imageUrl });
diff --git a/apps/monograph/package-lock.json b/apps/monograph/package-lock.json
index c08bbb3dc..f4f4c5b14 100644
--- a/apps/monograph/package-lock.json
+++ b/apps/monograph/package-lock.json
@@ -24,6 +24,7 @@
"@theme-ui/core": "^0.16.2",
"buffer": "^6.0.3",
"comlink": "^4.4.1",
+ "date-fns": "^4.1.0",
"html-to-text": "^9.0.5",
"isbot": "^5.1.17",
"mac-scrollbar": "^0.13.6",
@@ -4011,6 +4012,16 @@
"node": ">= 6"
}
},
+ "node_modules/date-fns": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-4.1.0.tgz",
+ "integrity": "sha512-Ukq0owbQXxa/U3EGtsdVBkR1w7KOQ5gIBqdH2hkvknzZPYvBxb/aa6E8L7tmjFtkwZBu3UXBbjIgPo/Ez4xaNg==",
+ "license": "MIT",
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/kossnocorp"
+ }
+ },
"node_modules/debug": {
"version": "4.3.7",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz",
diff --git a/apps/monograph/package.json b/apps/monograph/package.json
index 6af61d2bb..96ffb3dd5 100644
--- a/apps/monograph/package.json
+++ b/apps/monograph/package.json
@@ -27,6 +27,7 @@
"@theme-ui/core": "^0.16.2",
"buffer": "^6.0.3",
"comlink": "^4.4.1",
+ "date-fns": "^4.1.0",
"html-to-text": "^9.0.5",
"isbot": "^5.1.17",
"mac-scrollbar": "^0.13.6",
diff --git a/apps/monograph/public/social.png b/apps/monograph/public/social.png
new file mode 100644
index 000000000..c558217e0
Binary files /dev/null and b/apps/monograph/public/social.png differ