Skip to content

Commit a1d5bf8

Browse files
committed
a bunch of shenanigans to make highlight.js work
1 parent aec887a commit a1d5bf8

6 files changed

Lines changed: 42 additions & 6 deletions

File tree

File renamed without changes.

content/web-badges.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,24 @@ and here's [a list of them, linking to pages on neocities](https://neonaut.neoci
1919
after seeing that i really really wanted to make my own;\
2020
so i did! here it is: [-mutter (sorry if its low effort i made it in 2 minutes with aseprite)]
2121

22-
[![evie's pages: blog](/resources/badge.png)](https://evie.is-a.dev)
22+
[![evie's pages: blog](/badge.png)](https://evie.is-a.dev)
2323

24-
i DO wanna make a better one some day.\
24+
[-mutter (edit)] of course the badge would be useless without an embed code so here they are:
25+
- html:
26+
```html
27+
<a href="{origin}">
28+
<img
29+
alt="evie's pages: blog"
30+
src="{origin}/badge.png"
31+
>
32+
</a>
33+
```
34+
- markdown:
35+
```md
36+
[![evie's pages: blog]({origin}/badge.png)]({origin})
37+
```
38+
39+
i DO wanna make a better one some day.\
2540
[-mutter maybe tomorrow,\
2641
maybe never.\
2742
we'll see...]

index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
<link rel="stylesheet" href="/src/styles.css">
77
<meta name="color-scheme" content="dark">
88

9+
<!-- external libraries -->
10+
<link rel="stylesheet" href="https://unpkg.com/@highlightjs/cdn-assets@11.11.1/styles/rose-pine.min.css">
11+
912
<!-- google font bs -->
1013
<link rel="preconnect" href="https://fonts.googleapis.com">
1114
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>

src/index.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { marked } from 'https://cdn.jsdelivr.net/npm/marked@17.0.1/lib/marked.esm.js'
1+
import { marked } from 'https://unpkg.com/marked@17.0.1/lib/marked.esm.js'
2+
import hljs from 'https://unpkg.com/@highlightjs/cdn-assets@11.11.1/es/core.min.js'
3+
4+
import hljsXML from 'https://unpkg.com/@highlightjs/cdn-assets@11.11.1/es/languages/xml.min.js'
5+
import hljsMarkdown from 'https://unpkg.com/@highlightjs/cdn-assets@11.11.1/es/languages/markdown.min.js'
6+
7+
hljs.registerLanguage('html', hljsXML)
8+
hljs.registerLanguage('md', hljsMarkdown)
9+
210
import preprocess from '/src/preprocessor.js'
311
import postprocess from '/src/postprocessor.js'
412

@@ -128,4 +136,6 @@ if (changelog)
128136

129137
return line
130138
})
131-
)
139+
)
140+
141+
hljs.highlightAll()

src/preprocessor.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,14 @@ const preprocessors = Object.freeze(
4747
}
4848
},
4949

50+
{
51+
filter: /{origin}/g,
52+
replacer: location.origin
53+
},
54+
5055
{
5156
filter: /{dialogue}/g,
52-
replacer: () =>
53-
`<span blockquote-dialogue></span>`
57+
replacer: '<span blockquote-dialogue></span>'
5458
},
5559

5660
{

src/styles.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,10 @@ a:visited {
409409
content: ')';
410410
}
411411

412+
pre code {
413+
font-size: 14px;
414+
}
415+
412416
code {
413417
font-family: 'JetBrains Mono', monospace;
414418
}

0 commit comments

Comments
 (0)