1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2026-06-29 20:06:00 -04:00

clean up self-hosted emoji code

This commit is contained in:
2021-12-03 10:03:19 -05:00
parent cf9a8f742a
commit fd1393b223
3 changed files with 28 additions and 16 deletions
+10 -3
View File
@@ -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
parseEmoji(document.body, (icon) => `/assets/emoji/${icon}.svg`);
const parseEmoji = (what) =>
// 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;
+2 -2
View File
@@ -1,9 +1,9 @@
import { h, render, Fragment } from "preact";
import { useState, useEffect } from "preact/hooks";
import fetch from "unfetch";
import { parse as parseEmoji } from "imagemoji";
import dayjs from "dayjs";
import dayjsRelativeTime from "dayjs/plugin/relativeTime.js";
import parseEmoji from "./emoji.js";
// shared react components:
import { StarIcon, RepoForkedIcon } from "@primer/octicons-react";
@@ -48,7 +48,7 @@ const RepositoryCard = (repo) => (
<p
class="repo-description"
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{ __html: parseEmoji(repo.description, (icon) => `/assets/emoji/${icon}.svg`) }}
dangerouslySetInnerHTML={{ __html: parseEmoji(repo.description) }}
/>
)}