mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-21 12:08:03 +02:00
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:
parent
0584407257
commit
78159f6dd5
13 changed files with 253 additions and 43 deletions
|
@ -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;
|
Loading…
Add table
Add a link
Reference in a new issue