mirror of
https://github.com/cloudflare/cloudflare-docs.git
synced 2026-01-11 20:06:58 +00:00
* [Docs Site] Adopt eslint * Demonstrate a fixable suggestion, add VSCode plugin and package.json script * Fix slice in ModelCatalog * Remove test error in AnchorHeading * recreate package-lock.json * update new .jsx components to .tsx * amend deps, fix react types, organise ec plugins * another attempt at fixing platform-specific deps * fix FieldCatalog filters, remove test block from code.mdx * use opacity instead of brightness for ruleid * fix lockfile * amend ruleid opacity styling * test onetrust * enable prefer const rule, remove onetrust test * add save-dev
45 lines
1.2 KiB
JavaScript
45 lines
1.2 KiB
JavaScript
import { definePlugin } from "@expressive-code/core";
|
|
|
|
export default () => {
|
|
return definePlugin({
|
|
name: "Adds the '.code-output' class if 'output' is passed on the opening codefence.",
|
|
hooks: {
|
|
preprocessMetadata: async (context) => {
|
|
if (!context.codeBlock.meta.includes("output")) return;
|
|
|
|
context.codeBlock.props.frame = "none";
|
|
},
|
|
postprocessRenderedBlock: async (context) => {
|
|
if (!context.codeBlock.meta.includes("output")) return;
|
|
context.renderData.blockAst.properties.className ??= [];
|
|
if (Array.isArray(context.renderData.blockAst.properties.className)) {
|
|
context.renderData.blockAst.properties.className.push("code-output");
|
|
}
|
|
context.addStyles(`
|
|
div.expressive-code:has(figure.code-output) {
|
|
margin-top: 0 !important;
|
|
}
|
|
|
|
.code-output .copy {
|
|
display: none !important;
|
|
}
|
|
|
|
.code-output > pre {
|
|
border-top-width: 0 !important;
|
|
background: var(--sl-color-gray-6) !important;
|
|
}
|
|
|
|
.code-output > pre > code {
|
|
user-select: none;
|
|
transition: opacity 0.5s ease;
|
|
}
|
|
|
|
.code-output > pre > code:hover {
|
|
cursor: default;
|
|
opacity: 0.5;
|
|
}
|
|
`);
|
|
},
|
|
},
|
|
});
|
|
};
|