A set of utilities and helpers to work with DatoCMS in a Next.js project.
npm install @smartive/datocms-utils
Import and use the utilities you need in your project. The following utilities are available.
The following utilities are used to work with DatoCMS cache tags and a Vercel Postgres database.
-
storeQueryCacheTags
: Stores the cache tags of a query in the database. -
queriesReferencingCacheTags
: Retrieves the queries that reference cache tags. -
deleteQueries
: Deletes the cache tags of a query from the database.
In order for the above utilites to work, you need to setup a the following database. You can use the following SQL script to do that:
CREATE TABLE IF NOT EXISTS query_cache_tags (
query_id TEXT NOT NULL,
cache_tag TEXT NOT NULL,
PRIMARY KEY (query_id, cache_tag)
);
-
classNames
: Cleans and joins an array of inputs with possible undefined or boolean values. Useful for tailwind classnames. -
getTelLink
: Formats a phone number to a tel link.
-
CacheTag
: A branded type for cache tags. -
CacheTagsInvalidateWebhook
: The payload of the DatoCMS cache tags invalidate webhook.