Directus Hook Library

screenshot of Directus Hook Library
directus

A collection of customizable hooks for Directus

Overview

The Directus Hook Library is a collection of customizable hooks for Directus. It is not an extension, but rather a library of scripts that can be used inside a Directus hook extension. This library allows for additional functionality and customization within Directus.

Features

  • deleteUnusedM2OItems: Deletes related M2O items that lose their relation and should not be kept. This is not possible through Directus itself.
  • deleteUnusedM2AItems: Deletes related M2A items that lose their relation and should not be kept. This is also not possible through Directus.
  • toAnyCollectionM2A: Maps array elements to objects of type AnyCollection with a default key field of "id".
  • toJunctionCollectionM2A: Maps array elements to objects of type JunctionCollection with a default foreignKey field of "item" and a default foreignCollection field of "collection".
  • preventDeletingM2AItems: Prevents deletion of M2A items, which is not possible through Directus itself.
  • replaceDeletedUserReferences: Replaces the reference to a deleted user with a reference to the current user in the directus_files collection.
  • resetFieldsHiddenByOptionSet: Sets fields hidden by a condition to null if they have a value.
  • setProjectSettingsFromEnvVars: Sets project settings from environment variables like PROJECT_URL.

Summary

The Directus Hook Library is a collection of customizable hooks for Directus that provide additional functionality and customization options. It includes features such as deleting unused M2O and M2A items, mapping array elements to specific types, preventing deletion of M2A items, replacing deleted user references, resetting hidden fields, and setting project settings from environment variables. By following the installation guide, users can easily integrate this library into their Directus hook extensions.

directus
Directus

A website that uses Directus as an open source headless CMS to manage content. This includes features such as a customizable content model, role-based access control, and API-based content delivery to support a wide range of digital experiences.

Recoil

Recoil is a state management library for React that provides an intuitive and flexible API for managing and sharing state across components. It supports a range of features, including derived state, asynchronous updates, and time-travel debugging, and is designed to work well with the React ecosystem and other state management solutions.

typescript
Typescript

TypeScript is a superset of JavaScript, providing optional static typing, classes, interfaces, and other features that help developers write more maintainable and scalable code. TypeScript's static typing system can catch errors at compile-time, making it easier to build and maintain large applications.