fix(v2): ignore style imports in excerpt (#3944)

This commit is contained in:
Alexey Pyltsyn 2020-12-21 16:47:19 +03:00 committed by GitHub
parent b133e2def6
commit 2fb766ba7c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View file

@ -386,6 +386,7 @@ describe('load utils', () => {
input: `
import Component from '@site/src/components/Component';
import Component from '@site/src/components/Component'
import './styles.css';
export function ItemCol(props) { return <Item {...props} className={'col col--6 margin-bottom--lg'}/> }

View file

@ -204,7 +204,7 @@ export function createExcerpt(fileString: string): string | undefined {
}
// Skip import/export declaration.
if (/^.*import\s.*from.*;?|export\s.*{.*};?/.test(fileLine)) {
if (/^\s*?import\s.*(from.*)?;?|export\s.*{.*};?/.test(fileLine)) {
continue;
}