Skip to content

Commit e8b0cff

Browse files
committed
Tweak styling around markdown contents
- Add external link indicator - Change code block color theme following light/dark switch - Change text selection styles
1 parent 0a320f5 commit e8b0cff

File tree

6 files changed

+73
-26
lines changed

6 files changed

+73
-26
lines changed

astro.config.mjs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
import {defineConfig} from "astro/config";
2-
// import tailwind from "@astrojs/tailwind";
32
import tailwindcss from "@tailwindcss/vite";
4-
53
import mdx from "@astrojs/mdx";
4+
import rehypeExternalLinks from "rehype-external-links";
5+
import {fromHtml} from "hast-util-from-html";
6+
const extBoxSVG = "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='lucide lucide-square-arrow-out-up-right-icon lucide-square-arrow-out-up-right'><path d='M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6'></path><path d='m21 3-9 9'></path><path d='M15 3h6v6'></path></svg>";
67

7-
// https://astro.build/config
88
export default defineConfig({
99
site: "https://arx-ein.github.io",
1010
vite: {
1111
plugins: [tailwindcss()],
1212
},
1313
integrations: [mdx()],
14+
markdown: {
15+
shikiConfig: {themes: {light: "one-light", dark: "houston"}},
16+
rehypePlugins: [[rehypeExternalLinks, {content: fromHtml(extBoxSVG, {fragment: true, space: "svg"})}]],
17+
},
1418
devOptions: {
15-
// port: 3000
19+
port: 4321,
1620
tailwindConfig: "./tailwind.config.mjs",
1721
},
1822
redirects: {

package-lock.json

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"@tailwindcss/vite": "^4.1.18",
2323
"astro": "^5.16.5",
2424
"astro-breadcrumbs": "^3.3.1",
25+
"rehype-external-links": "^3.0.0",
2526
"tailwindcss": "^4.1.18",
2627
"typescript": "^5.9.3"
2728
},

src/content/blog/lorem.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
create: 2024-07-11
3-
update: 2025-08-13
3+
update: 2025-12-13
44
title: "Lorem ipsum"
55
caption: "レイアウトのテスト"
66
description: "プログページの見え方を確認するためのテスト投稿"
@@ -19,9 +19,9 @@ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras orci odio, pulvina
1919
>
2020
> > nested quote
2121
22-
```txt
23-
code block {
24-
indent
22+
```js
23+
const foo = () => {
24+
return;
2525
}
2626
```
2727

src/styles/default.css

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@import "tailwindcss";
22
@plugin "@tailwindcss/typography";
3-
@config '../../tailwind.config.mjs';
3+
@config "./tailwind.config.js";
44
@import "./font.css";
55
@custom-variant dark (&:where(.dark, .dark *));
66

@@ -9,6 +9,7 @@
99
--color-fore-dim: var(--color-zinc-400);
1010
--color-fore-dark: var(--color-zinc-200);
1111
--color-highlight: var(--color-emerald-500);
12+
--color-selection: var(--color-green-200);
1213
--color-heading: var(--color-lime-600);
1314
--color-heading-dark: var(--color-green-500);
1415
--color-link: var(--color-indigo-600);
@@ -30,32 +31,27 @@
3031

3132
@utility color-a {
3233
& a {
33-
@apply text-link dark:text-link-dark
34-
hover:text-link-hover dark:hover:text-link-dark-hover
35-
active:text-link-active
36-
visited:text-link-visited dark:visited:text-link-dark-visited;
34+
@apply text-link dark:text-link-dark hover:text-link-hover dark:hover:text-link-dark-hover
35+
active:text-link-active visited:text-link-visited dark:visited:text-link-dark-visited;
3736
}
3837
}
3938

4039
@utility anchor {
41-
@apply text-link dark:text-link-dark
42-
hover:text-link-hover dark:hover:text-link-dark-hover
43-
active:text-link-active
44-
visited:text-link-visited dark:visited:text-link-dark-visited;
40+
@apply text-link dark:text-link-dark hover:text-link-hover dark:hover:text-link-dark-hover
41+
active:text-link-active visited:text-link-visited dark:visited:text-link-dark-visited;
4542
}
4643

4744
@layer base {
4845
html {
4946
font-family:
50-
-apple-system, BlinkMacSystemFont, "Noto Sans", "Segoe UI", Roboto,
51-
"BIZ UDPGothic", "Hiragino Sans", sans-serif, "Apple Color Emoji",
52-
"Segoe UI Emoji", "Segoe UI Symbol", "Noto Sans Emoji";
47+
-apple-system, BlinkMacSystemFont, "Noto Sans", "Segoe UI", Roboto, "BIZ UDPGothic", "Hiragino Sans", sans-serif,
48+
"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Sans Emoji";
5349
font-size: 16px;
54-
@apply text-zinc-700 dark:text-zinc-300 scroll-smooth;
50+
@apply scroll-smooth text-zinc-700 dark:text-zinc-300;
5551
}
5652

5753
body {
58-
@apply bg-zinc-50 dark:bg-zinc-900 transition-colors;
54+
@apply selection:bg-selection dark:selection:text-fore bg-zinc-50 transition-colors dark:bg-zinc-900;
5955
}
6056

6157
code {
@@ -71,10 +67,22 @@
7167
monospace;
7268
}
7369

70+
.astro-code,
71+
.astro-code span {
72+
@apply transition-colors dark:bg-(--shiki-dark-bg)! dark:text-(--shiki-dark)!;
73+
}
74+
75+
.astro-code {
76+
corner-shape: bevel;
77+
@apply border-fore dark:border-fore-dark motion-safe:hover:border-highlight border;
78+
}
79+
7480
main {
7581
.matter {
76-
@apply max-w-none prose dark:prose-invert prose-zinc prose-hyphae prose-a:anchor prose-pre:text-wrap
77-
prose-headings:leading-none prose-li:leading-none prose-h2:text-2xl prose-h2:mt-6 prose-h2:mb-4;
82+
@apply prose dark:prose-invert prose-zinc prose-hyphae prose-a:anchor prose-pre:text-wrap prose-headings:leading-none prose-li:leading-none prose-h2:text-2xl prose-h2:mt-6 prose-h2:mb-4 max-w-none;
83+
a > span > svg {
84+
@apply inline size-3 align-text-bottom;
85+
}
7886
}
7987
}
8088

@@ -93,7 +101,7 @@
93101

94102
astro-breadcrumbs {
95103
a {
96-
@apply text-emerald-700 hover:text-emerald-500 active:text-lime-500 visited:text-zinc-600
97-
dark:text-emerald-300 dark:hover:text-emerald-200 dark:active:text-green-400 dark:visited:text-zinc-400;
104+
@apply text-emerald-700 visited:text-zinc-600 hover:text-emerald-500 active:text-lime-500
105+
dark:text-emerald-300 dark:visited:text-zinc-400 dark:hover:text-emerald-200 dark:active:text-green-400;
98106
}
99107
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ export default {
1111
"code::after": {
1212
content: "",
1313
},
14+
"pre": {
15+
borderRadius: "0.75rem",
16+
},
1417
},
1518
},
1619
},

0 commit comments

Comments
 (0)