Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: transform GitHub alert blocks into Docusaurus admonitions #655

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 }) => {
Expand All @@ -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`,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down