From 0d87cea96f99bc4c9d33b54f7610e9873cb24a1d Mon Sep 17 00:00:00 2001 From: Leni Aniva Date: Tue, 5 Nov 2024 11:37:04 -0800 Subject: [PATCH 1/3] feat: Add more icons --- src/routes/+page.svelte | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 88d8cd3..5ce6685 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -19,15 +19,22 @@ import metadata from '$content/metadata.json'; const iconMap: Map = { - "bitbucket": "fa-brands fa-bitbucket", + "orcid": "fa-brands fa-orcid", + "google-scholar": "fa-brands fa-google-scholar", + "discord": "fa-brands fa-discord", "email": "fa-solid fa-envelope", + + "bitbucket": "fa-brands fa-bitbucket", "github": "fa-brands fa-github", "gitlab": "fa-brands fa-gitlab", - "google-scholar": "fa-brands fa-google-scholar", - "instagram": "fa-brands fa-instagram", "open-source": "fa-brands fa-osi", - "orcid": "fa-brands fa-orcid", + + "bluesky": "fa-brands fa-bluesky", + "youtube": "fa-brands fa-youtube", + "instagram": "fa-brands fa-instagram", + "bandcamp": "fa-brands fa-bandcamp", + "pixiv": "fa-brands fa-pixiv", }; const iconLinks: [string, string][] = Object.entries(metadata.links).map( ([key, link]) => [iconMap[key], link]); -- 2.44.1 From 7b900c2993e1d3fd871299a9ef1d2c6f982e80bb Mon Sep 17 00:00:00 2001 From: Leni Aniva Date: Tue, 5 Nov 2024 11:50:00 -0800 Subject: [PATCH 2/3] feat: Read highlighter languages from metadata --- src/content/metadata.json | 9 ++++++++- src/content/post/the-perfect-math-class.md | 4 ++++ svelte.config.js | 15 +++++++++------ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/content/metadata.json b/src/content/metadata.json index fe4b596..258fb4b 100644 --- a/src/content/metadata.json +++ b/src/content/metadata.json @@ -12,5 +12,12 @@ }, "extra": [ { "route": "/archives", "name": "Archives" } - ] + ], + "markdown": { + "highlighterLangs": [ + "python", + "lean", + "tex" + ] + } } diff --git a/src/content/post/the-perfect-math-class.md b/src/content/post/the-perfect-math-class.md index ce1e00e..d016784 100644 --- a/src/content/post/the-perfect-math-class.md +++ b/src/content/post/the-perfect-math-class.md @@ -26,3 +26,7 @@ $$ $$ \vec z^{(l+1)} = \mat M\vec z^{(l)} + \vec b $$ + +```tex +\\newcommand{\\cirno}{9} +``` diff --git a/svelte.config.js b/svelte.config.js index deabdb8..7fcd4df 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -1,5 +1,6 @@ import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'; import adapter from '@sveltejs/adapter-static'; +import fs from 'fs'; import { mdsvex, escapeSvelte } from 'mdsvex'; import remarkAlert from './src/lib/markdown.js' @@ -12,7 +13,9 @@ import remarkMath from 'remark-math' const contentDir = process.env?.CHRYSOBLOG_CONTENT ?? "src/content"; -const langs = [ +const metadata = await fs.promises.readFile(contentDir + "/metadata.json") + .then((file) => JSON.parse(file.toString())); +const langs = metadata?.markdown.highlighterLangs ?? [ "javascript", "lean", "lisp", @@ -26,11 +29,7 @@ const langs = [ "c++", "sh", ]; -const highlightingThemes = { - light: 'vitesse-light', - dark: 'vitesse-dark', -}; -const katexOptions = { +const katexOptions = metadata?.markdown.katex ?? { macros: { "\\Nat": "\\mathbb N", "\\Complex": "\\mathbb C", @@ -39,6 +38,10 @@ const katexOptions = { "\\rv": "\\mathrm", }, }; +const highlightingThemes = { + light: 'vitesse-light', + dark: 'vitesse-dark', +}; const themes = Object.keys(highlightingThemes).map(function(k){ return highlightingThemes[k] }); const highlighter = await getHighlighter({ -- 2.44.1 From 5dbb8e7a8c0d6c87ca037e3acf97121670611fbe Mon Sep 17 00:00:00 2001 From: Leni Aniva Date: Tue, 5 Nov 2024 11:55:27 -0800 Subject: [PATCH 3/3] doc: Documentation about metadata.json --- .pre-commit-config.yaml | 2 +- README.md | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3e6b0fa..aafa64d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,7 +11,7 @@ repos: hooks: - id: conventional-pre-commit stages: [commit-msg] - args: [feat, fix, chore, test, build, merge, refactor] + args: [feat, fix, chore, test, build, merge, refactor, doc] - repo: local hooks: - id: eslint diff --git a/README.md b/README.md index 7cc754f..53b403e 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,18 @@ To insert custom content, create a directory with a similar structure to directory. The website will be built statically in `build/`. Note that changing `favicon.svg` will require modifying the `static/` folder. +Set `metadata.json` based on the example to have a custom avatar and background +image. +- `name`: Displayed name on the home page +- `blogName`: Displayed name of the blog +- `url`: The site url +- `frontDescription`: The text above the main navbar +- `frontCover`: Path to the cover image +- `picture`: Avatar +- `links`: A map of brands to links +- `extra`: Extra pages showing on the navbar +- `markdown`: `{ "highlighterLangs": [ ... ], "katex": [ ... ] }` + ## Developing Install [pre-commit](https://pre-commit.com/). -- 2.44.1