diff --git a/docusaurus.config.ts b/docusaurus.config.ts index 8c0e6647979..b4c0ff71d5f 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -3,6 +3,7 @@ import type { Config } from '@docusaurus/types'; import type * as Preset from '@docusaurus/preset-classic'; import { execSync } from 'child_process'; import path from 'path'; +import remarkGithubAdmonitionsToDirectives from 'remark-github-admonitions-to-directives'; import generateSubPages from './scripts/generateSubPages.js'; import latestRhelRedirect from './src/data/latest-rhel-redirect.json'; @@ -55,6 +56,9 @@ const config: Config = { // Remove this to remove the "edit this page" links. editUrl: 'https://github.com/osbuild/osbuild.github.io/tree/main/', + // Convert GitHub Alerts (`> [!WARNING]`) from pulled READMEs into + // Docusaurus admonition directives. Must run before default plugins. + beforeDefaultRemarkPlugins: [remarkGithubAdmonitionsToDirectives], }, theme: { customCss: './src/css/custom.css', diff --git a/package-lock.json b/package-lock.json index cc5d596c63d..9040f2367b2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,8 @@ "clsx": "^2.1.1", "prism-react-renderer": "^2.4.1", "react": "^18.3.1", - "react-dom": "^18.3.1" + "react-dom": "^18.3.1", + "remark-github-admonitions-to-directives": "^2.1.0" }, "devDependencies": { "@docusaurus/module-type-aliases": "3.6.3", @@ -14909,6 +14910,21 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/remark-github-admonitions-to-directives": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/remark-github-admonitions-to-directives/-/remark-github-admonitions-to-directives-2.1.0.tgz", + "integrity": "sha512-bI3E4Oj1pKY3ym2IQrrVCdORgEu0+mSrWgpCYFNy8QvytfnLs/nAacVPjkWU/JzDMUiQio2k4nTFP7bsIr9TSA==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "mdast-util-directive": "^3.0.0", + "unified": "^11.0.0", + "unist-util-visit": "^5.0.0" + }, + "engines": { + "pnpm": ">=9.0.0" + } + }, "node_modules/remark-mdx": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/remark-mdx/-/remark-mdx-3.0.0.tgz", diff --git a/package.json b/package.json index 44aecd93129..b70d72f163e 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,8 @@ "clsx": "^2.1.1", "prism-react-renderer": "^2.4.1", "react": "^18.3.1", - "react-dom": "^18.3.1" + "react-dom": "^18.3.1", + "remark-github-admonitions-to-directives": "^2.1.0" }, "devDependencies": { "@docusaurus/module-type-aliases": "3.6.3",