Compare commits
2 Commits
95dd7e51e5
...
20656e74e8
Author | SHA1 | Date |
---|---|---|
Oliver Booth | 20656e74e8 | |
Oliver Booth | 2036970fa2 |
|
@ -60,7 +60,6 @@
|
||||||
|
|
||||||
<p>@Html.Raw(BlogService.GetExcerpt(post, out bool trimmed))</p>
|
<p>@Html.Raw(BlogService.GetExcerpt(post, out bool trimmed))</p>
|
||||||
|
|
||||||
<article>
|
|
||||||
@if (trimmed)
|
@if (trimmed)
|
||||||
{
|
{
|
||||||
<p>
|
<p>
|
||||||
|
@ -73,7 +72,6 @@
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
}
|
}
|
||||||
</article>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -97,41 +97,6 @@ declare const katex: any;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const formatRelativeTime = function (timestamp) {
|
|
||||||
const now = new Date();
|
|
||||||
// @ts-ignore
|
|
||||||
const diff = now - timestamp;
|
|
||||||
const suffix = diff < 0 ? 'from now' : 'ago';
|
|
||||||
|
|
||||||
const seconds = Math.floor(diff / 1000);
|
|
||||||
if (seconds < 60) {
|
|
||||||
return `${seconds} second${seconds !== 1 ? 's' : ''} ${suffix}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
const minutes = Math.floor(diff / 60000);
|
|
||||||
if (minutes < 60) {
|
|
||||||
return `${minutes} minute${minutes !== 1 ? 's' : ''} ${suffix}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
const hours = Math.floor(diff / 3600000);
|
|
||||||
if (hours < 24) {
|
|
||||||
return `${hours} hour${hours !== 1 ? 's' : ''} ${suffix}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
const days = Math.floor(diff / 86400000);
|
|
||||||
if (days < 30) {
|
|
||||||
return `${days} day${days !== 1 ? 's' : ''} ${suffix}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
const months = Math.floor(diff / 2592000000);
|
|
||||||
if (months < 12) {
|
|
||||||
return `${months} month${months !== 1 ? 's' : ''} ${suffix}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
const years = Math.floor(diff / 31536000000);
|
|
||||||
return `${years} year${years !== 1 ? 's' : ''} ${suffix}`;
|
|
||||||
};
|
|
||||||
|
|
||||||
document.querySelectorAll("pre code").forEach((block) => {
|
document.querySelectorAll("pre code").forEach((block) => {
|
||||||
let content = block.textContent;
|
let content = block.textContent;
|
||||||
if (content.trim().split("\n").length > 1) {
|
if (content.trim().split("\n").length > 1) {
|
||||||
|
@ -195,7 +160,7 @@ declare const katex: any;
|
||||||
|
|
||||||
case "R":
|
case "R":
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
timestamp.textContent = formatRelativeTime(date);
|
timestamp.textContent = TimeUtility.formatRelativeTimestamp(date);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue