Skip to main content

Overview

@acromedia/gesso-cms

Gesso CMS Integration Provider

Provides functionality for interacting with content management services.

note

Requires plugin to integrate with a CMS system. IE "Drupal" integrations require use of @acromedia/gesso-drupal

Overview

The CMS provider exposes the following hooks/methods for developers to use to query data from their configured CMS.

CMS

cms(plugins: Plugins, config = {}): Used to register plugins with a provider. config allows for customization of how your provider should function. see plugins/cms/drupal for example usage of cms()

useContent

useContent(id: string, path?: string, options?: {}): Used for querying a specific content entity.

  • id: the id of the content you wish to grab
  • path: the path alias of the content you wish to grab. when using path you can pass '' as the id

useContentSearch

useContentSearch(keyword: string, properties?: SearchProperties, tags?: string[], limit = 50, offset: number)

  • keyword (string): The search keyword or term used to filter the content.
  • properties (optional): An object specifying additional search properties to refine the search results. This object contains key-value pairs where the keys represent property names, and the values represent the desired property values. An example from Drupal ContentSearch might look like this:
// Define the properties for fetching and sorting articles
const articleFilterProperties = {
filters: [
{
field: "type",
value: "article",
operator: "EQUAL",
},
],
sort: {
field: "created",
direction: DESC,
},
};
  • tags (optional): An array of strings specifying the tags associated with the content. Only content items matching any of the provided tags will be included in the search results.
  • limit (optional): An integer representing the maximum number of search results to be returned. The default value is set to 50 if not specified.
  • offset (number | optional): Specifies the number of content items to skip before starting to collect the result set. In Drupal ContentSearch, if this argument is provided it will be applied as a variable into the GraphQL query and can be used for pagination. This may not be available in all plugins and can be left undefined or not provided at all in those scenarios.

useMenu

useMenu(id: string, options?: Options): Used to query menu data.

  • id (string): The unique identifier of the menu to retrieve. This identifier is used by the plugin function to fetch the corresponding menu data.
  • options (optional): An object specifying additional options or parameters for the menu retrieval. The content and structure of the options object depend on the implementation of the plugin function.

useTags

useTags(): Used to query content by tags.

  • id (string): The unique identifier of the tag to retrieve. This identifier is used by the plugin function to fetch the corresponding tag data.
  • options (optional): An object specifying additional options or parameters for tag retrieval. The content and structure of the options object depend on the implementation of the plugin function.

useUser

useUser(): used for managing user-related functionality within a React application. This hook returns the current logged in user, as well as a few methods for handling authentication.

  • add(email: string, username: string, password?: string): used for creating new users in the CMS.
  • login(username: string, password: string): used for logging a user into the CMS.
  • logout(): used for logging a user out of the CMS.

getRedirects

getRedirects(path?: string, options?: Options): used for retrieving redirects within a React application. It does not follow the typical hook pattern and is not intended to be used within a component directly. rather you would use this method alongside a static build or serverside method.

  • path (optional): The path for which redirects are requested. If provided, the function retrieves the redirects specifically related to the given path. If not provided, it returns all redirects.
  • options (optional): An object specifying additional options or parameters for the redirects retrieval. The content and structure of the options object depend on the implementation of the plugin function.

getRoutes

getRoutes(path?: string, options?: Options): Used for retrieving routes within a react application. It does not follow the typical hook pattern and is not intended to be used within a component directly. rather you would use this method alongside a static build or serverside method.

  • path (optional): The path for which routes are requested. If provided, the function retrieves the routes that match or include the given path. If not provided, it returns all routes.
  • options (optional): An object specifying additional options or parameters for the routes retrieval. The content and structure of the options object depend on the implementation of the plugin function.

Installation

pnpm install @acromedia/gesso-cms

Configuration

See CMS Plugin Drupal : Registering Hooks