mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-23 21:17:54 +02:00
fix(v2): linkify blog posts (#2326)
* fix(v2): linkify blog posts * Fix tests
This commit is contained in:
parent
84eeb5120c
commit
36163773ec
8 changed files with 161 additions and 12 deletions
|
@ -5,21 +5,20 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const {parseQuery, getOptions} = require('loader-utils');
|
||||
import {loader} from 'webpack';
|
||||
import {truncate} from './blogUtils';
|
||||
import {truncate, linkify} from './blogUtils';
|
||||
const {parseQuery, getOptions} = require('loader-utils');
|
||||
|
||||
export = function(fileString: string) {
|
||||
const callback = this.async();
|
||||
|
||||
const {truncateMarker}: {truncateMarker: RegExp} = getOptions(this);
|
||||
|
||||
let finalContent = fileString;
|
||||
const {truncateMarker, siteDir, contentPath, blogPosts} = getOptions(this);
|
||||
// Linkify posts
|
||||
let finalContent = linkify(fileString, siteDir, contentPath, blogPosts);
|
||||
|
||||
// Truncate content if requested (e.g: file.md?truncated=true).
|
||||
const {truncated} = this.resourceQuery && parseQuery(this.resourceQuery);
|
||||
if (truncated) {
|
||||
finalContent = truncate(fileString, truncateMarker);
|
||||
finalContent = truncate(finalContent, truncateMarker);
|
||||
}
|
||||
|
||||
return callback && callback(null, finalContent);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue