From 83c5fa64eaaa03fe7374715f78a9d7c1dde4e972 Mon Sep 17 00:00:00 2001 From: Jacky Zhao Date: Sun, 2 Jul 2023 13:08:29 -0700 Subject: [PATCH] various polish --- quartz.config.ts | 36 ++++---- quartz/bootstrap-cli.mjs | 2 +- quartz/cfg.ts | 11 +++ quartz/components/ArticleTitle.tsx | 5 +- quartz/components/Footer.tsx | 2 +- quartz/components/Head.tsx | 19 +--- quartz/components/Header.tsx | 1 + quartz/components/PageList.tsx | 5 +- quartz/components/TagList.tsx | 23 ++--- quartz/components/pages/Content.tsx | 4 +- quartz/components/renderPage.tsx | 43 +++++++--- quartz/components/scripts/darkmode.inline.ts | 5 +- quartz/components/scripts/graph.inline.ts | 17 ++-- quartz/components/scripts/plausible.inline.ts | 3 + quartz/components/scripts/popover.inline.ts | 32 +++++-- quartz/components/styles/backlinks.scss | 6 +- quartz/components/styles/footer.scss | 2 + quartz/components/styles/graph.scss | 5 +- quartz/components/styles/listPage.scss | 33 ++++--- quartz/components/styles/popover.scss | 2 +- quartz/components/styles/search.scss | 3 +- quartz/components/types.ts | 2 +- quartz/path.ts | 13 ++- quartz/plugins/emitters/contentIndex.ts | 1 - quartz/plugins/index.ts | 72 ++++++---------- quartz/plugins/transformers/gfm.ts | 5 +- quartz/plugins/transformers/links.ts | 5 +- quartz/processors/emit.ts | 78 ++++++++++++++++- quartz/resources.tsx | 8 +- quartz/styles/base.scss | 86 +++++++++++++------ 30 files changed, 339 insertions(+), 190 deletions(-) create mode 100644 quartz/components/scripts/plausible.inline.ts diff --git a/quartz.config.ts b/quartz.config.ts index f58bc32e..58c1d9cd 100644 --- a/quartz.config.ts +++ b/quartz.config.ts @@ -4,12 +4,7 @@ import * as Plugin from "./quartz/plugins" const sharedPageComponents = { head: Component.Head(), - header: [ - Component.PageTitle(), - Component.Spacer(), - Component.Search(), - Component.Darkmode() - ], + header: [], footer: Component.Footer({ authorName: "Jacky", links: { @@ -25,11 +20,15 @@ const contentPageLayout: PageLayout = { Component.ReadingTime(), Component.TagList(), ], - left: [], + left: [ + Component.PageTitle(), + Component.Search(), + Component.TableOfContents(), + Component.Darkmode() + ], right: [ Component.Graph(), - Component.TableOfContents(), - Component.Backlinks() + Component.Backlinks(), ], } @@ -37,7 +36,11 @@ const listPageLayout: PageLayout = { beforeBody: [ Component.ArticleTitle() ], - left: [], + left: [ + Component.PageTitle(), + Component.Search(), + Component.Darkmode() + ], right: [], } @@ -46,6 +49,9 @@ const config: QuartzConfig = { pageTitle: "🪴 Quartz 4.0", enableSPA: true, enablePopovers: true, + analytics: { + provider: 'plausible', + }, canonicalUrl: "quartz.jzhao.xyz", ignorePatterns: ["private", "templates"], theme: { @@ -102,16 +108,16 @@ const config: QuartzConfig = { ...contentPageLayout, pageBody: Component.Content(), }), - Plugin.TagPage({ - ...sharedPageComponents, - ...listPageLayout, - pageBody: Component.TagContent(), - }), Plugin.FolderPage({ ...sharedPageComponents, ...listPageLayout, pageBody: Component.FolderContent(), }), + Plugin.TagPage({ + ...sharedPageComponents, + ...listPageLayout, + pageBody: Component.TagContent(), + }), Plugin.ContentIndex({ enableSiteMap: true, enableRSS: true, diff --git a/quartz/bootstrap-cli.mjs b/quartz/bootstrap-cli.mjs index 2824f8e9..3f71b177 100755 --- a/quartz/bootstrap-cli.mjs +++ b/quartz/bootstrap-cli.mjs @@ -64,7 +64,7 @@ yargs(hideBin(process.argv)) packages: "external", plugins: [ sassPlugin({ - type: 'css-text' + type: 'css-text', }), { name: 'inline-script-loader', diff --git a/quartz/cfg.ts b/quartz/cfg.ts index 1c9ece8f..49698ab5 100644 --- a/quartz/cfg.ts +++ b/quartz/cfg.ts @@ -2,12 +2,23 @@ import { QuartzComponent } from "./components/types" import { PluginTypes } from "./plugins/types" import { Theme } from "./theme" +export type Analytics = null + | { + provider: 'plausible' + } + | { + provider: 'google', + tagId: string + } + export interface GlobalConfiguration { pageTitle: string, /** Whether to enable single-page-app style rendering. this prevents flashes of unstyled content and improves smoothness of Quartz */ enableSPA: boolean, /** Whether to display Wikipedia-style popovers when hovering over links */ enablePopovers: boolean, + /** Analytics mode */ + analytics: Analytics /** Glob patterns to not search */ ignorePatterns: string[], /** Base URL to use for CNAME files, sitemaps, and RSS feeds that require an absolute URL. diff --git a/quartz/components/ArticleTitle.tsx b/quartz/components/ArticleTitle.tsx index c25769e2..b8d58c6b 100644 --- a/quartz/components/ArticleTitle.tsx +++ b/quartz/components/ArticleTitle.tsx @@ -2,9 +2,8 @@ import { QuartzComponentConstructor, QuartzComponentProps } from "./types" function ArticleTitle({ fileData }: QuartzComponentProps) { const title = fileData.frontmatter?.title - const displayTitle = fileData.slug === "index" ? undefined : title - if (displayTitle) { - return

{displayTitle}

+ if (title) { + return

{title}

} else { return null } diff --git a/quartz/components/Footer.tsx b/quartz/components/Footer.tsx index 4229f9d2..5fc6d64c 100644 --- a/quartz/components/Footer.tsx +++ b/quartz/components/Footer.tsx @@ -14,7 +14,7 @@ export default ((opts?: Options) => { return <>