feat: update for Deno 2 (#2655)

Co-authored-by: Luca Casonato <hello@lcas.dev>
This commit is contained in:
Marvin Hagemeister
2024-09-30 18:30:30 +02:00
committed by GitHub
co-authored by Luca Casonato
parent b5389f69a3
commit de8f1b0c59
32 changed files with 3836 additions and 3194 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
import Prism from "https://esm.sh/prismjs@1.29.0";
import Prism from "prismjs";
export function CodeBlock(
{ code, lang }: { code: string; lang: "js" | "ts" | "jsx" | "md" | "bash" },
+2 -2
View File
@@ -19,10 +19,10 @@ export default function NavigationBar(
];
const isHome = props.active == "/";
return (
<nav class={"flex " + props.class ?? ""} f-client-nav={false}>
<nav class={"flex " + (props.class ?? "")} f-client-nav={false}>
<ul class="flex items-center gap-x-2 sm:gap-4 mx-4 my-2 sm:my-6 flex-wrap lg:mx-8 2xl:mr-0">
{items.map((item) => (
<li>
<li key={item.name}>
<a
href={item.href}
class={`p-1 sm:p-2 ${
+9 -6
View File
@@ -7,10 +7,9 @@
},
"imports": {
"$ga4": "https://raw.githubusercontent.com/denoland/ga4/main/mod.ts",
"$marked-mangle": "https://esm.sh/marked-mangle@1.1.7",
"@fresh/plugin-tailwind": "../plugin-tailwindcss/src/mod.ts",
"@luca/esbuild-deno-loader": "jsr:@luca/esbuild-deno-loader@^0.10.3",
"@preact/signals": "npm:@preact/signals@^1.2.3",
"@preact/signals": "npm:@preact/signals@^1.3.0",
"@std/crypto": "jsr:@std/crypto",
"@std/datetime": "jsr:@std/datetime@^0.224.0",
"@std/encoding": "jsr:@std/encoding",
@@ -24,15 +23,19 @@
"@std/semver": "jsr:@std/semver@^0.224.0",
"autoprefixer": "npm:autoprefixer@10.4.17",
"cssnano": "npm:cssnano@6.0.3",
"esbuild": "npm:esbuild@0.20.2",
"esbuild-wasm": "npm:esbuild-wasm@0.20.2",
"esbuild": "npm:esbuild@0.23.1",
"esbuild-wasm": "npm:esbuild-wasm@0.23.1",
"fresh": "../src/mod.ts",
"fresh/compat": "../src/compat/mod.ts",
"fresh/dev": "../src/dev/mod.ts",
"fresh/runtime": "../src/runtime/shared.ts",
"github-slugger": "npm:github-slugger@^2.0.0",
"marked": "npm:marked@^14.1.2",
"marked-mangle": "npm:marked-mangle@^1.1.9",
"postcss": "npm:postcss@8.4.35",
"preact": "npm:preact@^10.22.0",
"preact-render-to-string": "npm:preact-render-to-string@^6.4.2",
"preact": "npm:preact@^10.24.0",
"preact-render-to-string": "npm:preact-render-to-string@^6.5.11",
"prismjs": "npm:prismjs@^1.29.0",
"tailwindcss": "npm:tailwindcss@3.4.1",
"tailwindcss/plugin": "npm:/tailwindcss@3.4.1/plugin.js"
},
Generated
+1263 -1354
View File
File diff suppressed because it is too large Load Diff
+2 -1
View File
@@ -15,8 +15,9 @@ export default function CopyArea(props: { code: string }) {
copied.value = true;
} catch (error) {
copied.value = false;
const message = error instanceof Error ? error.message : String(error);
// deno-lint-ignore no-console
console.error((error && error.message) || "Copy failed");
console.error(message || "Copy failed");
}
}
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
google-site-verification: google40caa9e535ae39e9.html
google-site-verification: google40caa9e535ae39e9.html
+9 -2
View File
@@ -756,8 +756,15 @@ ol.nested li:before {
border-top-right-radius: 0 !important;
}
.fenced-code-title {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
"Liberation Mono", "Courier New", monospace;
font-family:
ui-monospace,
SFMono-Regular,
Menlo,
Monaco,
Consolas,
"Liberation Mono",
"Courier New",
monospace;
font-size: 0.8125rem;
line-height: 1;
}
+83 -1
View File
@@ -1,3 +1,85 @@
/* PrismJS 1.29.0
https://prismjs.com/download.html#themes=prism-okaidia&languages=markup+css+clike+javascript */
code[class*=language-],pre[class*=language-]{color:#f8f8f2;background:0 0;text-shadow:0 1px rgba(0,0,0,.3);font-family:Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace;font-size:1em;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}pre[class*=language-]{padding:1em;margin:.5em 0;overflow:auto;border-radius:.3em}:not(pre)>code[class*=language-],pre[class*=language-]{background:#272822}:not(pre)>code[class*=language-]{padding:.1em;border-radius:.3em;white-space:normal}.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#8292a2}.token.punctuation{color:#f8f8f2}.token.namespace{opacity:.7}.token.constant,.token.deleted,.token.property,.token.symbol,.token.tag{color:#f92672}.token.boolean,.token.number{color:#ae81ff}.token.attr-name,.token.builtin,.token.char,.token.inserted,.token.selector,.token.string{color:#a6e22e}.language-css .token.string,.style .token.string,.token.entity,.token.operator,.token.url,.token.variable{color:#f8f8f2}.token.atrule,.token.attr-value,.token.class-name,.token.function{color:#e6db74}.token.keyword{color:#66d9ef}.token.important,.token.regex{color:#fd971f}.token.bold,.token.important{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help}
code[class*="language-"], pre[class*="language-"] {
color: #f8f8f2;
background: 0 0;
text-shadow: 0 1px rgba(0, 0, 0, 0.3);
font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace;
font-size: 1em;
text-align: left;
white-space: pre;
word-spacing: normal;
word-break: normal;
word-wrap: normal;
line-height: 1.5;
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;
-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
hyphens: none;
}
pre[class*="language-"] {
padding: 1em;
margin: 0.5em 0;
overflow: auto;
border-radius: 0.3em;
}
:not(pre) > code[class*="language-"], pre[class*="language-"] {
background: #272822;
}
:not(pre) > code[class*="language-"] {
padding: 0.1em;
border-radius: 0.3em;
white-space: normal;
}
.token.cdata, .token.comment, .token.doctype, .token.prolog {
color: #8292a2;
}
.token.punctuation {
color: #f8f8f2;
}
.token.namespace {
opacity: 0.7;
}
.token.constant, .token.deleted, .token.property, .token.symbol, .token.tag {
color: #f92672;
}
.token.boolean, .token.number {
color: #ae81ff;
}
.token.attr-name,
.token.builtin,
.token.char,
.token.inserted,
.token.selector,
.token.string {
color: #a6e22e;
}
.language-css .token.string,
.style .token.string,
.token.entity,
.token.operator,
.token.url,
.token.variable {
color: #f8f8f2;
}
.token.atrule, .token.attr-value, .token.class-name, .token.function {
color: #e6db74;
}
.token.keyword {
color: #66d9ef;
}
.token.important, .token.regex {
color: #fd971f;
}
.token.bold, .token.important {
font-weight: 700;
}
.token.italic {
font-style: italic;
}
.token.entity {
cursor: help;
}
+13 -2
View File
@@ -19,8 +19,19 @@
}
body {
font-family: Fixel, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
font-family:
Fixel,
system-ui,
-apple-system,
BlinkMacSystemFont,
"Segoe UI",
Roboto,
Oxygen,
Ubuntu,
Cantarell,
"Open Sans",
"Helvetica Neue",
sans-serif;
font-weight: 450;
font-size: 1.125rem;
line-height: 1.5;
+43 -36
View File
@@ -1,17 +1,20 @@
import Prism from "https://esm.sh/prismjs@1.29.0";
import "https://esm.sh/prismjs@1.29.0/components/prism-jsx.js?no-check";
import "https://esm.sh/prismjs@1.29.0/components/prism-typescript.js?no-check";
import "https://esm.sh/prismjs@1.29.0/components/prism-tsx.js?no-check";
import "https://esm.sh/prismjs@1.29.0/components/prism-diff.js?no-check";
import "https://esm.sh/prismjs@1.29.0/components/prism-json.js?no-check";
import "https://esm.sh/prismjs@1.29.0/components/prism-bash.js?no-check";
import "https://esm.sh/prismjs@1.29.0/components/prism-yaml.js?no-check";
import Prism from "prismjs";
import "prismjs/components/prism-jsx.js";
import "prismjs/components/prism-typescript.js";
import "prismjs/components/prism-tsx.js";
import "prismjs/components/prism-diff.js";
import "prismjs/components/prism-json.js";
import "prismjs/components/prism-bash.js";
import "prismjs/components/prism-yaml.js";
export { extractYaml as frontMatter } from "@std/front-matter";
import * as Marked from "https://esm.sh/marked@7.0.2";
import * as Marked from "marked";
import { escape as escapeHtml } from "@std/html";
import { mangle } from "$marked-mangle";
import { mangle } from "marked-mangle";
import GitHubSlugger from "github-slugger";
const slugger = new GitHubSlugger();
Marked.marked.use(mangle());
@@ -25,7 +28,16 @@ export interface MarkdownHeading {
class DefaultRenderer extends Marked.Renderer {
headings: MarkdownHeading[] = [];
text(text: string): string {
override text(
token: Marked.Tokens.Text | Marked.Tokens.Escape | Marked.Tokens.Tag,
): string {
let text = token.text;
if (
token.type === "text" && "tokens" in token && token.tokens !== undefined
) {
text = this.parser.parseInline(token.tokens);
}
// Smartypants typography enhancement
return text
.replaceAll("...", "&#8230;")
@@ -39,37 +51,32 @@ class DefaultRenderer extends Marked.Renderer {
.replaceAll(/['](.*?)[']/g, "&#8216;$1&#8217;");
}
heading(
text: string,
level: 1 | 2 | 3 | 4 | 5 | 6,
raw: string,
slugger: Marked.Slugger,
): string {
override heading({
tokens,
depth,
raw,
}: Marked.Tokens.Heading): string {
const slug = slugger.slug(raw);
const text = this.parser.parseInline(tokens);
this.headings.push({ id: slug, html: text });
return `<h${level} id="${slug}"><a class="md-anchor" tabindex="-1" href="#${slug}">${text}<span aria-hidden="true">#</span></a></h${level}>`;
return `<h${depth} id="${slug}"><a class="md-anchor" tabindex="-1" href="#${slug}">${text}<span aria-hidden="true">#</span></a></h${depth}>`;
}
link(href: string, title: string | null, text: string) {
override link({ href, title, tokens }: Marked.Tokens.Link) {
const text = this.parser.parseInline(tokens);
const titleAttr = title ? ` title="${title}"` : "";
if (href.startsWith("#")) {
return `<a href="${href}"${titleAttr}>${text}</a>`;
}
if (this.options.baseUrl) {
try {
href = new URL(href, this.options.baseUrl).href;
} catch (_) {
//
}
}
return `<a href="${href}"${titleAttr} rel="noopener noreferrer">${text}</a>`;
}
image(src: string, title: string | null, alt: string | null) {
return `<img src="${src}" alt="${alt ?? ""}" title="${title ?? ""}" />`;
override image({ href, text, title }: Marked.Tokens.Image) {
return `<img src="${href}" alt="${text ?? ""}" title="${title ?? ""}" />`;
}
code(code: string, info: string | undefined): string {
override code({ lang: info, text }: Marked.Tokens.Code): string {
// format: tsx
// format: tsx my/file.ts
// format: tsx "This is my title"
@@ -96,9 +103,9 @@ class DefaultRenderer extends Marked.Renderer {
: undefined;
if (grammar === undefined) {
out += `<pre><code class="notranslate">${escapeHtml(code)}</code></pre>`;
out += `<pre><code class="notranslate">${escapeHtml(text)}</code></pre>`;
} else {
const html = Prism.highlight(code, grammar, lang);
const html = Prism.highlight(text, grammar, lang);
out +=
`<pre class="highlight highlight-source-${lang} notranslate lang-${lang}"><code>${html}</code></pre>`;
}
@@ -107,8 +114,8 @@ class DefaultRenderer extends Marked.Renderer {
return out;
}
blockquote(quote: string): string {
const match = quote.match(ADMISSION_REG);
override blockquote({ text }: Marked.Tokens.Blockquote): string {
const match = text.match(ADMISSION_REG);
if (match) {
const label: Record<string, string> = {
tip: "Tip",
@@ -116,13 +123,13 @@ class DefaultRenderer extends Marked.Renderer {
info: "Info",
};
const type = match[1];
quote = quote.slice(match[0].length);
text = text.slice(match[0].length);
const icon = `<svg class="icon"><use href="/icons.svg#${type}" /></svg>`;
return `<blockquote class="admonition ${type}">\n<span class="admonition-header">${icon}${
label[type]
}</span>${quote}</blockquote>\n`;
}</span>${text}</blockquote>\n`;
}
return `<blockquote>\n${quote}</blockquote>\n`;
return `<blockquote>\n${text}</blockquote>\n`;
}
}