Repository: vuepress/vuepress-next (ts)

Issue:
[Bug report] Page flickers after initial load
<!-- Please fill in relevant information as much as possible. That would be helpful to locate the problem and save us each other's time -->

<!-- If some fields are irrelevant or you are not sure, remove it or mark it as "not related" / not sure" -->

<!-- If you don't follow the template and not providing valid information, we'll close your issue without further reply -->

## Bug report

### Description

<!-- A clear and concise description of what the bug is. -->

When the page loads, it first displays the frontpage, then switches to an all white screen, and then displays it correctly again. This flickering takes less than a second in both Chrome and Firefox with no cache, and gets faster on subsequent page reloads. This affects only the front page.

### Steps to reproduce

<!-- Steps to reproduce the behavior -->

- Reproduction link / repo:

  Look at <https://grammy.dev/> which is built from [here](https://github.com/grammyjs/website/tree/main/site) using `"vuepress": "^2.0.0-beta.9"`.

In fact, you can also observe it on the documentation of Vuepress Next itself at <https://vuepress2.netlify.app/> if you throttle your network in the devtools, e.g. to Slow 3G.

This does not happen for Vuepress itself, <https://vuepress.vuejs.org/> works just fine under all circumstances.

### Expected behavior

<!-- A clear and concise description of what you expected to happen. -->

When the page loads, the content does not disappear again after being displayed.

### Screenshots

<!-- If applicable, add screenshots to help explain your problem. -->

![rec-2021-04-25_13 52 14 (1)](https://user-images.githubusercontent.com/12952387/115992956-9d8d5d00-a5d0-11eb-9df6-b09690f2acb3.gif)

### Environment info

- Browser: Chrome (Linux), Chrome (Android), Firefox ESR (Linux)
- Output of `vuepress info`:

```bash
$ npx vuepress info

  System:
    OS: Linux 4.19 Debian GNU/Linux 10 (buster) 10 (buster)
    CPU: (4) x64 Intel(R) Core(TM) i5-4200M CPU @ 2.50GHz
    Memory: 2.59 GB / 7.55 GB
    Shell: 5.0.3 - /bin/bash
  Binaries:
    Node: 14.16.1 - /usr/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 7.6.1 - /usr/local/bin/npm
  Utilities:
    Git: 2.20.1 - /usr/bin/git
  Browsers:
    Chrome: 90.0.4430.85
    Firefox: 78.10.0esr
  npmPackages:
    @vuepress/bundler-vite: Not Found
    @vuepress/bundler-webpack:  2.0.0-beta.9 
    @vuepress/cli:  2.0.0-beta.9 
    @vuepress/client:  2.0.0-beta.9 
    @vuepress/core:  2.0.0-beta.9 
    @vuepress/markdown:  2.0.0-beta.9 
    @vuepress/plugin-active-header-links:  2.0.0-beta.9 
    @vuepress/plugin-back-to-top:  2.0.0-beta.9 
    @vuepress/plugin-container:  2.0.0-beta.9 
    @vuepress/plugin-debug: Not Found
    @vuepress/plugin-docsearch: ^2.0.0-beta.9 => 2.0.0-beta.9 
    @vuepress/plugin-git:  2.0.0-beta.9 
    @vuepress/plugin-google-analytics: Not Found
    @vuepress/plugin-medium-zoom:  2.0.0-beta.9 
    @vuepress/plugin-nprogress:  2.0.0-beta.9 
    @vuepress/plugin-palette:  2.0.0-beta.9 
    @vuepress/plugin-pwa: Not Found
    @vuepress/plugin-pwa-popup: Not Found
    @vuepress/plugin-theme-data:  2.0.0-beta.9 
    @vuepress/shared:  2.0.0-beta.7 
    @vuepress/theme-default:  2.0.0-beta.9 
    @vuepress/theme-vue: Not Found
    @vuepress/utils:  2.0.0-beta.8 
    vue:  3.0.11 
    vue-loader:  16.2.0 
    vue-router:  4.0.6 
    vuepress: ^2.0.0-beta.9 => 2.0.0-beta.9 
    vuepress-vite: Not Found
```


Pull request description:
chore(core): tweaks

Patch:
diff --git a/packages/core/src/page/createPage.ts b/packages/core/src/page/createPage.ts
index 0e899d78..7f40f66d 100644
--- a/packages/core/src/page/createPage.ts
+++ b/packages/core/src/page/createPage.ts
@@ -39,7 +39,7 @@ export const createPage = async (
     links,
     sfcBlocks,
     title,
-  } = await renderPageContent({
+  } = renderPageContent({
     app,
     content,
     filePath,
diff --git a/packages/core/src/page/renderPageContent.ts b/packages/core/src/page/renderPageContent.ts
index 414ff07e..b3d0e966 100644
--- a/packages/core/src/page/renderPageContent.ts
+++ b/packages/core/src/page/renderPageContent.ts
@@ -9,7 +9,7 @@ import type { App, PageFrontmatter, PageOptions } from '../types/index.js'
 /**
  * Render page content and extract related info
  */
-export const renderPageContent = async ({
+export const renderPageContent = ({
   app,
   content,
   filePath,
@@ -21,7 +21,7 @@ export const renderPageContent = async ({
   filePath: string | null
   filePathRelative: string | null
   options: PageOptions
-}): Promise<{
+}): {
   contentRendered: string
   deps: string[]
   frontmatter: PageFrontmatter
@@ -29,7 +29,7 @@ export const renderPageContent = async ({
   links: MarkdownLink[]
   sfcBlocks: MarkdownSfcBlocks
   title: string
-}> => {
+} => {
   const markdownEnv: MarkdownEnv = {
     base: app.options.base,
     filePath,


Test patch:
diff --git a/packages/core/tests/page/renderPageContent.spec.ts b/packages/core/tests/page/renderPageContent.spec.ts
index 5f3c8c7d..0ecc671b 100644
--- a/packages/core/tests/page/renderPageContent.spec.ts
+++ b/packages/core/tests/page/renderPageContent.spec.ts
@@ -11,8 +11,8 @@ const app = createBaseApp({
 app.markdown = createMarkdown()
 
 describe('core > page > renderPageContent', () => {
-  it('should render page content correctly', async () => {
-    const resolved = await renderPageContent({
+  it('should render page content correctly', () => {
+    const resolved = renderPageContent({
       app,
       content: `\
 foobar
@@ -64,8 +64,8 @@ const msg = 'msg'
   })
 
   describe('page title', () => {
-    it('should use title in frontmatter', async () => {
-      const resolved = await renderPageContent({
+    it('should use title in frontmatter', () => {
+      const resolved = renderPageContent({
         app,
         content: '# title in header',
         filePath: null,
@@ -80,8 +80,8 @@ const msg = 'msg'
       expect(resolved.title).toEqual('title in frontmatter')
     })
 
-    it('should use title in the first h1 header', async () => {
-      const resolved = await renderPageContent({
+    it('should use title in the first h1 header', () => {
+      const resolved = renderPageContent({
         app,
         content: '# title in header',
         filePath: null,
@@ -92,8 +92,8 @@ const msg = 'msg'
       expect(resolved.title).toEqual('title in header')
     })
 
-    it('should use empty title', async () => {
-      const resolved = await renderPageContent({
+    it('should use empty title', () => {
+      const resolved = renderPageContent({
         app,
         content: '',
         filePath: null,
@@ -106,8 +106,8 @@ const msg = 'msg'
   })
 
   describe('page frontmatter', () => {
-    it('should merge markdown frontmatter and options frontmatter', async () => {
-      const resolved = await renderPageContent({
+    it('should merge markdown frontmatter and options frontmatter', () => {
+      const resolved = renderPageContent({
         app,
         content: `\
 ---
@@ -129,8 +129,8 @@ title: title in markdown frontmatter
       })
     })
 
-    it('should use fields from markdown frontmatter first', async () => {
-      const resolved = await renderPageContent({
+    it('should use fields from markdown frontmatter first', () => {
+      const resolved = renderPageContent({
         app,
         content: `\
 ---