Compare commits

...

2 Commits

Author SHA1 Message Date
Aaron
df66d9678b
chore: set different trigger key
Signed-off-by: Aaron <29749331+aarnphm@users.noreply.github.com>
2024-02-08 23:48:31 -05:00
Aaron
a72aeae429
feat: cursor chat
Signed-off-by: Aaron <29749331+aarnphm@users.noreply.github.com>
2024-02-06 08:32:57 -05:00
5 changed files with 39 additions and 2 deletions

View File

@ -6,6 +6,7 @@ const config: QuartzConfig = {
pageTitle: "🪴 Quartz 4.0",
enableSPA: true,
enablePopovers: true,
enableCursorChat: false,
analytics: {
provider: "plausible",
},

View File

@ -26,6 +26,8 @@ export interface GlobalConfiguration {
enableSPA: boolean
/** Whether to display Wikipedia-style popovers when hovering over links */
enablePopovers: boolean
/** Whether to enable cursor-chat */
enableCursorChat: boolean
/** Analytics mode */
analytics: Analytics
/** Glob patterns to not search */

View File

@ -235,6 +235,11 @@ export function renderPage(
</Body>
<Footer {...componentData} />
</div>
{cfg.enableCursorChat && (
<div id="cursor-chat-layer">
<input type="text" id="cursor-chat-box" />
</div>
)}
</body>
{pageResources.js
.filter((resource) => resource.loadTime === "afterDOMReady")

View File

@ -138,6 +138,21 @@ function addGlobalPageResources(
`)
}
if (cfg.enableCursorChat) {
staticResources.css.push("https://unpkg.com/cursor-chat/dist/style.css")
staticResources.js.push({
script: `
document.addEventListener('nav', async () => {
const chat = await import('https://esm.sh/cursor-chat')
chat.initCursorChat(\`cursor-chat-room-\${window.location.host + window.location.pathname}\`, { triggerKey: '.' })
})
`,
loadTime: "afterDOMReady",
moduleType: "module",
contentType: "inline",
})
}
let wsUrl = `ws://localhost:${ctx.argv.wsPort}`
if (ctx.argv.remoteDevHost) {
@ -186,7 +201,7 @@ export const ComponentResources: QuartzEmitterPlugin<Options> = (opts?: Partial<
addGlobalPageResources(ctx, resources, componentResources)
const stylesheet = joinStyles(ctx.cfg.configuration.theme, ...componentResources.css, styles)
const stylesheet = joinStyles(ctx.cfg.configuration, ...componentResources.css, styles)
const [prescript, postscript] = await Promise.all([
joinScripts(componentResources.beforeDOMLoaded),
joinScripts(componentResources.afterDOMLoaded),

View File

@ -1,3 +1,5 @@
import { GlobalConfiguration } from "../cfg"
export interface ColorScheme {
light: string
lightgray: string
@ -30,8 +32,20 @@ export function googleFontHref(theme: Theme) {
return `https://fonts.googleapis.com/css2?family=${code}&family=${header}:wght@400;700&family=${body}:ital,wght@0,400;0,600;1,400;1,600&display=swap`
}
export function joinStyles(theme: Theme, ...stylesheet: string[]) {
export function joinStyles(cfg: GlobalConfiguration, ...stylesheet: string[]) {
const theme = cfg.theme
return `
${
cfg.enableCursorChat &&
`
input#cursor-chat-box {
outline: none;
background-color: var(--light);
font-family: "${cfg.theme.typography.body}", ${DEFAULT_SANS_SERIF} !important;
}
`
}
${stylesheet.join("\n\n")}
:root {