diff --git a/package.json b/package.json index 0b0db9b..1dcd618 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "@mdx-js/mdx": "^3.0.1", "@mdx-js/rollup": "^3.0.1", "@rollup/pluginutils": "^5.1.0", + "@solidjs/meta": "^0.29.4", "@solidjs/router": "^0.13.6", "@solidjs/start": "^1.0.2", "@types/mdx": "^2.0.13", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3df5cb4..c16e708 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -17,6 +17,9 @@ importers: '@rollup/pluginutils': specifier: ^5.1.0 version: 5.1.0(rollup@4.18.0) + '@solidjs/meta': + specifier: ^0.29.4 + version: 0.29.4(solid-js@1.8.17) '@solidjs/router': specifier: ^0.13.6 version: 0.13.6(solid-js@1.8.17) @@ -906,6 +909,11 @@ packages: resolution: {integrity: sha512-LtoMMhxAlorcGhmFYI+LhPgbPZCkgP6ra1YL604EeF6U98pLlQ3iWIGMdWSC+vWmPBWBNgmDBAhnAobLROJmwg==} engines: {node: '>=18'} + '@solidjs/meta@0.29.4': + resolution: {integrity: sha512-zdIWBGpR9zGx1p1bzIPqF5Gs+Ks/BH8R6fWhmUa/dcK1L2rUC8BAcZJzNRYBQv74kScf1TSOs0EY//Vd/I0V8g==} + peerDependencies: + solid-js: '>=1.8.4' + '@solidjs/router@0.13.6': resolution: {integrity: sha512-CdpFsBYoiJ/FQ4wZIamj3KEFRkmrYu5sVXM6PouNkmSENta1YJamsm9wa/VjaPmkw2RsnDnO0UvZ705v6EgOXQ==} peerDependencies: @@ -4423,6 +4431,10 @@ snapshots: '@sindresorhus/merge-streams@2.3.0': {} + '@solidjs/meta@0.29.4(solid-js@1.8.17)': + dependencies: + solid-js: 1.8.17 + '@solidjs/router@0.13.6(solid-js@1.8.17)': dependencies: solid-js: 1.8.17 diff --git a/src/components/global.ts b/src/components/global.ts new file mode 100644 index 0000000..3ee8f98 --- /dev/null +++ b/src/components/global.ts @@ -0,0 +1,18 @@ +import { onCleanup, onMount } from "solid-js"; +export function createGlobals() { + onMount(() => { + function tripleClick(evt: MouseEvent) { + if (evt.detail === 3) { + document.body.classList.toggle("light"); + } + } + window.addEventListener("click", tripleClick); + onCleanup(() => window.removeEventListener("click", tripleClick)); + + function hashchange() { + document.querySelector(window.location.hash)?.scrollIntoView(); + } + window.addEventListener("hashchange", hashchange); + onCleanup(() => window.removeEventListener("hashchange", hashchange)); + }); +} diff --git a/src/routes/2022-12-01/reactivity.tsx b/src/routes/2022-12-01/reactivity.tsx index b7c6c17..008c248 100644 --- a/src/routes/2022-12-01/reactivity.tsx +++ b/src/routes/2022-12-01/reactivity.tsx @@ -1,11 +1,15 @@ -import MDXComponent from "~/blogs/reactivity.mdx"; +import { Title } from "@solidjs/meta"; +import { createGlobals } from "~/components/global"; import { createMermaid } from "~/components/mermaid"; +import MDXComponent from "~/blogs/reactivity.mdx"; export default function Page() { createMermaid(); + createGlobals(); return ( <> + Super Charging Fine-Grained Reactive Performance · milomg.dev