mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-07-21 11:01:17 -04:00
clean up self-hosted emoji code
This commit is contained in:
@@ -1,4 +1,11 @@
|
|||||||
import { parse as parseEmoji } from "imagemoji";
|
import * as imagemoji from "imagemoji";
|
||||||
|
|
||||||
// we're hosting twemojis locally instead of from Twitter's CDN
|
const parseEmoji = (what) =>
|
||||||
parseEmoji(document.body, (icon) => `/assets/emoji/${icon}.svg`);
|
// we're hosting twemojis locally instead of from Twitter's CDN
|
||||||
|
imagemoji.parse(what, (icon) => `/assets/emoji/${icon}.svg`);
|
||||||
|
|
||||||
|
// apply to the entire body automatically on load...
|
||||||
|
parseEmoji(document.body);
|
||||||
|
|
||||||
|
// ...but this can still be reused elsewhere so the URL above doesn't need to be changed in multiple places
|
||||||
|
export default parseEmoji;
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import { h, render, Fragment } from "preact";
|
import { h, render, Fragment } from "preact";
|
||||||
import { useState, useEffect } from "preact/hooks";
|
import { useState, useEffect } from "preact/hooks";
|
||||||
import fetch from "unfetch";
|
import fetch from "unfetch";
|
||||||
import { parse as parseEmoji } from "imagemoji";
|
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import dayjsRelativeTime from "dayjs/plugin/relativeTime.js";
|
import dayjsRelativeTime from "dayjs/plugin/relativeTime.js";
|
||||||
|
import parseEmoji from "./emoji.js";
|
||||||
|
|
||||||
// shared react components:
|
// shared react components:
|
||||||
import { StarIcon, RepoForkedIcon } from "@primer/octicons-react";
|
import { StarIcon, RepoForkedIcon } from "@primer/octicons-react";
|
||||||
@@ -48,7 +48,7 @@ const RepositoryCard = (repo) => (
|
|||||||
<p
|
<p
|
||||||
class="repo-description"
|
class="repo-description"
|
||||||
// eslint-disable-next-line react/no-danger
|
// eslint-disable-next-line react/no-danger
|
||||||
dangerouslySetInnerHTML={{ __html: parseEmoji(repo.description, (icon) => `/assets/emoji/${icon}.svg`) }}
|
dangerouslySetInnerHTML={{ __html: parseEmoji(repo.description) }}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
27
yarn.lock
27
yarn.lock
@@ -2345,9 +2345,9 @@ caniuse-api@^3.0.0:
|
|||||||
lodash.uniq "^4.5.0"
|
lodash.uniq "^4.5.0"
|
||||||
|
|
||||||
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001179, caniuse-lite@^1.0.30001251, caniuse-lite@^1.0.30001272, caniuse-lite@^1.0.30001280:
|
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001179, caniuse-lite@^1.0.30001251, caniuse-lite@^1.0.30001272, caniuse-lite@^1.0.30001280:
|
||||||
version "1.0.30001283"
|
version "1.0.30001284"
|
||||||
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001283.tgz#8573685bdae4d733ef18f78d44ba0ca5fe9e896b"
|
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001284.tgz#d3653929ded898cd0c1f09a56fd8ca6952df4fca"
|
||||||
integrity sha512-9RoKo841j1GQFSJz/nCXOj0sD7tHBtlowjYlrqIUS812x9/emfBLBt6IyMz1zIaYc/eRL8Cs6HPUVi2Hzq4sIg==
|
integrity sha512-t28SKa7g6kiIQi6NHeOcKrOrGMzCRrXvlasPwWC26TH2QNdglgzQIRUuJ0cR3NeQPH+5jpuveeeSFDLm2zbkEw==
|
||||||
|
|
||||||
careful-downloader@^2.0.1:
|
careful-downloader@^2.0.1:
|
||||||
version "2.0.1"
|
version "2.0.1"
|
||||||
@@ -3436,9 +3436,9 @@ ee-first@1.1.1:
|
|||||||
integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=
|
integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=
|
||||||
|
|
||||||
electron-to-chromium@^1.3.896:
|
electron-to-chromium@^1.3.896:
|
||||||
version "1.4.8"
|
version "1.4.10"
|
||||||
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.8.tgz#e1b7752ac1a75e39b5dd90cc7e29ea08b351c484"
|
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.10.tgz#5f44ae6f6725b1949d6e8d34352f80d4c1880734"
|
||||||
integrity sha512-Cu5+dbg55+1E3ohlsa8HT0s4b8D0gBewXEGG8s5wBl8ynWv60VuvYW25GpsOeTVXpulhyU/U8JYZH+yxASSJBQ==
|
integrity sha512-tFgA40Iq2oy4k2PnZrLJowbgpij+lD6ZLxkw8Ht1NKTYyN8dvSvC5xlo8X0WW2jqhKSzITrbr5mpB4/AZ/8OUA==
|
||||||
|
|
||||||
emoji-regex@^8.0.0:
|
emoji-regex@^8.0.0:
|
||||||
version "8.0.0"
|
version "8.0.0"
|
||||||
@@ -8818,12 +8818,12 @@ snapdragon@^0.8.1:
|
|||||||
use "^3.1.0"
|
use "^3.1.0"
|
||||||
|
|
||||||
sockjs@^0.3.21:
|
sockjs@^0.3.21:
|
||||||
version "0.3.21"
|
version "0.3.24"
|
||||||
resolved "https://registry.yarnpkg.com/sockjs/-/sockjs-0.3.21.tgz#b34ffb98e796930b60a0cfa11904d6a339a7d417"
|
resolved "https://registry.yarnpkg.com/sockjs/-/sockjs-0.3.24.tgz#c9bc8995f33a111bea0395ec30aa3206bdb5ccce"
|
||||||
integrity sha512-DhbPFGpxjc6Z3I+uX07Id5ZO2XwYsWOrYjaSeieES78cq+JaJvVe5q/m1uvjIQhXinhIeCFRH6JgXe+mvVMyXw==
|
integrity sha512-GJgLTZ7vYb/JtPSSZ10hsOYIvEYsjbNU+zPdIHcUaWVNUEPivzxku31865sSSud0Da0W4lEeOPlmw93zLQchuQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
faye-websocket "^0.11.3"
|
faye-websocket "^0.11.3"
|
||||||
uuid "^3.4.0"
|
uuid "^8.3.2"
|
||||||
websocket-driver "^0.7.4"
|
websocket-driver "^0.7.4"
|
||||||
|
|
||||||
sort-keys-length@^1.0.0:
|
sort-keys-length@^1.0.0:
|
||||||
@@ -9982,11 +9982,16 @@ utils-merge@1.0.1:
|
|||||||
resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713"
|
resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713"
|
||||||
integrity sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=
|
integrity sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=
|
||||||
|
|
||||||
uuid@^3.0.1, uuid@^3.4.0:
|
uuid@^3.0.1:
|
||||||
version "3.4.0"
|
version "3.4.0"
|
||||||
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee"
|
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee"
|
||||||
integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==
|
integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==
|
||||||
|
|
||||||
|
uuid@^8.3.2:
|
||||||
|
version "8.3.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
|
||||||
|
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==
|
||||||
|
|
||||||
v8-compile-cache@^2.0.3, v8-compile-cache@^2.3.0:
|
v8-compile-cache@^2.0.3, v8-compile-cache@^2.3.0:
|
||||||
version "2.3.0"
|
version "2.3.0"
|
||||||
resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee"
|
resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee"
|
||||||
|
Reference in New Issue
Block a user