~repos /website

#astro#js#html#css

git clone https://pyrossh.dev/repos/website.git
Discussions: https://groups.google.com/g/rust-embed-devs

木 Personal website of pyrossh. Built with astrojs, shiki, vite.



src/components/TimeAgo.astro



---
import { format } from "timeago.js";
type Props = {
date: string;
};
const { date } = Astro.props;
---
<time-ago data-date={date}>
{format(date)}
</time-ago>
<script>
import { format } from "timeago.js";
class TimeAgo extends HTMLElement {
connectedCallback() {
const date = this.dataset.date || new Date();
this.textContent = format(date);
}
}
customElements.define("time-ago", TimeAgo);
</script>
<style>
time-ago {
display: inline;
}
</style>