Skip to content

Commit

Permalink
refactor: use omit
Browse files Browse the repository at this point in the history
  • Loading branch information
meteorlxy committed Feb 27, 2023
1 parent dfb46a4 commit 0c37903
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 19 deletions.
4 changes: 4 additions & 0 deletions packages/core/package.json
Expand Up @@ -35,8 +35,12 @@
"@vuepress/markdown": "workspace:*",
"@vuepress/shared": "workspace:*",
"@vuepress/utils": "workspace:*",
"lodash.omit": "^4.5.0",
"vue": "^3.2.47"
},
"devDependencies": {
"@types/lodash.omit": "^4.5.7"
},
"publishConfig": {
"access": "public"
},
Expand Down
24 changes: 10 additions & 14 deletions packages/core/src/page/renderPageContent.ts
Expand Up @@ -4,6 +4,7 @@ import type {
MarkdownLink,
MarkdownSfcBlocks,
} from '@vuepress/markdown'
import omit from 'lodash.omit'
import type { App, PageFrontmatter, PageOptions } from '../types/index.js'

/**
Expand Down Expand Up @@ -55,19 +56,7 @@ export const renderPageContent = ({
customBlocks: [],
},
title = '',

// values dropped from env

// eslint-disable-next-line @typescript-eslint/naming-convention
base: _base,
// eslint-disable-next-line @typescript-eslint/naming-convention
content: _content,
// eslint-disable-next-line @typescript-eslint/naming-convention
filePath: _filePath,
// eslint-disable-next-line @typescript-eslint/naming-convention
filePathRelative: _filePathRelative,

...otherEnv
...extraMarkdownEnv
} = markdownEnv

return {
Expand All @@ -76,7 +65,14 @@ export const renderPageContent = ({
frontmatter,
headers,
links,
markdownEnv: otherEnv,
markdownEnv: omit(
extraMarkdownEnv,
'base',
'content',
'filePath',
'filePathRelative',
'frontmatter'
),
sfcBlocks,
title: frontmatter.title ?? title,
}
Expand Down
10 changes: 5 additions & 5 deletions packages/core/src/types/page.ts
Expand Up @@ -42,6 +42,11 @@ export type Page<
*/
links: MarkdownLink[]

/**
* Markdown env object of the page
*/
markdownEnv: Record<string, unknown>

/**
* Path of the page that inferred from file path
*
Expand Down Expand Up @@ -74,11 +79,6 @@ export type Page<
*/
routeMeta: Record<string, unknown>

/**
* Markdown Environment of the page
*/
markdownEnv: Record<string, unknown>

/**
* Extracted sfc blocks of the page
*/
Expand Down
19 changes: 19 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0c37903

Please sign in to comment.