;
```
@@ -38,7 +38,7 @@ By default, Fresh adds caching headers for the `src` and `srcset` attributes on
You can always opt out of this behaviour per tag, by adding the
`data-fresh-disable-lock` attribute.
-```jsx
+```tsx
// Opt-out of automatic caching headers
;
```
@@ -48,7 +48,7 @@ You can always opt out of this behaviour per tag, by adding the
Use the `asset()` function to add caching headers manually. It will be served
with a cache lifetime of one year.
-```jsx
+```tsx
import { asset } from "fresh/runtime";
// Adding caching headers manually
diff --git a/docs/latest/concepts/server-configuration.md b/docs/latest/concepts/server-configuration.md
index 7e6a35b8..3b162aa7 100644
--- a/docs/latest/concepts/server-configuration.md
+++ b/docs/latest/concepts/server-configuration.md
@@ -151,7 +151,7 @@ The `basePath` will be automatically applied to absolute links in your app. For
example, when the `basePath` is `/foo/bar`, linking to `/about` will
automatically become `/foo/bar/about`.
-```jsx
+```tsx
About;
```
diff --git a/docs/latest/concepts/static-files.md b/docs/latest/concepts/static-files.md
index b3c96d7a..880de300 100644
--- a/docs/latest/concepts/static-files.md
+++ b/docs/latest/concepts/static-files.md
@@ -29,7 +29,7 @@ version of this path that contains a build ID for cache busting. When the asset
is requested at this "locked" path, it will be served with a cache lifetime of
one year.
-```jsx routes/page.tsx
+```tsx routes/page.tsx
import { asset } from "$fresh/runtime.ts";
export default function Page() {
@@ -46,6 +46,6 @@ and `
;
```
diff --git a/docs/latest/examples/rendering-markdown.md b/docs/latest/examples/rendering-markdown.md
index 1150b579..02d28b37 100644
--- a/docs/latest/examples/rendering-markdown.md
+++ b/docs/latest/examples/rendering-markdown.md
@@ -92,7 +92,7 @@ description: testFromText
You'll also need to import the `Github Flavored Markdown` module:
-```bash
+```sh
deno add jsr:@deno/gfm
```
diff --git a/docs/latest/getting-started/running-locally.md b/docs/latest/getting-started/running-locally.md
index a8299669..9dbedce0 100644
--- a/docs/latest/getting-started/running-locally.md
+++ b/docs/latest/getting-started/running-locally.md
@@ -38,7 +38,7 @@ you add a new route.
If you want to change the port or host, modify the config bag of the `start()`
call in `main.ts` to include an explicit port number:
-```js main.ts
+```ts main.ts
await start(manifest, { server: { port: 3000 } });
```
diff --git a/www/static/logos/css.svg b/www/static/logos/css.svg
new file mode 100644
index 00000000..13691bdb
--- /dev/null
+++ b/www/static/logos/css.svg
@@ -0,0 +1 @@
+
diff --git a/www/static/logos/diff.svg b/www/static/logos/diff.svg
new file mode 100644
index 00000000..7e22809e
--- /dev/null
+++ b/www/static/logos/diff.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/www/static/logos/docker.svg b/www/static/logos/docker.svg
new file mode 100644
index 00000000..98727887
--- /dev/null
+++ b/www/static/logos/docker.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/www/static/logos/git.svg b/www/static/logos/git.svg
new file mode 100644
index 00000000..c5ea394b
--- /dev/null
+++ b/www/static/logos/git.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/www/static/logos/html.svg b/www/static/logos/html.svg
new file mode 100644
index 00000000..a0152d86
--- /dev/null
+++ b/www/static/logos/html.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/www/static/logos/json.svg b/www/static/logos/json.svg
new file mode 100644
index 00000000..26c39ba7
--- /dev/null
+++ b/www/static/logos/json.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/www/static/logos/markdown.svg b/www/static/logos/markdown.svg
new file mode 100644
index 00000000..c5b32a6f
--- /dev/null
+++ b/www/static/logos/markdown.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/www/static/logos/shell.svg b/www/static/logos/shell.svg
new file mode 100644
index 00000000..17d38213
--- /dev/null
+++ b/www/static/logos/shell.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/www/static/logos/text.svg b/www/static/logos/text.svg
new file mode 100644
index 00000000..a5562edd
--- /dev/null
+++ b/www/static/logos/text.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/www/static/markdown.css b/www/static/markdown.css
index 87c953d1..4d30ead0 100644
--- a/www/static/markdown.css
+++ b/www/static/markdown.css
@@ -812,11 +812,20 @@ ol.nested li:before {
border-top-right-radius: 0 !important;
}
.fenced-code-title {
+ display: grid;
font-family:
ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
"Courier New", monospace;
font-size: 0.8125rem;
line-height: 1;
+ grid-auto-flow: column;
+ align-items: center;
+ gap: 0.625rem;
+}
+.fenced-code-title > img {
+ background-color: transparent;
+ margin: -0.2rem 0;
+ width: 1.25rem;
}
.highlight-source-yml .atrule {
diff --git a/www/utils/markdown.ts b/www/utils/markdown.ts
index 2af3367a..e6ee0122 100644
--- a/www/utils/markdown.ts
+++ b/www/utils/markdown.ts
@@ -3,6 +3,7 @@ import denoJson from "../../deno.json" with { type: "json" };
export { extractYaml as frontMatter } from "@std/front-matter";
import * as Marked from "marked";
+import { asset } from "fresh/runtime";
import { escape as escapeHtml } from "@std/html";
import { mangle } from "marked-mangle";
import GitHubSlugger from "github-slugger";
@@ -14,6 +15,69 @@ Marked.marked.use(mangle());
const ADMISSION_REG = /^\[(info|warn|tip)\]:\s/;
+const LOGOS = [
+ {
+ lang: /^tsx?$/,
+ file: /\.tsx?$/,
+ src: asset("/logos/typescript.svg"),
+ text: "Typescript",
+ },
+ {
+ lang: /^css$/,
+ file: /\.css$/,
+ src: asset("/logos/css.svg"),
+ text: "CSS",
+ },
+ {
+ lang: /^html$/,
+ file: /\.html$/,
+ src: asset("/logos/html.svg"),
+ text: "HTML",
+ },
+ {
+ lang: /^jsonc?$/,
+ file: /\.jsonc?$/,
+ src: asset("/logos/json.svg"),
+ text: "JSON",
+ },
+ {
+ lang: /^(sh|bash)$/,
+ file: /\.sh$/,
+ src: asset("/logos/shell.svg"),
+ text: "Terminal (Shell/Bash)",
+ },
+ {
+ lang: /^md$/,
+ file: /\.md$/,
+ src: asset("/logos/markdown.svg"),
+ text: "Markdown",
+ },
+ {
+ lang: /^txt$/,
+ file: /\.txt$/,
+ src: asset("/logos/text.svg"),
+ text: "Text",
+ },
+ {
+ lang: /^diff$/,
+ file: /\.diff$/,
+ src: asset("/logos/diff.svg"),
+ text: "File diff",
+ },
+ {
+ lang: /^gitignore$/,
+ file: /^\.gitignore$/,
+ src: asset("/logos/git.svg"),
+ text: "Git",
+ },
+ {
+ lang: /^dockerfile$/,
+ file: /^Dockerfile$/,
+ src: asset("/logos/docker.svg"),
+ text: "Docker",
+ },
+];
+
export interface MarkdownHeading {
id: string;
html: string;
@@ -95,11 +159,20 @@ class DefaultRenderer extends Marked.Renderer {
title = match[2] ?? "";
}
+ // Find icon by filename first, then by markdown block language.
+ const icon = LOGOS.find((l) => l.file.test(title)) ??
+ LOGOS.find((l) => l.lang.test(lang));
+
let out = `\n${icon}${ label[type] - }${Marked.parser(tokens)}\n`; + }${this.parser.parse(tokens)}\n`; } - return `
\n${Marked.parser(tokens)}\n`; + return `
\n${this.parser.parse(tokens)}\n`; } }