From 0d8025e8ea916951a7651df8afdf0e4c425e342f Mon Sep 17 00:00:00 2001 From: Rachelle Hu Date: Mon, 7 Feb 2022 11:34:00 -0500 Subject: [PATCH 1/3] Emoji in code block, fix issue #329 --- functions/src/content.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/functions/src/content.ts b/functions/src/content.ts index 8f68446c4..050f66722 100644 --- a/functions/src/content.ts +++ b/functions/src/content.ts @@ -70,7 +70,13 @@ function replaceEmojis(md: string, emojis: Record): string { for (const k of Object.keys(emojis)) { const withColons = `:${k}:`; const asEmoji = emojis[k]; - content = content.replace(new RegExp(withColons, "g"), asEmoji); + const contentList = content.split("```"); + contentList.forEach((val, ind) => { + if (ind % 2 === 0) { + contentList[ind] = val.replace(new RegExp(withColons, "g"), asEmoji); + } + }); + content = contentList.join("```"); } return content; From 174c2640741e93c9b3e61b62adba445bff944294 Mon Sep 17 00:00:00 2001 From: Rachelle Hu Date: Mon, 7 Feb 2022 17:26:17 -0500 Subject: [PATCH 2/3] Update dates.ts --- app/src/plugins/dates.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/plugins/dates.ts b/app/src/plugins/dates.ts index 539a53e1a..739036161 100644 --- a/app/src/plugins/dates.ts +++ b/app/src/plugins/dates.ts @@ -18,15 +18,20 @@ const DAY_MS = 24 * 60 * 60 * 1000; export function renderDaysAgo(lastUpdated: number) { - const now = new Date().getTime(); + const now = new Date(); - const diff = now - lastUpdated; + const diff = now.getTime() - lastUpdated; const daysAgo = Math.floor(diff / DAY_MS); if (daysAgo <= 0) { return "today"; } else if (daysAgo === 1) { return "yesterday"; + } else if (daysAgo > 30) { + const lastUpdatedDate = new Date(lastUpdated); + let monthsAgo = (now.getFullYear() - lastUpdatedDate.getFullYear()) * 12; + monthsAgo = monthsAgo + now.getMonth() - lastUpdatedDate.getMonth(); + return `${monthsAgo} months ago`; } else { return `${daysAgo} days ago`; } From 7e95474696a7d7b95d230a2df6812915e495d9c1 Mon Sep 17 00:00:00 2001 From: Rachelle Hu Date: Tue, 8 Feb 2022 09:13:15 -0500 Subject: [PATCH 3/3] removed emoji change --- functions/src/content.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/functions/src/content.ts b/functions/src/content.ts index 050f66722..8f68446c4 100644 --- a/functions/src/content.ts +++ b/functions/src/content.ts @@ -70,13 +70,7 @@ function replaceEmojis(md: string, emojis: Record): string { for (const k of Object.keys(emojis)) { const withColons = `:${k}:`; const asEmoji = emojis[k]; - const contentList = content.split("```"); - contentList.forEach((val, ind) => { - if (ind % 2 === 0) { - contentList[ind] = val.replace(new RegExp(withColons, "g"), asEmoji); - } - }); - content = contentList.join("```"); + content = content.replace(new RegExp(withColons, "g"), asEmoji); } return content;