docs: update canary docs for Fresh 2 (#3108)

There are still some rough edges here and there, but it's in a much
better shape than what we have today.
This commit is contained in:
Marvin Hagemeister
2025-07-18 15:18:38 +02:00
committed by GitHub
parent a66e0df08d
commit a703e79181
29 changed files with 2094 additions and 62 deletions
+16 -1
View File
@@ -6,6 +6,7 @@ import "prismjs/components/prism-diff.js";
import "prismjs/components/prism-json.js";
import "prismjs/components/prism-bash.js";
import "prismjs/components/prism-yaml.js";
import denoJson from "../../deno.json" with { type: "json" };
export { extractYaml as frontMatter } from "@std/front-matter";
@@ -55,7 +56,15 @@ class DefaultRenderer extends Marked.Renderer {
depth,
raw,
}: Marked.Tokens.Heading): string {
const slug = slugger.slug(raw);
let slugInput = tokens.length === 1 && tokens[0].type === "codespan"
? tokens[0].text
: raw;
if (/^\..*\(\)$/.test(slugInput)) {
slugInput = slugInput.slice(1, -2);
}
const slug = slugger.slug(slugInput);
const text = this.parser.parseInline(tokens);
this.headings.push({ id: slug, html: text });
return `<h${depth} id="${slug}"><a class="md-anchor" tabindex="-1" href="#${slug}">${text}<span aria-hidden="true">#</span></a></h${depth}>`;
@@ -76,6 +85,12 @@ class DefaultRenderer extends Marked.Renderer {
}
override code({ lang: info, text }: Marked.Tokens.Code): string {
// For canary only
text = text.replaceAll(
/(@fresh\/init)/g,
`@fresh/init@${denoJson.version}`,
);
// format: tsx
// format: tsx my/file.ts
// format: tsx "This is my title"