-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c689953
commit 38e5bd2
Showing
5 changed files
with
85 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,8 @@ import { default as hljs } from "https://esm.sh/[email protected]/lib/language | |
import { default as hlmd } from "https://esm.sh/[email protected]/lib/languages/markdown" | ||
import { default as hlsh } from "https://esm.sh/[email protected]/lib/languages/diff" | ||
import { DOMParser } from "https://deno.land/x/[email protected]/deno-dom-wasm.ts" | ||
import { gzipSize } from "https://deno.land/x/[email protected]/mod.ts" | ||
import { css } from "./css.ts" | ||
syntax.registerLanguage("xml", hlxml) | ||
syntax.registerLanguage("css", hlcss) | ||
syntax.registerLanguage("lisp", hllisp) | ||
|
@@ -69,6 +71,12 @@ export async function html() { | |
} | ||
}) | ||
document.querySelector("aside > nav")!.innerHTML = `<ul>${nav.join("")}</ul>` | ||
// Compute gzip size | ||
const size = document.querySelector("[data-matcha-size]") ? gzipSize(await css()) : NaN | ||
Array.from(document.querySelectorAll("[data-matcha-size]")).forEach((_element) => { | ||
const element = _element as unknown as HTMLElement | ||
element.innerText = `~${new Intl.NumberFormat("en-US", { style: "unit", unit: "kilobyte", unitDisplay: "narrow", maximumSignificantDigits: 3 }).format(size / 1000)}` | ||
}) | ||
return `<!DOCTYPE html>${document.documentElement!.outerHTML}` | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.