feat: transform GitHub alert blocks into Docusaurus admonitions (#655)

Co-authored-by: Erick Zhao <erick@hotmail.ca>
This commit is contained in:
AmrMustafa 2024-11-13 04:59:18 +02:00 коммит произвёл GitHub
Родитель f9a8a07c09
Коммит 7c646d63f9
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
3 изменённых файлов: 30 добавлений и 0 удалений

Просмотреть файл

@ -2,6 +2,11 @@ import path from 'path';
import { Config } from '@docusaurus/types';
import npm2yarn from '@docusaurus/remark-plugin-npm2yarn';
import { themes as prismThemes } from 'prism-react-renderer';
import remarkGithubAdmonitionsToDirectives, {
DEFAULT_MAPPING,
DirectiveName,
GithubAlertType,
} from 'remark-github-admonitions-to-directives';
import apiLabels from './src/transformers/api-labels';
import apiOptionsClass from './src/transformers/api-options-class';
@ -208,6 +213,18 @@ const config: Config = {
'@docusaurus/preset-classic',
{
docs: {
path: 'docs',
beforeDefaultRemarkPlugins: [
[
remarkGithubAdmonitionsToDirectives,
{
mapping: {
...DEFAULT_MAPPING,
[GithubAlertType.NOTE]: DirectiveName.INFO,
},
},
],
],
sidebarPath: require.resolve('./sidebars.js'),
routeBasePath: '/docs/',
editUrl: ({ docPath }) => {
@ -226,6 +243,8 @@ const config: Config = {
},
blog: {
// See `node_modules/@docusaurus/plugin-content-blog/src/pluginOptionSchema.ts` for full undocumented options
path: 'blog',
beforeDefaultRemarkPlugins: [remarkGithubAdmonitionsToDirectives],
blogSidebarCount: 'ALL',
blogSidebarTitle: 'Latest posts',
blogTitle: `Electron's blog`,

Просмотреть файл

@ -45,6 +45,7 @@
"react-dom": "^18.3.1",
"react-markdown": "^9.0.1",
"react-useportal": "^1.0.14",
"remark-github-admonitions-to-directives": "^2.0.0",
"sass": "^1.37.5",
"semver": "^7.5.4",
"yaml": "^2.4.3"

Просмотреть файл

@ -13050,6 +13050,16 @@ remark-gfm@^4.0.0:
remark-stringify "^11.0.0"
unified "^11.0.0"
remark-github-admonitions-to-directives@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/remark-github-admonitions-to-directives/-/remark-github-admonitions-to-directives-2.1.0.tgz#5bdb5deb3e1d6ee7a1427aeea9e27e7b3ea96ff4"
integrity sha512-bI3E4Oj1pKY3ym2IQrrVCdORgEu0+mSrWgpCYFNy8QvytfnLs/nAacVPjkWU/JzDMUiQio2k4nTFP7bsIr9TSA==
dependencies:
"@types/mdast" "^4.0.0"
mdast-util-directive "^3.0.0"
unified "^11.0.0"
unist-util-visit "^5.0.0"
remark-mdx@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/remark-mdx/-/remark-mdx-3.0.1.tgz#8f73dd635c1874e44426e243f72c0977cf60e212"