docusaurus/packages/docusaurus-theme-live-codeb.../src/index.ts
Joshua Chen 250d9c8cf5
refactor(live-codeblock): migrate theme to TS (#6583)
* refactor(live-codeblock): migrate theme to TS

* Don't make it visible
2022-02-02 17:48:06 +08:00

47 lines
1.1 KiB
TypeScript

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import path from 'path';
import {readDefaultCodeTranslationMessages} from '@docusaurus/theme-translations';
import type {LoadContext, Plugin} from '@docusaurus/types';
export default function themeLiveCodeblock(context: LoadContext): Plugin {
const {
i18n: {currentLocale},
} = context;
return {
name: 'docusaurus-theme-live-codeblock',
getThemePath() {
return path.resolve(__dirname, '../lib/theme');
},
getTypeScriptThemePath() {
return path.resolve(__dirname, '../src/theme');
},
getDefaultCodeTranslationMessages() {
return readDefaultCodeTranslationMessages({
locale: currentLocale,
name: 'theme-live-codeblock',
});
},
configureWebpack() {
return {
resolve: {
alias: {
buble: path.resolve(__dirname, './custom-buble.js'),
},
},
};
},
};
}
export {validateThemeConfig} from './validateThemeConfig';