Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

improved landing hero + accounted for edge case

Steven Tey7e2930d1448b
diff --git a/package.json b/package.json
index bfcd3898c7..7f7db3c241 100644
--- a/package.json
+++ b/package.json
@@ -68,6 +68,7 @@
"devDependencies": {
"@tailwindcss/line-clamp": "^0.4.2",
"@trivago/prettier-plugin-sort-imports": "^3.3.0",
+ "@types/html-escaper": "^3.0.0",
"@types/ms": "^0.7.31",
"@types/node": "17.0.35",
"@types/react": "18.0.9",
diff --git a/pages/api/edge/metatags.ts b/pages/api/edge/metatags.ts
index 41fd4f841a..5756c1febf 100644
--- a/pages/api/edge/metatags.ts
+++ b/pages/api/edge/metatags.ts
@@ -41,7 +41,7 @@ const getMetadataFromUrl = async (url: string, ev: NextFetchEvent) => {
/<meta\s+(?:name|property|itemprop|http-equiv)="([^"]+)"\s+content="([^"]+)"/g,
// @ts-ignore
(_, key, value) => {
- obj[key] = unescape(value);
+ obj[key] = unescape(value).replaceAll("&#x27;", "'");
},
);
// get all meta tags (reversed order for content & name/property)
@@ -49,7 +49,7 @@ const getMetadataFromUrl = async (url: string, ev: NextFetchEvent) => {
/<meta\s+content="([^"]+)"\s+(?:name|property|itemprop|http-equiv)="([^"]+)"/g,
// @ts-ignore
(_, value, key) => {
- obj[key] = unescape(value);
+ obj[key] = unescape(value).replaceAll("&#x27;", "'");
},
);
// get all title tags
@@ -57,7 +57,7 @@ const getMetadataFromUrl = async (url: string, ev: NextFetchEvent) => {
/<title>([^<]+)<\/title>/g,
// @ts-ignore
(_, value) => {
- obj["title"] = unescape(value);
+ obj["title"] = unescape(value).replaceAll("&#x27;", "'");
},
);
// get all link tags
@@ -65,7 +65,7 @@ const getMetadataFromUrl = async (url: string, ev: NextFetchEvent) => {
/<link\s+(?:rel|itemprop)="([^"]+)"\s+href="([^"]+)"/g,
// @ts-ignore
(_, key, value) => {
- obj[key] = unescape(value);
+ obj[key] = unescape(value).replaceAll("&#x27;", "'");
},
);
diff --git a/pages/metatags.tsx b/pages/metatags.tsx
index 4cae15fe77..72125ec284 100644
--- a/pages/metatags.tsx
+++ b/pages/metatags.tsx
@@ -1,5 +1,5 @@
import HomeLayout from "@/components/layout/home";
-import { Twitter } from "@/components/shared/icons";
+import { Github, Twitter } from "@/components/shared/icons";
import getTweetsMetadata from "@/lib/twitter";
import Tweet from "@/components/shared/tweet";
import { useState } from "react";
@@ -38,27 +38,19 @@ export default function Metatags({ tweets }: { tweets: any }) {
API
</h1>
<h2 className="mt-5 text-lg text-gray-600 sm:text-xl">
- A dead-simple API to retrieve the meta tags for a URL, using{" "}
- <a
- href="https://vercel.com/edge"
- target="_blank"
- rel="noreferrer"
- className="underline decoration-dotted hover:text-black"
- >
- Vercel Edge Functions ↗
- </a>
- .
+ A dead-simple API to retrieve the meta tags for a URL. Completely free
+ and open-source.
</h2>
- <div className="mx-auto mt-5 mb-10 flex justify-center space-x-4 lg:-mb-5">
+ <div className="mt-5 mb-10 lg:-mb-5">
<form
- className="relative mt-1 flex rounded-md shadow-sm"
+ className="relative mt-1 flex w-full rounded-md shadow-sm"
onSubmit={(e) => {
e.preventDefault();
window.open(`https://api.dub.sh/metatags?url=${url}`);
}}
>
- <span className="inline-flex items-center whitespace-nowrap rounded-l-md border border-r-0 border-gray-300 bg-gray-50 px-5 text-sm text-gray-500">
+ <span className="inline-flex items-center whitespace-nowrap rounded-l-md border border-r-0 border-gray-300 bg-gray-50 px-3 text-sm text-gray-500">
api.dub.sh/metatags?url=
</span>
<input
@@ -66,16 +58,25 @@ export default function Metatags({ tweets }: { tweets: any }) {
id="url"
type="url"
required
- className="w-66 block rounded-r-md border-gray-300 pr-12 text-sm text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:outline-none focus:ring-gray-500 sm:w-72"
+ className="w-66 block w-full rounded-r-md border-gray-300 pr-12 text-sm text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:outline-none focus:ring-gray-500"
placeholder="https://vercel.com"
value={url}
onChange={(e) => setUrl(e.target.value)}
aria-invalid="true"
/>
- <button className="group absolute inset-y-0 right-0 my-1.5 mr-1.5 w-8 rounded border border-gray-200 font-sans text-sm font-medium text-gray-400 hover:border-gray-700 hover:text-gray-700 peer-focus:border-gray-700 peer-focus:text-gray-700">
+ <button className="group absolute inset-y-0 right-2 my-1.5 w-8 rounded border border-gray-200 font-sans text-sm font-medium text-gray-400 hover:border-gray-700 hover:text-gray-700 peer-focus:border-gray-700 peer-focus:text-gray-700">
<p>↵</p>
</button>
</form>
+ <a
+ href="https://dub.sh/metatags-code"
+ target="_blank"
+ rel="noreferrer"
+ className="mx-auto mt-2 flex items-center justify-center space-x-2 text-sm text-gray-500 transition-all hover:text-black"
+ >
+ <Github className="h-4 w-4" />
+ <p>View the source code</p>
+ </a>
</div>
<div className="text-left">
diff --git a/yarn.lock b/yarn.lock
index ccd9f4dd03..87ed01acc3 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1449,6 +1449,11 @@
resolved "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.10.tgz"
integrity sha512-Nmh0K3iWQJzniTuPRcJn5hxXkfB1T1pgB89SBig5PlJQU5yocazeu4jATJlaA0GYFKWMqDdvYemoSnF2pXgLVA==
+"@types/html-escaper@^3.0.0":
+ version "3.0.0"
+ resolved "https://registry.yarnpkg.com/@types/html-escaper/-/html-escaper-3.0.0.tgz#97d7df443c0fc86e3abdd0971f4814a58e3ca762"
+ integrity sha512-OcJcvP3Yk8mjYwf/IdXZtTE1tb/u0WF0qa29ER07ZHCYUBZXSN29Z1mBS+/96+kNMGTFUAbSz9X+pHmHpZrTCw==
+
"@types/html-minifier-terser@^6.1.0":
version "6.1.0"
resolved "https://registry.yarnpkg.com/@types/html-minifier-terser/-/html-minifier-terser-6.1.0.tgz#4fc33a00c1d0c16987b1a20cf92d20614c55ac35"