From d379344e6aa3b6b6e629a6f7174fe48d5f7ba3e1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 27 Nov 2025 10:46:49 +0100 Subject: [PATCH 1/2] chore(deps): bump node-forge from 1.3.1 to 1.3.2 (#11574) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 8458344ef517..e71ea0438253 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13531,9 +13531,9 @@ node-fetch@2.7.0, node-fetch@^2.6.7: whatwg-url "^5.0.0" node-forge@^1: - version "1.3.1" - resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-1.3.1.tgz#be8da2af243b2417d5f646a770663a92b7e9ded3" - integrity sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA== + version "1.3.2" + resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-1.3.2.tgz#d0d2659a26eef778bf84d73e7f55c08144ee7750" + integrity sha512-6xKiQ+cph9KImrRh0VsjH2d8/GXA4FIMlgU4B757iI1ApvcyA9VlouP0yZJha01V+huImO+kKMU7ih+2+E14fw== node-gyp-build@^4.3.0: version "4.6.0" From c6a86ff717199354e8511395adaea446c9fa8beb Mon Sep 17 00:00:00 2001 From: Balthasar Hofer Date: Thu, 27 Nov 2025 11:19:53 +0100 Subject: [PATCH 2/2] feat(core): support custom html elements in head tags (#11571) Co-authored-by: sebastien --- packages/docusaurus-types/src/plugin.d.ts | 2 ++ .../src/server/__tests__/configValidation.test.ts | 13 +++++++++++++ .../src/server/__tests__/htmlTags.test.ts | 2 +- packages/docusaurus/src/server/configValidation.ts | 11 ++++++++--- packages/docusaurus/src/server/htmlTags.ts | 13 +++++++++---- website/docs/api/docusaurus.config.js.mdx | 4 ++-- 6 files changed, 35 insertions(+), 10 deletions(-) diff --git a/packages/docusaurus-types/src/plugin.d.ts b/packages/docusaurus-types/src/plugin.d.ts index 7d8a91e8a620..25458e9fd8c1 100644 --- a/packages/docusaurus-types/src/plugin.d.ts +++ b/packages/docusaurus-types/src/plugin.d.ts @@ -104,6 +104,8 @@ export type HtmlTagObject = { tagName: string; /** The inner HTML */ innerHTML?: string; + /** Allow custom html elements, e.g. `` */ + customElement?: boolean; }; export type HtmlTags = string | HtmlTagObject | (string | HtmlTagObject)[]; diff --git a/packages/docusaurus/src/server/__tests__/configValidation.test.ts b/packages/docusaurus/src/server/__tests__/configValidation.test.ts index 98aea0370a30..379ce8af2898 100644 --- a/packages/docusaurus/src/server/__tests__/configValidation.test.ts +++ b/packages/docusaurus/src/server/__tests__/configValidation.test.ts @@ -315,6 +315,19 @@ describe('headTags', () => { `); }); + it('accepts headTags with a custom element without attributes', () => { + expect(() => + normalizeConfig({ + headTags: [ + { + tagName: 'my-custom-element', + customElement: true, + }, + ], + }), + ).not.toThrow(); + }); + it("throws error if headTags doesn't have string attributes", () => { expect(() => { normalizeConfig({ diff --git a/packages/docusaurus/src/server/__tests__/htmlTags.test.ts b/packages/docusaurus/src/server/__tests__/htmlTags.test.ts index 717e5ca79e03..e46e60d59523 100644 --- a/packages/docusaurus/src/server/__tests__/htmlTags.test.ts +++ b/packages/docusaurus/src/server/__tests__/htmlTags.test.ts @@ -189,7 +189,7 @@ describe('loadHtmlTags', () => { }, ]), ).toThrowErrorMatchingInlineSnapshot( - `"Error loading {"tagName":"endiliey","attributes":{"this":"is invalid"}}, "endiliey" is not a valid HTML tag."`, + `"Error loading {"tagName":"endiliey","attributes":{"this":"is invalid"}}, "endiliey" is not a valid HTML tag. Either use a valid "tagName" or set "customElement: true"."`, ); }); diff --git a/packages/docusaurus/src/server/configValidation.ts b/packages/docusaurus/src/server/configValidation.ts index f826788adf6e..e57a7ba45abe 100644 --- a/packages/docusaurus/src/server/configValidation.ts +++ b/packages/docusaurus/src/server/configValidation.ts @@ -437,9 +437,14 @@ export const ConfigSchema = Joi.object({ .items( Joi.object({ tagName: Joi.string().required(), - attributes: Joi.object() - .pattern(/[\w-]+/, Joi.string()) - .required(), + attributes: Joi.object().when('customElement', { + is: Joi.valid(true), + then: Joi.optional(), + otherwise: Joi.object() + .pattern(/[\w-]+/, Joi.string()) + .required(), + }), + customElement: Joi.bool().default(false), }).unknown(), ) .messages({ diff --git a/packages/docusaurus/src/server/htmlTags.ts b/packages/docusaurus/src/server/htmlTags.ts index 46bd39ab75cc..52cbee825847 100644 --- a/packages/docusaurus/src/server/htmlTags.ts +++ b/packages/docusaurus/src/server/htmlTags.ts @@ -17,22 +17,27 @@ import type { RouterType, } from '@docusaurus/types'; +// TODO this should be done at config validation time, not here function assertIsHtmlTagObject(val: unknown): asserts val is HtmlTagObject { if (typeof val !== 'object' || !val) { throw new Error(`"${val}" is not a valid HTML tag object.`); } - if (typeof (val as HtmlTagObject).tagName !== 'string') { + const htmlTag = val as HtmlTagObject; + if (typeof htmlTag.tagName !== 'string') { throw new Error( `${JSON.stringify( val, )} is not a valid HTML tag object. "tagName" must be defined as a string.`, ); } - if (!(htmlTags as string[]).includes((val as HtmlTagObject).tagName)) { + if ( + !htmlTag.customElement && + !(htmlTags as string[]).includes(htmlTag.tagName) + ) { throw new Error( `Error loading ${JSON.stringify(val)}, "${ - (val as HtmlTagObject).tagName - }" is not a valid HTML tag.`, + htmlTag.tagName + }" is not a valid HTML tag. Either use a valid "tagName" or set "customElement: true".`, ); } } diff --git a/website/docs/api/docusaurus.config.js.mdx b/website/docs/api/docusaurus.config.js.mdx index a376628fb02b..a21ebbcf1782 100644 --- a/website/docs/api/docusaurus.config.js.mdx +++ b/website/docs/api/docusaurus.config.js.mdx @@ -767,9 +767,9 @@ export default { ### `headTags` {#headTags} -An array of tags that will be inserted in the HTML ``. The values must be objects that contain two properties; `tagName` and `attributes`. `tagName` must be a string that determines the tag being created; eg `"link"`. `attributes` must be an attribute-value map. +An array of tags that will be inserted in the HTML ``. The values must be objects that contain two properties; `tagName` and `attributes`. `tagName` must be a string that determines the tag being created; eg `"link"`. `attributes` must be an attribute-value map. When custom html elements are needed, set `customElement: true`. -- Type: `{ tagName: string; attributes: Object; }[]` +- Type: `{ tagName: string; attributes: Object; customElement?: boolean; }[]` Example: