From 9b74744299ece0108573a142e5a2e949dc569254 Mon Sep 17 00:00:00 2001 From: Koy Zhuang Date: Sat, 17 Sep 2022 19:01:35 +0800 Subject: [PATCH 1/2] fix: fix search with no content. (#1878) --- src/plugins/search/search.js | 15 ++++++++------- test/e2e/search.test.js | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+), 7 deletions(-) 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'); + }); }); From c98fda7ad6805d9f38dd964dbc3751583b3b940b Mon Sep 17 00:00:00 2001 From: Mike Mwanje Date: Sat, 17 Sep 2022 17:50:31 +0300 Subject: [PATCH 2/2] docs: Update GitHub default branch from to 'main' (#1883) --- docs/deploy.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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