mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-04 10:27:52 +02:00
refactor(v2): simplify blog truncate function (#1968)
* refactor(v2): simplify blog truncate function * Update packages/docusaurus-plugin-content-blog/src/blogUtils.ts Co-Authored-By: Alexey Pyltsyn <lex61rus@gmail.com>
This commit is contained in:
parent
3823feb276
commit
874b0638cd
1 changed files with 1 additions and 5 deletions
|
@ -7,11 +7,7 @@ import {parse, normalizeUrl} from '@docusaurus/utils';
|
||||||
import {LoadContext} from '@docusaurus/types';
|
import {LoadContext} from '@docusaurus/types';
|
||||||
|
|
||||||
export function truncate(fileString: string, truncateMarker: RegExp | string) {
|
export function truncate(fileString: string, truncateMarker: RegExp | string) {
|
||||||
const truncated =
|
return fileString.split(truncateMarker, 1).shift()!;
|
||||||
typeof truncateMarker === 'string'
|
|
||||||
? fileString.includes(truncateMarker)
|
|
||||||
: truncateMarker.test(fileString);
|
|
||||||
return truncated ? fileString.split(truncateMarker)[0] : fileString;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// YYYY-MM-DD-{name}.mdx?
|
// YYYY-MM-DD-{name}.mdx?
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue