docusaurus/packages/docusaurus-plugin-content-docs/src/markdown/index.ts
Endi feb804cb83 test(v2): add tests for docs markdown link replacement (#1944)
* refactor(v2): simplify & add tests for docs markdown link replacement

* nits
2019-11-06 23:54:37 +08:00

28 lines
646 B
TypeScript

/**
* Copyright (c) 2017-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import {getOptions} from 'loader-utils';
import {loader} from 'webpack';
import linkify from './linkify';
export = function(fileString: string) {
const callback = this.async();
const {docsDir, siteDir, sourceToPermalink} = getOptions(this);
return (
callback &&
callback(
null,
linkify(
fileString,
this.resourcePath,
docsDir,
siteDir,
sourceToPermalink,
),
)
);
} as loader.Loader;