Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/smartive/datocms-utils
A set of utilities and helpers to work with DatoCMS in a Next.js project.
https://github.com/smartive/datocms-utils
Last synced: about 5 hours ago
JSON representation
A set of utilities and helpers to work with DatoCMS in a Next.js project.
- Host: GitHub
- URL: https://github.com/smartive/datocms-utils
- Owner: smartive
- License: mit
- Created: 2024-09-25T11:57:50.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2024-10-23T23:03:22.000Z (14 days ago)
- Last Synced: 2024-10-24T12:23:32.837Z (13 days ago)
- Language: TypeScript
- Size: 263 KB
- Stars: 1
- Watchers: 5
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# smartive DatoCMS Utilities
A set of utilities and helpers to work with DatoCMS in a Next.js project.
## Installation
```bash
npm install @smartive/datocms-utils
```## Usage
Import and use the utilities you need in your project. The following utilities are available.
## Utilities
### Utilities for DatoCMS Cache Tags
The following utilities are used to work with [DatoCMS cache tags](https://www.datocms.com/docs/content-delivery-api/cache-tags) and a [Vercel Postgres database](https://vercel.com/docs/storage/vercel-postgres).
- `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.#### Setup Postgres 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:
```sql
CREATE TABLE IF NOT EXISTS query_cache_tags (
query_id TEXT NOT NULL,
cache_tag TEXT NOT NULL,
PRIMARY KEY (query_id, cache_tag)
);
```### Other Utilities
- `classNames`: Cleans and joins an array of inputs with possible undefined or boolean values. Useful for tailwind classnames.
### Types
- `CacheTag`: A branded type for cache tags.
- `CacheTagsInvalidateWebhook`: The payload of the DatoCMS cache tags invalidate webhook.