Merge pull request #508 from tangly1024/release/3.6.0

Release/3.6.0
This commit is contained in:
tangly1024
2022-11-27 14:18:13 +08:00
committed by GitHub
2 changed files with 27 additions and 26 deletions

View File

@@ -51,35 +51,36 @@ function renderPrismMac() {
}
})
}
// Add line numbers
const codeBlocks = container?.getElementsByTagName('pre')
if (codeBlocks) {
Array.from(codeBlocks).forEach(item => {
if (!item.classList.contains('line-numbers')) {
item.classList.add('line-numbers')
item.style.whiteSpace = 'pre-wrap'
}
})
}
setTimeout(() => {
// Add pre-mac element for Mac Style UI
if (codeToolBars) {
Array.from(codeToolBars).forEach(item => {
const existPreMac = item.getElementsByClassName('pre-mac')
if (existPreMac.length < codeToolBars.length) {
const preMac = document.createElement('div')
preMac.classList.add('pre-mac')
preMac.innerHTML = '<span></span><span></span><span></span>'
item?.appendChild(preMac, item)
}
})
}
}, 10)
// 重新渲染之前检查所有的多余text
try {
Prism.highlightAll()
// Add line numbers
const codeBlocks = container?.getElementsByTagName('pre')
if (codeBlocks) {
Array.from(codeBlocks).forEach(item => {
if (!item.classList.contains('line-numbers')) {
item.classList.add('line-numbers')
item.style.whiteSpace = 'pre-wrap'
}
})
}
setTimeout(() => {
// Add pre-mac element for Mac Style UI
if (codeToolBars) {
Array.from(codeToolBars).forEach(item => {
const existPreMac = item.getElementsByClassName('pre-mac')
if (existPreMac.length < codeToolBars.length) {
const preMac = document.createElement('div')
preMac.classList.add('pre-mac')
preMac.innerHTML = '<span></span><span></span><span></span>'
item?.appendChild(preMac, item)
}
})
}
}, 10)
} catch (err) {
console.log('代码渲染', err)
}

View File

@@ -18,7 +18,7 @@ export default function ArticleDetail(props) {
const { locale } = useGlobal()
const date = formatDate(post?.date?.start_date || post?.createdTime, locale.LOCALE)
return (<div id="container" className="max-w-5xl overflow-x-auto flex-grow mx-auto w-screen md:w-full ">
{post?.type && !post?.type.includes('Page') && post?.page_cover && (
{post?.type && !post?.type !== 'Page' && post?.page_cover && (
<div className="w-full relative md:flex-shrink-0 overflow-hidden">
{/* eslint-disable-next-line @next/next/no-img-element */}
<img alt={post.title} src={post?.page_cover} className='object-center w-full' />