Skip to content

Commit

Permalink
refactor(v2): simplify blog truncate function (#1968)
Browse files Browse the repository at this point in the history
* refactor(v2): simplify blog truncate function

* Update packages/docusaurus-plugin-content-blog/src/blogUtils.ts

Co-Authored-By: Alexey Pyltsyn <lex61rus@gmail.com>
  • Loading branch information
endiliey and lex111 authored Nov 12, 2019
1 parent 3823feb commit 874b063
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions packages/docusaurus-plugin-content-blog/src/blogUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ import {parse, normalizeUrl} from '@docusaurus/utils';
import {LoadContext} from '@docusaurus/types';

export function truncate(fileString: string, truncateMarker: RegExp | string) {
const truncated =
typeof truncateMarker === 'string'
? fileString.includes(truncateMarker)
: truncateMarker.test(fileString);
return truncated ? fileString.split(truncateMarker)[0] : fileString;
return fileString.split(truncateMarker, 1).shift()!;
}

// YYYY-MM-DD-{name}.mdx?
Expand Down

0 comments on commit 874b063

Please sign in to comment.