Snippets
A collection of code snippets – including serverless functions, Node.js scripts, and CSS tricks.
Print Object
Generate Slugs with Flows
Use Directus Flows to generate slugs
useInterval
Buttondown
Subscribe to a newsletter.
API CRUD Route
Debounce
useHasMounted
useStickyState
Tiny ID
Gumroad
Buttondown
Get all subscribers.
useLocalStorage
Delve
Safely get a dot-notated path within a nested object, with ability to return a default if the full key path does not exist or the value is undefined
Stringify query parameters
Loading Progress
useAxios
Axios calls can get repetitive so a hook to handle it can be handy.
Slack
Send a slack webhook
Hasura
Simple fetch call for Hasura
useOnClickOutside
This hook allows you to detect clicks outside of a specified element.
Range
Sometimes, you want to render a sequence of numbers.
jsonHash
The jsonHash function lets you define those functions directly in the json, reducing the need to create extra functions and variables.
Download a Directus Example
This is a simple bash script that when passed an example, will download just that example from the Directus examples repo, handy to get started quickly with an example and build something.
Remix
Subscribe to a newsletter
Optimize SQLite
SQLite is a handy database and can be a lot more powerful that it seems but it also can use some optimization to help it get there.
Animated Links
Quick little Astro component that uses Tailwind to animate links on hover.
Lazy Loading with CSS
Use the content-visibility property in CSS indicates to the browser whether or not an element’s contents should be rendered at initial load time, acting as a lazy load.