From 3a0d7102c982c1ece202127689a981a4f1edec64 Mon Sep 17 00:00:00 2001 From: Kian Date: Fri, 20 Sep 2024 14:57:18 +0100 Subject: [PATCH] [Docs Site] Add default title to PowerShell codeblocks (#16975) --- ec.config.mjs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/ec.config.mjs b/ec.config.mjs index af2b20f3e8de77..9b43caeb90f311 100644 --- a/ec.config.mjs +++ b/ec.config.mjs @@ -122,8 +122,31 @@ function outputCodeblocks() { }); } +function defaultLanguageTitles() { + return definePlugin({ + name: "Adds language-specific default titles.", + hooks: { + preprocessLanguage: async (context) => { + switch (context.codeBlock.language) { + case "powershell": { + context.codeBlock.props.title ??= "PowerShell"; + break; + } + default: { + return; + } + } + }, + }, + }); +} + export default { - plugins: [workersPlaygroundButton(), outputCodeblocks()], + plugins: [ + workersPlaygroundButton(), + outputCodeblocks(), + defaultLanguageTitles(), + ], themes: [darkTheme, lightTheme], styleOverrides: { textMarkers: {