Schedule posts to Bluesky with Cloudflare workers. skyscheduler.work
cf tool bsky-tool cloudflare bluesky schedule bsky service social-media cloudflare-workers
at main 60 lines 1.7 kB view raw
1import { Context } from 'hono'; 2import { html } from 'hono/html'; 3import { Child } from 'hono/jsx'; 4import { HtmlEscapedString } from 'hono/utils/html'; 5 6type FooterLink = { 7 title: string; 8 url: string; 9}; 10 11type AccountFormProps = { 12 ctx?: Context; 13 children: Child; 14 title: string; 15 submitText?: string; 16 loadingText: string; 17 endpoint: string; 18 successText: string; 19 redirect: string; 20 disabledByDefault?: boolean; 21 customRedirectDelay?: number; 22 footerLinks?: FooterLink[] 23 footerHTML?: string | Promise<HtmlEscapedString> 24}; 25 26export default function AccountHandler(props: AccountFormProps) { 27 const footerLinkHTML = props.footerLinks?.map((el: FooterLink) => { 28 return (<span><a class="contrast outline" href={el.url}>{el.title}</a></span>); 29 }); 30 return (<section class="container"> 31 <article> 32 <header> 33 <center><h3>{props.title}</h3></center> 34 </header> 35 <form id="loginForm"> 36 {props.children} 37 <center> 38 <button type="submit" disabled={props.disabledByDefault || false}> 39 {props.submitText || props.title} 40 </button> 41 </center> 42 </form> 43 <center> 44 <span aria-busy="true" id="loading" hidden>{props.loadingText}</span> 45 </center> 46 <footer> 47 <center> 48 <span id="footerLinks"> 49 {props.footerLinks ? <small>{footerLinkHTML}</small> : (props.footerHTML || "")} 50 </span> 51 </center> 52 </footer> 53 </article> 54 <script type="text/javascript"> 55 {html` 56 easySetup("${props.endpoint}", "${props.successText}", "${props.redirect}", ${props.customRedirectDelay || 0}); 57 `} 58 </script> 59 </section>); 60}