-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Features - Add first blog post - Add blog/posts pages - Add tags/categories pages - Add posts to home page - Add rss - Add open-graph generator - Enable smooth scroll Changes - Update release workflow - Bump versions to `v3` - Replace deploy step - Update dependencies - Remove swup animations - Only show two projects instead of four on homepage Fixes - Fix canonical url
- Loading branch information
Showing
90 changed files
with
6,962 additions
and
558 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"name": "@lucjosin/remark-alert-blocks", | ||
"version": "1.0.0", | ||
"type": "module", | ||
"author": { | ||
"name": "Lucas Josino", | ||
"username": "LucJosin", | ||
"email": "contact@lucasjosino.com", | ||
"url": "https://lucasjosino.com" | ||
}, | ||
"publishConfig": { | ||
"access": "public", | ||
"registry": "https://registry.npmjs.org" | ||
}, | ||
"homepage": "https://github.com/LucJosin/lucasjosino.com", | ||
"bugs": { | ||
"url": "https://github.com/LucJosin/lucasjosino.com", | ||
"email": "hawapi@lucasjosino.com" | ||
}, | ||
"license": "MIT", | ||
"keywords": [ | ||
"remark-plugin", | ||
"remark-alerts" | ||
], | ||
"main": "src/index.js", | ||
"dependencies": { | ||
"hastscript": "^8.0.0", | ||
"unist-util-is": "^6.0.0", | ||
"unist-util-visit": "^5.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { is } from 'unist-util-is'; | ||
import { visit } from 'unist-util-visit'; | ||
|
||
const alerts = { | ||
'!!!info': 'info', | ||
'!!!note': 'note', | ||
'!!!tip': 'tip', | ||
'!!!issue': 'issue', | ||
'!!!success': 'success', | ||
'!!!solution': 'solution', | ||
'!!!check': 'check', | ||
'!!!complete': 'complete', | ||
'!!!warning': 'warning', | ||
'!!!error': 'error', | ||
'!!!danger': 'danger', | ||
}; | ||
|
||
const INFO_REGEX = '!!!(?:.*?)(?:\\{(.*?)(?:#(.*))?\\})?\\s(.*)'; | ||
|
||
export default function remarkAlertBlocks() { | ||
return function transformer(tree) { | ||
visit(tree, 'paragraph', (paragraphNode, _, parent) => { | ||
visit(paragraphNode, 'text', (textNode) => { | ||
for (const alert in alerts) { | ||
if (textNode.value.startsWith(alert)) { | ||
const data = textNode.value.match(INFO_REGEX); | ||
|
||
const id = data[1]; | ||
const className = data[2]; | ||
const text = data[3]; | ||
|
||
textNode.value = text; | ||
parent.children = parent.children.map((node) => { | ||
if (is(paragraphNode, node)) { | ||
return { | ||
type: 'wrapper', | ||
children: [node], | ||
data: { | ||
hName: 'div', | ||
hProperties: { | ||
id, | ||
className: [ | ||
'remark-alerts', | ||
`remark-alert-${alerts[alert]}`, | ||
className, | ||
], | ||
}, | ||
}, | ||
}; | ||
} | ||
|
||
return node; | ||
}); | ||
} | ||
} | ||
}); | ||
}); | ||
}; | ||
} |
Oops, something went wrong.