website: initial ooknet website commit
This commit is contained in:
		
							parent
							
								
									97be7a19c6
								
							
						
					
					
						commit
						a9280b78cd
					
				
					 55 changed files with 2424 additions and 2 deletions
				
			
		
							
								
								
									
										53
									
								
								outputs/pkgs/website/src/static/callouts.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								outputs/pkgs/website/src/static/callouts.js
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,53 @@ | |||
| function processCallouts() { | ||||
|   console.log("Processing callouts"); | ||||
|   const content = document.querySelector(".content"); | ||||
|   if (content) { | ||||
|     const blockquotes = content.querySelectorAll("blockquote"); | ||||
|     blockquotes.forEach((blockquote) => { | ||||
|       const firstParagraph = blockquote.querySelector("p"); | ||||
|       if (firstParagraph && firstParagraph.textContent.startsWith("[!")) { | ||||
|         const match = firstParagraph.textContent.match(/\[!(\w+)\]/); | ||||
|         if (match) { | ||||
|           const type = match[1].toLowerCase(); | ||||
|           console.log(`Matched callout: ${type}`); | ||||
| 
 | ||||
|           // remove the [!type] from the first paragraph
 | ||||
|           firstParagraph.textContent = firstParagraph.textContent.replace( | ||||
|             /\[!\w+\]\s*/, | ||||
|             "", | ||||
|           ); | ||||
| 
 | ||||
|           // create the callout structure
 | ||||
|           const callout = document.createElement("div"); | ||||
|           callout.className = `callout callout--${type}`; | ||||
| 
 | ||||
|           const title = document.createElement("div"); | ||||
|           title.className = "callout__title"; | ||||
| 
 | ||||
|           const icon = document.createElement("span"); | ||||
|           icon.className = `icon icon--medium icon__${type}`; | ||||
| 
 | ||||
|           const titleText = document.createElement("span"); | ||||
|           titleText.textContent = type.charAt(0).toUpperCase() + type.slice(1); | ||||
| 
 | ||||
|           title.appendChild(icon); | ||||
|           title.appendChild(titleText); | ||||
| 
 | ||||
|           callout.appendChild(title); | ||||
| 
 | ||||
|           // move blockquote contents to the callout
 | ||||
|           callout.appendChild(title); | ||||
|           while (blockquote.firstChild) { | ||||
|             callout.appendChild(blockquote.firstChild); | ||||
|           } | ||||
| 
 | ||||
|           // replace the blockquote with the callout
 | ||||
|           blockquote.parentNode.replaceChild(callout, blockquote); | ||||
|         } | ||||
|       } | ||||
|     }); | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| document.addEventListener("DOMContentLoaded", processCallouts); | ||||
| window.addEventListener("load", processCallouts); | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue