refactor(v2): convert @docusaurus/plugin-content-blog to TypeScript (#1785)

* convert `@docusaurus/plugin-content-blog` to typescript

remove divided plugin
convert `@docusaurus/plugin-content-blog` to typescript
convert `@docusaurus/plugin-content-blog` to typescript
convert `@docusaurus/plugin-content-blog` to typescript
add `packages/docusaurus-plugin-content-blog/lib` to ignores
linted
refactoring type definition
fix test fails
lint

* lint
This commit is contained in:
Dongwoo Gim 2019-09-17 00:46:57 +09:00 committed by Endi
parent 0584407257
commit 78159f6dd5
13 changed files with 253 additions and 43 deletions

View file

@ -0,0 +1,30 @@
/**
* 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.
*/
const {parseQuery, getOptions} = require('loader-utils');
import {loader} from 'webpack';
export = function(fileString: string) {
const callback = this.async();
const {truncateMarker} = getOptions(this);
let finalContent = fileString;
// Truncate content if requested (e.g: file.md?truncated=true)
const {truncated} = this.resourceQuery && parseQuery(this.resourceQuery);
if (
truncated &&
(typeof truncateMarker === 'string'
? fileString.includes(truncateMarker)
: truncateMarker.test(fileString))
) {
// eslint-disable-next-line
finalContent = fileString.split(truncateMarker)[0];
}
return callback && callback(null, finalContent);
} as loader.Loader;