metonym / svelte-time

Svelte component and action to format a timestamp using day.js
https://metonym.github.io/svelte-time
MIT License
137 stars 8 forks source link

How to use this inside <title> #4

Closed denny64 closed 3 years ago

denny64 commented 3 years ago

I'm trying to use this within the title header but getting an error saying only 'text' and {tags} can be used inside the </p> <p>Any ideas?</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/metonym"><img src="https://avatars.githubusercontent.com/u/10718366?v=4" />metonym</a> commented <strong> 3 years ago</strong> </div> <div class="markdown-body"> <p>You could use the <code>dayjs</code> function re-exported from <code>"svelte-time"</code> to format and display the value in the document title. It wraps the <code>relativeTime</code> plugin.</p> <pre><code class="language-svelte"><script> import { dayjs } from "svelte-time"; $: time = dayjs().format("MMM DD, YYYY"); </script> <svelte:head> <title>{time}</title> </svelte:head></code></pre> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/denny64"><img src="https://avatars.githubusercontent.com/u/9099997?v=4" />denny64</a> commented <strong> 3 years ago</strong> </div> <div class="markdown-body"> <p>Thank you @metonym </p> </div> </div> <div class="page-bar-simple"> </div> <div class="footer"> <ul class="body"> <li>© <script> document.write(new Date().getFullYear()) </script> Githubissues.</li> <li>Githubissues is a development platform for aggregating issues.</li> </ul> </div> <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script> <script src="/githubissues/assets/js.js"></script> <script src="/githubissues/assets/markdown.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/highlight.min.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/languages/go.min.js"></script> <script> hljs.highlightAll(); </script> </body> </html>