lint: format

This commit is contained in:
bfahrenfort 2024-08-31 18:24:31 +10:00
parent 4297be0fcb
commit 431539a363
8 changed files with 85 additions and 56 deletions

View File

@ -13,6 +13,7 @@ const config: QuartzConfig = {
enableSPA: true,
enablePopovers: false, // https://github.com/jackyzha0/quartz/issues/890
analytics: null,
locale: "en-US",
baseUrl: "be-far.com",
ignorePatterns: ["private", "**/templates"],
theme: {
@ -36,7 +37,7 @@ const config: QuartzConfig = {
textHighlight: "#fff23688",
},
darkMode: {
light: "#131829",// Backg
light: "#131829", // Backg
lightgray: "#70778F", // Code Backg
gray: "#686D82", // Unread nodes and subtitles
darkgray: "#cdd6f4", // Text
@ -67,8 +68,13 @@ const config: QuartzConfig = {
Plugin.TableOfContents(),
Plugin.CrawlLinks({ markdownLinkResolution: "shortest" }),
Plugin.Description(),
Plugin.Remark42({ host: "https://be-far.com/comments", site_id: "remark", theme: "dark", no_footer: true }),
Plugin.Latex({renderEngine: "katex"})
Plugin.Remark42({
host: "https://be-far.com/comments",
site_id: "remark",
theme: "dark",
no_footer: true,
}),
Plugin.Latex({ renderEngine: "katex" }),
],
filters: [Plugin.RemoveDrafts()],
emitters: [

View File

@ -28,31 +28,38 @@ export const defaultContentPageLayout: PageLayout = {
Component.MobileOnly(Component.Spacer()),
Component.Search(),
Component.Darkmode(),
Component.DesktopOnly(Component.Explorer({
sortFn: (a, b) => {
const emojis = /([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g
const a_name = a.name.replace(emojis, '').trim()
const a_dname = a.displayName.replace(emojis, '').trim()
const b_name = b.name.replace(emojis, '').trim()
const b_dname = b.displayName.replace(emojis, '').trim()
// Sort order: folders first, then files. Sort folders and files alphabetically
if (/^.*Home$/.test(a_dname)) { return -1 }
if (/^.*Home$/.test(b_dname)) { return 1 }
if ((!a.file && !b.file) || (a.file && b.file)) {
// numeric: true: Whether numeric collation should be used, such that "1" < "2" < "10"
// sensitivity: "base": Only strings that differ in base letters compare as unequal. Examples: a ≠ b, a = á, a = A
return a_dname.localeCompare(b_dname, undefined, {
numeric: true,
sensitivity: "base",
})
}
if (a.file && !b.file) {
return 1
} else {
return -1
}
}
})),
Component.DesktopOnly(
Component.Explorer({
sortFn: (a, b) => {
const emojis =
/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g
const a_name = a.name.replace(emojis, "").trim()
const a_dname = a.displayName.replace(emojis, "").trim()
const b_name = b.name.replace(emojis, "").trim()
const b_dname = b.displayName.replace(emojis, "").trim()
// Sort order: folders first, then files. Sort folders and files alphabetically
if (/^.*Home$/.test(a_dname)) {
return -1
}
if (/^.*Home$/.test(b_dname)) {
return 1
}
if ((!a.file && !b.file) || (a.file && b.file)) {
// numeric: true: Whether numeric collation should be used, such that "1" < "2" < "10"
// sensitivity: "base": Only strings that differ in base letters compare as unequal. Examples: a ≠ b, a = á, a = A
return a_dname.localeCompare(b_dname, undefined, {
numeric: true,
sensitivity: "base",
})
}
if (a.file && !b.file) {
return 1
} else {
return -1
}
},
}),
),
//Component.TableOfContents(),
],
right: [

View File

@ -16,16 +16,17 @@ export default ((opts?: Optionss) => {
<footer class={`${displayClass ?? ""}`}>
<hr />
<p style="margin-bottom:4px;font-weight:bold;font-size:2em;">
Share your thoughts with <a class="internal" href="/Projects/Obsidian/quartz-comments">Remark42</a>
Share your thoughts with{" "}
<a class="internal" href="/Projects/Obsidian/quartz-comments">
Remark42
</a>
</p>
<div id="remark42"></div>
<hr />
<p>
© be-far {year}. Powered by <a href="https://quartz.jzhao.xyz/">Quartz</a>.
</p>
<p>
not legal advice 🤟
</p>
<p>not legal advice 🤟</p>
<ul>
{Object.entries(links).map(([text, link]) => (
<li>

View File

@ -115,7 +115,7 @@ export default ((opts?: Partial<TagContentOptions>) => {
{pages.length != 0 && (
<p>
{i18n(cfg.locale).pages.tagContent.itemsUnderTag({
count: pages.length
count: pages.length,
})}
</p>
)}

View File

@ -215,12 +215,28 @@ export function renderPage(
const lang = componentData.fileData.frontmatter?.lang ?? cfg.locale?.split("-")[0] ?? "en"
const doc = (
<html lang={lang}>
<Head {...componentData}/>
<Head {...componentData} />
<head>
{ slug === "index" ?
<link rel="alternate" type="application/rss+xml" href="/index.xml" title="Newest in Projects & Privacy"/>: <></>}
{ slug === "index" ?
<link rel="alternate" type="application/rss+xml" href="/Updates.xml" title="Projects & Privacy Monthly"/>: <></>}
{slug === "index" ? (
<link
rel="alternate"
type="application/rss+xml"
href="/index.xml"
title="Newest in Projects & Privacy"
/>
) : (
<></>
)}
{slug === "index" ? (
<link
rel="alternate"
type="application/rss+xml"
href="/Updates.xml"
title="Projects & Privacy Monthly"
/>
) : (
<></>
)}
</head>
<body data-slug={slug}>
<div id="quartz-root" class="page">
@ -234,11 +250,8 @@ export function renderPage(
))}
</Header>
<div class="popover-hint">
{ slug !== "index" &&
beforeBody.map((BodyComponent) =>
(<BodyComponent {...componentData} />)
)
}
{slug !== "index" &&
beforeBody.map((BodyComponent) => <BodyComponent {...componentData} />)}
</div>
</div>
<Content {...componentData} />

View File

@ -85,9 +85,9 @@ function generateRSSFeed(cfg: GlobalConfiguration, idx: ContentIndex, limit?: nu
<channel>
<title>${escapeHTML(cfg.pageTitle)}</title>
<link>${base}</link>
<description>${!!limit ? `Last ${limit} notes` : "Recent notes"} on ${
escapeHTML(cfg.pageTitle)
}</description>
<description>${!!limit ? `Last ${limit} notes` : "Recent notes"} on ${escapeHTML(
cfg.pageTitle,
)}</description>
<generator>Quartz -- quartz.jzhao.xyz</generator>
${items}
</channel>
@ -120,7 +120,12 @@ export const ContentIndex: QuartzEmitterPlugin<Partial<Options>> = (opts) => {
},
async emit(ctx, content, _resources) {
// If we're missing an index file, don't bother with sitemap/RSS gen
if (!(opts?.bypassIndexCheck || content.map((c) => c[1].data.slug!).includes("index" as FullSlug))) {
if (
!(
opts?.bypassIndexCheck ||
content.map((c) => c[1].data.slug!).includes("index" as FullSlug)
)
) {
console.warn(
chalk.yellow(`Warning: contentIndex:
content/ folder is missing an index.md. RSS feeds and sitemap will not be generated.

View File

@ -10,7 +10,7 @@ interface Options {
components?: Array<String>
max_shown_comments?: number
max_last_comments?: number
theme?: 'light' | 'dark'
theme?: "light" | "dark"
page_title?: string // Don't use this, it'll break your comment database. It's included for the sake of completeness.
locale?: string // Technically an enum, full list at https://remark42.com/docs/configuration/frontend/#locales
show_email_subscription?: boolean
@ -38,8 +38,8 @@ export const Remark42: QuartzTransformerPlugin<Options> = (opts?: Options) => {
// Put the embeddable components into window scope
function getComment(e: Array<String>) {
for (var o = 0; o < e.length; o++) {
var src = opts?.host + '/web/' + e[o] + '.js'
scripts.push({ src: src, loadTime: "afterDOMReady", contentType: "external", })
var src = opts?.host + "/web/" + e[o] + ".js"
scripts.push({ src: src, loadTime: "afterDOMReady", contentType: "external" })
}
}
getComment(opts?.components || ["embed"])
@ -62,7 +62,6 @@ export const Remark42: QuartzTransformerPlugin<Options> = (opts?: Options) => {
`
scripts.push({ script: spaRouting, loadTime: "afterDOMReady", contentType: "inline" })
// @plodibre: Listen for theme changes and sync r42 if it changes
const buttonListener: string = `
document.querySelector('#darkmode-toggle').addEventListener('click', (_e) => {
@ -82,9 +81,8 @@ export const Remark42: QuartzTransformerPlugin<Options> = (opts?: Options) => {
css: [
// base css
],
js: scripts
js: scripts,
}
},
}
}

View File

@ -2,7 +2,7 @@
@font-face {
font-family: "Monaspace Neon";
src: url('/static/fonts/heading-font.otf') format('opentype');
src: url("/static/fonts/heading-font.otf") format("opentype");
font-weight: normal;
font-style: normal;
font-display: swap;
@ -10,7 +10,7 @@
@font-face {
font-family: "Monaspace Argon";
src: url('/static/fonts/main-font.otf') format('opentype');
src: url("/static/fonts/main-font.otf") format("opentype");
font-weight: normal;
font-style: normal;
font-display: swap;
@ -112,7 +112,6 @@ footer > p {
margin-right: 8px;
}
ul {
margin-top: 2px;
padding-top: 0px;