feat(techdocs): add techdocs-cli option to disable external font download

Signed-off-by: Karthik <karthik.jk11@gmail.com>
This commit is contained in:
Karthik
2025-11-25 14:16:44 +05:30
parent 5ef8d166cb
commit 329f5920b6
11 changed files with 44 additions and 6 deletions
@@ -37,7 +37,7 @@ import {
patchMkdocsYmlPreBuild,
patchMkdocsYmlWithPlugins,
sanitizeMkdocsYml,
patchMkdocsYmlWithFontDisabled
patchMkdocsYmlWithFontDisabled,
} from './mkdocsPatchers';
import yaml from 'js-yaml';
@@ -210,16 +210,27 @@ export const patchMkdocsYmlWithFontDisabled = async (
return true;
}
// Theme section exists, check if font is not configured, add font: false
// Theme section exists. Only modify it when the configured theme is Material
if (
mkdocsYml.theme &&
typeof mkdocsYml.theme === 'object' &&
(mkdocsYml.theme as any).name === MATERIAL_THEME &&
!('font' in mkdocsYml.theme)
) {
mkdocsYml.theme.font = false;
return true;
}
if (
mkdocsYml.theme &&
typeof mkdocsYml.theme === 'object' &&
(mkdocsYml.theme as any).name !== MATERIAL_THEME
) {
logger.debug(
'mkdocs.yml theme is not "material"; skipping font disabling patch',
);
}
return false;
});
};
@@ -288,4 +299,3 @@ export const sanitizeMkdocsYml = async (
return true;
});
};
@@ -269,7 +269,7 @@ export function readGeneratorConfig(
'techdocs.generator.mkdocs.dangerouslyAllowAdditionalKeys',
),
disableExternalFonts: config.getOptionalBoolean(
'techdocs.generator.mkdocs.disableExternalFonts'
'techdocs.generator.mkdocs.disableExternalFonts',
),
};
}