From ec10af141778005570b5403622e8457ad5a442b2 Mon Sep 17 00:00:00 2001 From: Eli <88557639+lishaduck@users.noreply.github.com> Date: Fri, 1 Mar 2024 13:00:48 -0600 Subject: [PATCH] feat: mathjax I know, I'm ~~a little~~over-opinionated. --- deno.json | 2 ++ src/content/geothermal/environment.mdx | 4 ++-- src/routes/solutions/[category]/[[slug]].tsx | 2 +- src/routes/solutions/[category]/index.tsx | 2 +- tool/compile-mdx.ts | 6 ++++++ 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/deno.json b/deno.json index 041ef1e8..90b32226 100644 --- a/deno.json +++ b/deno.json @@ -34,7 +34,9 @@ "preact": "https://esm.sh/v135/preact@10.19.5", "preact/": "https://esm.sh/v135/preact@10.19.5/", "@mdx-js/mdx": "npm:@mdx-js/mdx@3.0.1", + "rehype-mathjax": "npm:rehype-mathjax@6.0.0", "remark-frontmatter": "npm:remark-frontmatter@5.0.0", + "remark-math": "npm:remark-math@6.0.0", "remark-mdx-frontmatter": "npm:remark-mdx-frontmatter@4.0.0", "remark-preset-lint-consistent": "npm:remark-preset-lint-consistent@5.1.2", "remark-preset-lint-recommended": "npm:remark-preset-lint-recommended@6.1.3", diff --git a/src/content/geothermal/environment.mdx b/src/content/geothermal/environment.mdx index f388b72f..4acf7a9d 100644 --- a/src/content/geothermal/environment.mdx +++ b/src/content/geothermal/environment.mdx @@ -4,8 +4,8 @@ description: When it comes to carbon emissions, geothermal energy is very effici --- When it comes to carbon emissions, geothermal energy is very efficient. -It produces 10 times less CO2 than coal! -But it still isn’t as efficient as solar as it produces roughly 3x more CO2. +It produces 10 times less $$CO_{2}$$ than coal! +But it still isn’t as efficient as solar as it produces roughly 3x more $$CO_{2}$$. Possibly the biggest issue with geothermal though is the land it takes to build the infrastructure. The building of larger plants can often disrupt ecosystems but this effect comes with all types of energy. This effect is mitigated though with smaller systems such as ones installed on houses. diff --git a/src/routes/solutions/[category]/[[slug]].tsx b/src/routes/solutions/[category]/[[slug]].tsx index 7dfec6e7..f7dbd6bb 100644 --- a/src/routes/solutions/[category]/[[slug]].tsx +++ b/src/routes/solutions/[category]/[[slug]].tsx @@ -78,7 +78,7 @@ export default function Solution({ >

{description}

-
+
diff --git a/src/routes/solutions/[category]/index.tsx b/src/routes/solutions/[category]/index.tsx index 0c84d173..870b2055 100644 --- a/src/routes/solutions/[category]/index.tsx +++ b/src/routes/solutions/[category]/index.tsx @@ -131,7 +131,7 @@ export default function Category({ >

{description}

-
+

What is it?

{whatShort}. diff --git a/tool/compile-mdx.ts b/tool/compile-mdx.ts index 278f6b83..6f436398 100644 --- a/tool/compile-mdx.ts +++ b/tool/compile-mdx.ts @@ -6,7 +6,9 @@ import { resolve, } from "$std/path/mod.ts"; import { type CompileOptions, compile } from "@mdx-js/mdx"; +import rehypeMathjax from "rehype-mathjax"; import remarkFrontmatter from "remark-frontmatter"; +import remarkMath, { type Options as MathOptions } from "remark-math"; import remarkMdxFrontmatter from "remark-mdx-frontmatter"; import remarkPresetLintConsistent from "remark-preset-lint-consistent"; import remarkPresetLintRecommended from "remark-preset-lint-recommended"; @@ -151,11 +153,15 @@ const remarkPlugins = [ remarkPresetLintConsistent, // @ts-expect-error: remark-lint it still on Unified 10, but it works fine with Unified 11. remarkPresetLintRecommended, + [remarkMath, { singleDollarTextMath: false } satisfies MathOptions], ] as const satisfies PluggableList; +const rehypePlugins = [rehypeMathjax] as const satisfies PluggableList; + /** MDX compilation options. */ const compileOptions = { jsxImportSource: "preact", + rehypePlugins, // @ts-expect-error: Typescript dislikes current Deno deduping of Unified. remarkPlugins, } as const satisfies CompileOptions;