diff --git a/docs/deploy.md b/docs/deploy.md index 4072b404b..9ac3ca50f 100644 --- a/docs/deploy.md +++ b/docs/deploy.md @@ -7,14 +7,14 @@ Similar to [GitBook](https://www.gitbook.com), you can deploy files to GitHub Pa There are three places to populate your docs for your GitHub repository: - `docs/` folder -- master branch +- main branch - gh-pages branch -It is recommended that you save your files to the `./docs` subfolder of the `master` branch of your repository. Then select `master branch /docs folder` as your GitHub Pages source in your repository's settings page. +It is recommended that you save your files to the `./docs` subfolder of the `main` branch of your repository. Then select `main branch /docs folder` as your GitHub Pages source in your repository's settings page. ![GitHub Pages](_images/deploy-github-pages.png) -!> You can also save files in the root directory and select `master branch`. +!> You can also save files in the root directory and select `main branch`. You'll need to place a `.nojekyll` file in the deploy location (such as `/docs` or the gh-pages branch) ## GitLab Pages diff --git a/src/plugins/search/search.js b/src/plugins/search/search.js index 91a21094e..3266b7bb4 100644 --- a/src/plugins/search/search.js +++ b/src/plugins/search/search.js @@ -211,14 +211,15 @@ export function search(query) { } const matchContent = + handlePostContent && '...' + - handlePostContent - .substring(start, end) - .replace( - regEx, - word => `${word}` - ) + - '...'; + handlePostContent + .substring(start, end) + .replace( + regEx, + word => `${word}` + ) + + '...'; resultStr += matchContent; } diff --git a/test/e2e/search.test.js b/test/e2e/search.test.js index cab645184..ed79f05f9 100644 --- a/test/e2e/search.test.js +++ b/test/e2e/search.test.js @@ -176,4 +176,24 @@ test.describe('Search Plugin Tests', () => { await searchFieldElm.fill('hello'); await expect(resultsHeadingElm).toHaveText('Changelog Title'); }); + test('search when there is no body', async ({ page }) => { + const docsifyInitConfig = { + markdown: { + homepage: ` + # EmptyContent + --- + --- + `, + }, + scriptURLs: ['/lib/plugins/search.min.js'], + }; + + const searchFieldElm = page.locator('input[type=search]'); + const resultsHeadingElm = page.locator('.results-panel h2'); + + await docsifyInit(docsifyInitConfig); + + await searchFieldElm.fill('empty'); + await expect(resultsHeadingElm).toHaveText('EmptyContent'); + }); });