Skip to content

Commit

Permalink
Merge pull request #61 from kseki/feature/add-diagrams
Browse files Browse the repository at this point in the history
feat: Mermaid.jsのサポートを追加
  • Loading branch information
kseki authored Aug 21, 2024
2 parents dcf6fe1 + e93140e commit 30b56dd
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1 deletion.
9 changes: 9 additions & 0 deletions assets/scss/custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,12 @@
}
}
}

// For Mermaid diagrams
.article-content {
pre.mermaid {
display: flex;
justify-content: center;
align-items: center;
}
}
2 changes: 1 addition & 1 deletion config/_default/params.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ customText = ""

[dateFormat]
published = "2006-01-02"
lastUpdated = "2006-01-02 15:04 MST"
lastUpdated = "2006-01-02"

[sidebar]
#emoji = "🍥"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ keywords:
- リバースプロキシ
slug:
date: 2024-08-13T16:14:17+09:00
lastmod: 2024-08-21
image: nginx.webp
categories:
- 開発
Expand All @@ -24,6 +25,17 @@ draft: false

複数のプロジェクトを同時に開発する際に、Nginxをリバースプロキシとして使用し、hostsファイルでローカルドメインを設定する方法を紹介します。

```mermaid
graph TD;
A[ブラウザ] -->|http://klog.local| B[Nginx]
A -->|http://admin.hoge.local| B
A -->|http://user.hoge.local| B
B -->|http://localhost:1313| C[klogプロジェクト]
B -->|http://localhost:3000| D[admin.hogeプロジェクト]
B -->|http://localhost:3001| E[user.hogeプロジェクト]
```

## 複数プロジェクト開発の問題

ローカル開発環境では通常、ブラウザに `localhost:ポート番号` を入力してアクセスします。しかし、複数のプロジェクトを開発していると、ブラウザのアドレスバーに `localhost` と入力した際に他のプロジェクトのパスがサジェストされてしまい、煩わしいことがあります。
Expand Down
4 changes: 4 additions & 0 deletions layouts/_default/_markup/render-codeblock-mermaid.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<pre class="mermaid">
{{- .Inner | safeHTML }}
</pre>
{{ .Page.Store.Set "hasMermaid" true }}
7 changes: 7 additions & 0 deletions layouts/partials/footer/custom.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!-- For Mermaid diagrams -->
{{ if .Store.Get "hasMermaid" }}
<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.esm.min.mjs';
mermaid.initialize({startOnLoad: true});
</script>
{{ end }}

0 comments on commit 30b56dd

Please sign in to comment.