Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

drupal-remix

Package Overview
Dependencies
Maintainers
0
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

drupal-remix

Drupal utils for remix.run

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

Drupal-Remix

A list of utilities to help you integrate your Drupal site with Remix.

Prerequisites

Make sure your Drupal site is using the Metatag, and GraphQL Compose modules.

Usage of Metatags helper

Importing library

import { metaTags } from "drupal-remix";

Using the metaTags helper

export const meta: MetaFunction = ({
  data,
}: {
  data: { node: { metatag } };
}) => {
  return metaTags({
    tags: data.node.metatag
  );
};

Overriding values (optional)

You can override specific values in the meta tags by providing a metaTagOverrides object to the metaTags function. This object consists of three keys: MetaTagLink, MetaTagProperty, and MetaTagValue. Each key corresponds to a specific kind of meta tag and you can set the overrides for each key as needed.

return metaTags({
  tags: data.node.metatag,
  metaTagOverrides: {
    MetaTagLink: {
      ...
    },
    MetaTagProperty: {
      ...
    },
    MetaTagValue: {
      ...
    },
  },
});

There is two ways to override the values, one is fully overriding the value with the provided replacement, and the other is searching and replacing a specific pattern within the value.

Override

To fully override the value with a desired value, you can pass the desired value as string to the replacement key. For example, to override the canonical attribute of the <link> tag, use the MetaTagLink key.

export const meta: MetaFunction = ({
  data,
}: {
  data: { node: { metatag } };
}) => {
  return metaTags({
    tags: data.node.metatag,
    metaTagOverrides: {
      MetaTagLink: {
        canonical: "https://your-site-url.com",
      },
    },
  });
};

It will produce the following output in the HTML:

<head>
  <!-- Other meta tags -->
  <link rel="canonical" href="https://your-site-url.com" />
  <!-- Other meta tags -->
</head>

Ignoring the original value of the canonical attribute.

Search and Replace

To search and replace a specific pattern within the value, you can pass an array of objects that contains the pattern and replacement keys. It allows you to add multiple search and replace operations to the same value. For example, replace the domain name in the canonical attribute of the <link> tag.

It is useful when you want to replace the Drupal site URL with the Remix site URL.

export const meta: MetaFunction = ({
  data,
}: {
  data: { node: { metatag } };
}) => {
  return metaTags({
    tags: data.node.metatag,
    metaTagOverrides: {
      MetaTagLink: {
        canonical: [
          {
            pattern: "drupal-site-url.com",
            replacement: "your-site-url.com",
          },
        ],
      },
    },
  });
};

It will produce the following output in the HTML:

<head>
  <!-- Other meta tags -->
  <link rel="canonical" href="https://your-site-url.com" />
  <!-- Other meta tags -->
</head>

and will respect the original path. For example, if the original path was https://drupal-site-url.com/path/to/page, it will be replaced with https://your-site-url.com/path/to/page.

Supporting organizations

Development sponsored by Octahedroid

Keywords

FAQs

Package last updated on 12 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc