mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-20 03:14:06 -06:00
feat:ReplyByEmail button
adds a 'buttonLabel' support to allow changing the ReplyByEmail button label from the layout file
This commit is contained in:
parent
b4b22aad94
commit
e5049e89c6
@ -6,6 +6,7 @@ interface ReplyByEmailOptions {
|
|||||||
domain?: string
|
domain?: string
|
||||||
includeTitles?: string[]
|
includeTitles?: string[]
|
||||||
excludeTitles?: string[]
|
excludeTitles?: string[]
|
||||||
|
buttonLabel?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default options will be used if not provided in the layout file
|
// Default options will be used if not provided in the layout file
|
||||||
@ -13,7 +14,8 @@ const defaultOptions: ReplyByEmailOptions = {
|
|||||||
username: "ZW1haWw=", // "email" in base64
|
username: "ZW1haWw=", // "email" in base64
|
||||||
domain: "ZXhhbXBsZS5jb20=", // "email.com" in base64
|
domain: "ZXhhbXBsZS5jb20=", // "email.com" in base64
|
||||||
includeTitles: [],
|
includeTitles: [],
|
||||||
excludeTitles: ["Home", "About me", "Contact me"]
|
excludeTitles: ["Home", "About me", "Contact me"],
|
||||||
|
buttonLabel: "Reply by email"
|
||||||
}
|
}
|
||||||
|
|
||||||
const ReplyByEmail: QuartzComponent = ({
|
const ReplyByEmail: QuartzComponent = ({
|
||||||
@ -22,7 +24,8 @@ const ReplyByEmail: QuartzComponent = ({
|
|||||||
username,
|
username,
|
||||||
domain,
|
domain,
|
||||||
includeTitles,
|
includeTitles,
|
||||||
excludeTitles
|
excludeTitles,
|
||||||
|
buttonLabel
|
||||||
}: QuartzComponentProps & ReplyByEmailOptions) => {
|
}: QuartzComponentProps & ReplyByEmailOptions) => {
|
||||||
const title = fileData.frontmatter?.title
|
const title = fileData.frontmatter?.title
|
||||||
|
|
||||||
@ -31,6 +34,7 @@ const ReplyByEmail: QuartzComponent = ({
|
|||||||
const encodedPart2 = domain || defaultOptions.domain
|
const encodedPart2 = domain || defaultOptions.domain
|
||||||
const includeList = includeTitles || defaultOptions.includeTitles
|
const includeList = includeTitles || defaultOptions.includeTitles
|
||||||
const excludeList = excludeTitles || defaultOptions.excludeTitles
|
const excludeList = excludeTitles || defaultOptions.excludeTitles
|
||||||
|
const label = buttonLabel || defaultOptions.buttonLabel
|
||||||
|
|
||||||
// Display logic:
|
// Display logic:
|
||||||
// 1. If includeTitles is not empty, only show on those pages
|
// 1. If includeTitles is not empty, only show on those pages
|
||||||
@ -49,7 +53,7 @@ const ReplyByEmail: QuartzComponent = ({
|
|||||||
data-domain={encodedPart2}
|
data-domain={encodedPart2}
|
||||||
data-title={encodeURIComponent(title)}
|
data-title={encodeURIComponent(title)}
|
||||||
>
|
>
|
||||||
Reply by email
|
{label}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
@ -130,7 +134,8 @@ export default ((opts?: ReplyByEmailOptions) => {
|
|||||||
username: opts?.username,
|
username: opts?.username,
|
||||||
domain: opts?.domain,
|
domain: opts?.domain,
|
||||||
includeTitles: opts?.includeTitles,
|
includeTitles: opts?.includeTitles,
|
||||||
excludeTitles: opts?.excludeTitles
|
excludeTitles: opts?.excludeTitles,
|
||||||
|
buttonLabel: opts?.buttonLabel
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user