Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复 checkbox, radio, gitlab 标签 bug;使 fold 标签支持 markdown 内容;使 note 标签在深色模式下可以正常阅读 #3

Merged
merged 4 commits into from
Sep 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,11 @@ export function pTag([cls, text]: str2) {
*/
export function foldTag([title, open]: str2, content) {
_fold = true;
return htmlTag('details', {open}, htmlTag('summary', {}, title, false) + content, false);
// @ts-ignore
return htmlTag('details', { open }, htmlTag('summary', {}, title, false) + hexo.render.renderSync({
text: content,
engine: 'markdown'
}).trim(), false);
}

/**
Expand Down Expand Up @@ -271,11 +275,11 @@ export function checkboxTag([style, checked, content]: str3 | str2) {
content = checked;
checked = 'checked';
}
return htmlTag('div', {class: 'checkbox'}, htmlTag('input', {
type: 'checkbox',
checked,
style
}, content, false), false);
return htmlTag('div', {class: 'checkbox ' + style},
`<input type="checkbox" ${ checked==='unchecked' ? '' : `checked=${checked}` }/>${
// @ts-ignore
hexo.render.renderSync({text: content, engine: 'markdown'}).split('\n').join('')
}`, false);
}

/**
Expand All @@ -290,11 +294,11 @@ export function radioTag([style, checked, content]: str3 | str2) {
content = checked;
checked = 'checked';
}
return htmlTag('div', {class: 'checkbox'}, htmlTag('input', {
type: 'radio',
checked,
style
}, content, false), false);
return htmlTag('div', {class: 'checkbox ' + style},
`<input type="radio" ${ checked==='unchecked' ? '' : `checked=${checked}` }/>${
// @ts-ignore
hexo.render.renderSync({text: content, engine: 'markdown'}).split('\n').join('')
}`, false);
}

/**
Expand All @@ -312,7 +316,7 @@ export function noteTag([cls, icon]: str2 | string, content: string) {
cls += ' no-icon';
}
// @ts-ignore
return htmlTag('div', {class: `note ${cls}`}, (icon ? htmlTag('i', {class: `solitude ${icon}`}, '', false) : '') + hexo.render.renderSync({
return htmlTag('div', {class: `note ${cls} modern`}, (icon ? htmlTag('i', {class: `solitude ${icon}`}, '', false) : '') + hexo.render.renderSync({
text: content,
engine: 'markdown'
}).trim(), false);
Expand Down Expand Up @@ -432,7 +436,7 @@ export function gitlabTag([repo]: str) {
</div>
<img class='lang-${id} repo-language no-lightbox' />
<script>
fetch('https://gitlab.com/api/v4/projects/${repo}')
fetch('https://gitlab.com/api/v4/projects/${encodeURIComponent(repo)}')
.then(res => res.json())
.then(data => {
document.querySelector('.name-${id}').innerText = data.name;
Expand Down