Skip to content

Commit 0ff8df8

Browse files
committed
Simplify Mermaid approach with direct div method
- Remove complex JavaScript code conversion - Add inline script to Albatross post for direct rendering - Simplify test page with direct div elements - Use unpkg CDN for more reliable loading - Focus on working solution over complex automation
1 parent 2a2f308 commit 0ff8df8

3 files changed

Lines changed: 50 additions & 70 deletions

File tree

_includes/head-custom.html

Lines changed: 6 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -20,57 +20,12 @@
2020
.mermaid {
2121
text-align: center;
2222
margin: 1rem 0;
23+
background: white;
24+
border: 1px solid #e1e4e8;
25+
border-radius: 6px;
26+
padding: 16px;
2327
}
2428
</style>
2529

26-
<!-- Mermaid.js for diagram rendering -->
27-
<script src="https://cdn.jsdelivr.net/npm/mermaid@10.6.1/dist/mermaid.min.js"></script>
28-
<script>
29-
// Simple and reliable Mermaid initialization
30-
window.addEventListener('load', function() {
31-
if (typeof mermaid !== 'undefined') {
32-
// Configure mermaid
33-
mermaid.initialize({
34-
startOnLoad: true,
35-
theme: 'default',
36-
themeVariables: {
37-
primaryColor: '#ff4757',
38-
primaryTextColor: '#fff',
39-
primaryBorderColor: '#ff3742',
40-
lineColor: '#5f27cd',
41-
secondaryColor: '#f1f2f6',
42-
tertiaryColor: '#ffffff'
43-
}
44-
});
45-
46-
// Find and convert code blocks
47-
const codeBlocks = document.querySelectorAll('pre code.language-mermaid');
48-
if (codeBlocks.length > 0) {
49-
console.log('Found ' + codeBlocks.length + ' mermaid code blocks');
50-
51-
codeBlocks.forEach(function(codeBlock, index) {
52-
const content = codeBlock.textContent;
53-
const mermaidDiv = document.createElement('div');
54-
mermaidDiv.className = 'mermaid';
55-
mermaidDiv.setAttribute('data-processed', 'false');
56-
mermaidDiv.textContent = content;
57-
58-
// Replace the pre element
59-
const preElement = codeBlock.closest('pre');
60-
if (preElement && preElement.parentNode) {
61-
preElement.parentNode.replaceChild(mermaidDiv, preElement);
62-
console.log('Replaced code block ' + index + ' with mermaid div');
63-
}
64-
});
65-
66-
// Re-initialize mermaid to process new divs
67-
setTimeout(function() {
68-
mermaid.init();
69-
console.log('Mermaid re-initialized');
70-
}, 100);
71-
}
72-
} else {
73-
console.log('Mermaid library not loaded');
74-
}
75-
});
76-
</script>
30+
<!-- Mermaid.js library -->
31+
<script src="https://unpkg.com/mermaid@10.6.1/dist/mermaid.min.js"></script>

mermaid-test.md

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,28 @@ title: Mermaid Test
55

66
# Mermaid Diagram Test
77

8-
This is a test page to verify Mermaid.js integration is working properly.
8+
This page tests Mermaid.js integration.
99

10-
## Method 1: Code Blocks (Automatic Conversion)
11-
12-
```mermaid
10+
<div class="mermaid">
1311
graph TD
1412
A[Start] --> B{Is it working?}
1513
B -->|Yes| C[Great!]
1614
B -->|No| D[Debug it]
1715
D --> B
1816
C --> E[End]
19-
```
20-
21-
## Method 2: Architecture Diagram
17+
</div>
2218

23-
```mermaid
19+
<div class="mermaid">
2420
graph LR
2521
A[Blazor WASM<br/>Client] -->|HMAC Auth| B[Cloudflare<br/>Worker]
2622
B -->|API Key| C[AbuseIPDB<br/>API]
2723
C -->|JSON Data| B
2824
B -->|CORS + JSON| A
29-
```
30-
31-
## Method 3: Include Method (Alternative)
32-
33-
{% include mermaid.html id="test-include" content="
34-
graph TD
35-
A[Jekyll Include] --> B[Mermaid Rendering]
36-
B --> C[Success!]
37-
" %}
25+
</div>
3826

39-
If you can see rendered diagrams above instead of code blocks, Mermaid.js is working correctly!
27+
If you see rendered diagrams above, Mermaid is working!
4028

41-
Check the browser console for debug messages.
29+
<script src="https://unpkg.com/mermaid@10.6.1/dist/mermaid.min.js"></script>
30+
<script>
31+
mermaid.initialize({ startOnLoad: true, theme: 'default' });
32+
</script>

staging/2025-06-10-albatross.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,4 +858,38 @@ Whether you're building your own API proxy or exploring modern web security patt
858858

859859
---
860860

861+
**Albatross** is live at [https://albatross.devnomadic.com](https://albatross.devnomadic.com/) and the source code is available on [GitHub](https://github.com/devnomadic/albatross).
862+
863+
<script src="https://unpkg.com/mermaid@10.6.1/dist/mermaid.min.js"></script>
864+
<script>
865+
document.addEventListener('DOMContentLoaded', function() {
866+
if (typeof mermaid !== 'undefined') {
867+
mermaid.initialize({
868+
startOnLoad: false,
869+
theme: 'default',
870+
securityLevel: 'loose'
871+
});
872+
873+
// Convert mermaid code blocks
874+
const blocks = document.querySelectorAll('pre code.language-mermaid');
875+
blocks.forEach(function(block, i) {
876+
const div = document.createElement('div');
877+
div.className = 'mermaid';
878+
div.style.textAlign = 'center';
879+
div.style.margin = '20px 0';
880+
div.textContent = block.textContent.trim();
881+
882+
const pre = block.closest('pre');
883+
if (pre && pre.parentNode) {
884+
pre.parentNode.replaceChild(div, pre);
885+
}
886+
});
887+
888+
if (blocks.length > 0) {
889+
mermaid.init();
890+
}
891+
}
892+
});
893+
</script>
894+
861895
*Albatross is live at [https://albatross.devnomadic.com](https://albatross.devnomadic.com) and the source code is available on [GitHub](https://github.com/devnomadic/albatross).*

0 commit comments

Comments
 (0)