Skip to content

Commit 073c4ef

Browse files
authored
feat: implement dark mode image support in markdown (#129)
1 parent 179e3c6 commit 073c4ef

File tree

7 files changed

+16
-6
lines changed

7 files changed

+16
-6
lines changed

.vitepress/theme/custom.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
html.dark .light-only {
2+
display: none !important;
3+
}
4+
5+
html:not(.dark) .dark-only {
6+
display: none !important;
7+
}

.vitepress/theme/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import Layout from "./Layout.vue";
22
import * as amplitude from "@amplitude/analytics-browser";
3+
import "./custom.css";
34

45
export default {
56
Layout,
67
async enhanceApp() {
7-
if (typeof window !== 'undefined') {
8+
if (typeof window !== "undefined") {
89
const amplitudeApiKey = (import.meta as any).env.VITE_AMPLITUDE_API_KEY;
910
amplitude.init(amplitudeApiKey, { autocapture: true });
1011
}
1112
}
12-
};
13+
};

code/examples/submit-button.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ function SubmitButton() {
4343
예를 들어, 다음 코드에서 파란색은 사용자가 보기 전용 권한(`'viewer'`)을 가지고 있을 때, 빨간색은 일반 사용자일 때 실행되는 코드예요.
4444
동시에 실행되지 않는 코드가 교차되어서 나타나서 코드를 이해할 때 부담을 줘요.
4545

46-
![](../../images/examples/submit-button.png)
46+
![](../../images/examples/submit-button.png){.light-only}
47+
![](../../images/examples/submit-button-dark.png){.dark-only}
4748

4849
## ✏️ 개선해보기
4950

en/code/examples/submit-button.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ As a result, there are too many contexts for the reader to consider at once.
4343
For example, in the following code, the blue parts are executed when the user has read-only permissions (`'viewer'`), while the red parts are executed for regular users.
4444
Intermixed code that doesn't execute simultaneously creates confusion and makes it harder to understand the logic.
4545

46-
![](../../../images/examples/submit-button.png)
46+
![](../../../images/examples/submit-button.png){.light-only}
47+
![](../../../images/examples/submit-button-dark.png){.dark-only}
4748

4849
## ✏️ Work on Improving
4950

565 KB
Loading

images/examples/submit-button.png

-23.8 KB
Loading

ja/code/examples/submit-button.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ function SubmitButton() {
4141

4242
例えば、次のコードで青色の部分はユーザーが閲覧専用権限(`'viewer'`)を持っているときに実行されるコードで、赤色の部分は一般ユーザーの場合に実行されるコードです。同時に実行されないコードが交差して現れるため、コードを理解するのが難しくなってしまっています。
4343

44-
![](../../../images/examples/submit-button.png)
45-
44+
![](../../../images/examples/submit-button.png){.light-only}
45+
![](../../../images/examples/submit-button-dark.png){.dark-only}
4646

4747
## ✏️ リファクタリングしてみる
4848

0 commit comments

Comments
 (0)