From 8cd249cd2ad9f701f1ab85527ee18fa701b8a95f Mon Sep 17 00:00:00 2001 From: gaiety Date: Sun, 8 Mar 2026 21:52:33 -0600 Subject: [PATCH] Config quartz --- .gitignore | 1 + action.sh | 106 +++++++++++++++++++++++++++++++++ mise.toml | 2 + quartz.config.ts | 8 ++- quartz/components/Explorer.tsx | 2 +- quartz/styles/custom.scss | 26 ++++++++ quartz/styles/custom.scssr | 3 + 7 files changed, 144 insertions(+), 4 deletions(-) create mode 100644 action.sh create mode 100644 mise.toml create mode 100644 quartz/styles/custom.scssr diff --git a/.gitignore b/.gitignore index 25d07db..aa67a39 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ prof tsconfig.tsbuildinfo .obsidian .quartz-cache +quartz-themes/.git private/ .replit replit.nix diff --git a/action.sh b/action.sh new file mode 100644 index 0000000..b2d5a55 --- /dev/null +++ b/action.sh @@ -0,0 +1,106 @@ +#!/bin/bash + +# Only print echos +set +x + +# To fetch and use this script in a GitHub action: +# +# curl -s -S https://raw.githubusercontent.com/saberzero1/quartz-themes/master/action.sh | bash -s -- + +RED='\033[0;31m' +YELLOW='\033[1;33m' +GREEN='\033[0;32m' +BLUE='\033[1;34m' +NC='\033[0m' + +echo_err() { echo -e "${RED}$1${NC}"; } +echo_warn() { echo -e "${YELLOW}$1${NC}"; } +echo_ok() { echo -e "${GREEN}$1${NC}"; } +echo_info() { echo -e "${BLUE}$1${NC}"; } + +THEME_DIR="themes" +QUARTZ_STYLES_DIR="quartz/styles" +FINAL_THEME_DIR="./$QUARTZ_STYLES_DIR/$THEME_DIR" + +if [ -f "./$QUARTZ_STYLES_DIR/custom.scss" ]; then + echo_ok "Quartz root succesfully detected..." + FINAL_THEME_DIR="./$QUARTZ_STYLES_DIR/$THEME_DIR" +else + echo_warn "Quartz root not detected, checking if we are in the styles directory..." + if [ -f "./custom.scss" ]; then + echo_ok "Styles directory detected..." + FINAL_THEME_DIR="./$THEME_DIR" + else + echo_err "Cannot detect Quartz repository. Are you in the correct working directory?" 1>&2 + exit 1 + fi +fi + +echo -e "Input theme: ${BLUE}$*${NC}" + +echo "Parsing input theme..." + +# Concat parameters +result="" + +for param in "$@"; do + if [[ -n "$result" ]]; then + result="$result-" + fi + + result="$result$param" +done + +if [ -z "$result" ]; then + echo_warn "No theme provided, defaulting to Tokyo Night..." + result="tokyo-night" +fi + +# Convert to lowercase +THEME=$(echo "$result" | tr '[:upper:]' '[:lower:]') + +echo -e "Theme ${BLUE}$*${NC} parsed to $(echo_info ${THEME})" + +echo "Validating theme..." + +echo "Cleaning theme directory..." + +rm -rf ${FINAL_THEME_DIR} + +echo "Creating theme directory..." + +mkdir -p ${FINAL_THEME_DIR} + +echo "Fetching theme files..." + +# clone only the specified theme using sparse checkout to save bandwidth and time +git clone -n --depth=1 --filter=tree:0 https://github.com/saberzero1/quartz-themes.git &> /dev/null +git -C quartz-themes sparse-checkout set --no-cone /themes/${THEME} &> /dev/null +git -C quartz-themes checkout &> /dev/null + +echo "Installing theme files..." + +mv quartz-themes/themes/${THEME}/* ${FINAL_THEME_DIR} +rm -rf quartz-themes + +echo "Applying patches..." + +if grep -q -e "quartz themes dark-only" -e "quartz themes light-only" "$FINAL_THEME_DIR/_index.scss"; then + echo_warn "Single mode theme detected, applying patch..." + sed -i "/Component\.Darkmode\(\)/d" "quartz.layout.ts" +fi + +echo "Verifying setup..." + +cd ${FINAL_THEME_DIR} + +if grep -q '^@use "./themes";' "../custom.scss"; then + # Import already present in custom.scss + echo_warn "Theme import line already present in custom.scss. Skipping..." +else + # Add `@use "./themes";` import to custom.scss + sed -ir 's#@use "./base.scss";#@use "./base.scss";\n@use "./themes";#' "../custom.scss" + echo_info "Added import line to custom.scss..." +fi + +echo_ok "Finished fetching and applying theme '${THEME}'." \ No newline at end of file diff --git a/mise.toml b/mise.toml new file mode 100644 index 0000000..59a67ac --- /dev/null +++ b/mise.toml @@ -0,0 +1,2 @@ +[tools] +node = "latest" diff --git a/quartz.config.ts b/quartz.config.ts index b3db3d6..43d3696 100644 --- a/quartz.config.ts +++ b/quartz.config.ts @@ -8,7 +8,7 @@ import * as Plugin from "./quartz/plugins" */ const config: QuartzConfig = { configuration: { - pageTitle: "Quartz 4", + pageTitle: "Dauntless", pageTitleSuffix: "", enableSPA: true, enablePopovers: true, @@ -16,7 +16,7 @@ const config: QuartzConfig = { provider: "plausible", }, locale: "en-US", - baseUrl: "quartz.jzhao.xyz", + baseUrl: "dauntless.basking.monster", ignorePatterns: ["private", "templates", ".obsidian"], defaultDateType: "modified", theme: { @@ -78,7 +78,9 @@ const config: QuartzConfig = { Plugin.AliasRedirects(), Plugin.ComponentResources(), Plugin.ContentPage(), - Plugin.FolderPage(), + Plugin.FolderPage({ + showFolderCount: false, + }), Plugin.TagPage(), Plugin.ContentIndex({ enableSiteMap: true, diff --git a/quartz/components/Explorer.tsx b/quartz/components/Explorer.tsx index e4cbcab..1e834f3 100644 --- a/quartz/components/Explorer.tsx +++ b/quartz/components/Explorer.tsx @@ -103,7 +103,7 @@ export default ((userOpts?: Partial) => { data-mobile={false} aria-expanded={true} > -

{opts.title ?? i18n(cfg.locale).components.explorer.title}

+

{opts.title ?? i18n(cfg.locale).components.explorer.title}