Skip to content

Commit 2ef0e94

Browse files
committed
feat(core): support permalink: null in frontmatter to disable permalink
1 parent 8b1ab67 commit 2ef0e94

File tree

2 files changed

+9
-22
lines changed

2 files changed

+9
-22
lines changed

packages/core/src/page/resolvePagePermalink.ts

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,15 @@ export const resolvePagePermalink = ({
2525
return frontmatter.permalink
2626
}
2727

28+
if (frontmatter.permalink === null || frontmatter.permalinkPattern === null) {
29+
return null
30+
}
31+
2832
// get permalink pattern
29-
const permalinkPattern = getPermalinkPattern({ app, frontmatter })
30-
if (permalinkPattern === null) {
33+
const permalinkPattern =
34+
frontmatter.permalinkPattern || app.options.permalinkPattern
35+
36+
if (!permalinkPattern) {
3137
return null
3238
}
3339

@@ -45,22 +51,3 @@ export const resolvePagePermalink = ({
4551

4652
return ensureLeadingSlash(link)
4753
}
48-
49-
/**
50-
* Get permalink pattern from frontmatter or app options
51-
*/
52-
const getPermalinkPattern = ({
53-
app,
54-
frontmatter,
55-
}: {
56-
app: App
57-
frontmatter: PageFrontmatter
58-
}): string | null => {
59-
if (frontmatter.permalinkPattern === null) {
60-
return null
61-
}
62-
if (isString(frontmatter.permalinkPattern)) {
63-
return frontmatter.permalinkPattern
64-
}
65-
return app.options.permalinkPattern
66-
}

packages/shared/src/types/page.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export type PageFrontmatter<
6262
head?: HeadConfig[]
6363
lang?: string
6464
layout?: string
65-
permalink?: string
65+
permalink?: string | null
6666
permalinkPattern?: string | null
6767
routeMeta?: Record<string, unknown>
6868
title?: string

0 commit comments

Comments
 (0)