Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Astro Support #306

Open
jdgaravito opened this issue Jan 24, 2025 · 1 comment
Open

Astro Support #306

jdgaravito opened this issue Jan 24, 2025 · 1 comment

Comments

@jdgaravito
Copy link

jdgaravito commented Jan 24, 2025

I'm planning to use this on my astro project but the suggested implementation doesnt work, astro wont render any formated date at all.

Still getting the default April 1.

I dont see any way to import it into my server block or client. the tags relative-time are not doing anything.

Can you make it compatible so i can import it into my project like all the npm modules?
something like:

import { relative-time } from Relative-Time-Elements

@jdgaravito
Copy link
Author

jdgaravito commented Jan 24, 2025

this is the only way I made it work, but is because is making a call to github to download it wich is not performance friendly,

---

const { formattedDate } = Astro.props;

interface Props {
    formattedDate: string;
}
---

<relative-time datetime={formattedDate}>
    {formattedDate}
</relative-time>

<script type="module" src="https://unpkg.com/@github/relative-time-element@latest/dist/bundle.js"></script>

tried something like

---
import '@github/relative-time-element';
---

or using as a module

<script type="module">
    import '@github/relative-time-element';
</script>

and i had no luck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant