mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-21 03:57:51 +02:00
refactor: migrate lqip-loader to TS, fix typing for Webpack Loaders (#5779)
This commit is contained in:
parent
ca5d70d7fb
commit
68c970175a
18 changed files with 254 additions and 265 deletions
|
@ -8,18 +8,16 @@
|
|||
import {truncate, linkify} from './blogUtils';
|
||||
import {parseQuery} from 'loader-utils';
|
||||
import {BlogMarkdownLoaderOptions} from './types';
|
||||
import type {LoaderContext} from 'webpack';
|
||||
|
||||
// TODO temporary until Webpack5 export this type
|
||||
// see https://github.com/webpack/webpack/issues/11630
|
||||
interface Loader extends Function {
|
||||
(this: any, source: string): string | Buffer | void | undefined;
|
||||
}
|
||||
|
||||
const markdownLoader: Loader = function (source) {
|
||||
export default function markdownLoader(
|
||||
this: LoaderContext<BlogMarkdownLoaderOptions>,
|
||||
source: string,
|
||||
): void {
|
||||
const filePath = this.resourcePath;
|
||||
const fileString = source as string;
|
||||
const fileString = source;
|
||||
const callback = this.async();
|
||||
const markdownLoaderOptions = this.getOptions() as BlogMarkdownLoaderOptions;
|
||||
const markdownLoaderOptions = this.getOptions();
|
||||
|
||||
// Linkify blog posts
|
||||
let finalContent = linkify({
|
||||
|
@ -38,6 +36,4 @@ const markdownLoader: Loader = function (source) {
|
|||
}
|
||||
|
||||
return callback && callback(null, finalContent);
|
||||
};
|
||||
|
||||
export default markdownLoader;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue