mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-07 23:16:52 +00:00
Merge pull request #702 from expoli/dev
[update] 添加代码行号显示控制,取消行号显示可以将代码进行左右滑动,默认关闭行号
This commit is contained in:
@@ -43,6 +43,7 @@ const BLOG = {
|
|||||||
|
|
||||||
// PrismJs CDN
|
// PrismJs CDN
|
||||||
PRISM_JS_PATH: 'https://npm.elemecdn.com/prismjs@1.29.0/components/',
|
PRISM_JS_PATH: 'https://npm.elemecdn.com/prismjs@1.29.0/components/',
|
||||||
|
CODE_LINE_NUMBERS: process.env.NEXT_PUBLIC_CODE_LINE_NUMBERS || 'false',
|
||||||
|
|
||||||
BACKGROUND_LIGHT: '#eeeeee', // use hex value, don't forget '#' e.g #fffefc
|
BACKGROUND_LIGHT: '#eeeeee', // use hex value, don't forget '#' e.g #fffefc
|
||||||
BACKGROUND_DARK: '#000000', // use hex value, don't forget '#'
|
BACKGROUND_DARK: '#000000', // use hex value, don't forget '#'
|
||||||
|
|||||||
@@ -73,16 +73,17 @@ function renderPrismMac() {
|
|||||||
const container = document?.getElementById('container-inner')
|
const container = document?.getElementById('container-inner')
|
||||||
|
|
||||||
// Add line numbers
|
// Add line numbers
|
||||||
const codeBlocks = container?.getElementsByTagName('pre')
|
if (BLOG.CODE_LINE_NUMBERS === 'true') {
|
||||||
if (codeBlocks) {
|
const codeBlocks = container?.getElementsByTagName('pre')
|
||||||
Array.from(codeBlocks).forEach(item => {
|
if (codeBlocks) {
|
||||||
if (!item.classList.contains('line-numbers')) {
|
Array.from(codeBlocks).forEach(item => {
|
||||||
item.classList.add('line-numbers')
|
if (!item.classList.contains('line-numbers')) {
|
||||||
item.style.whiteSpace = 'pre-wrap'
|
item.classList.add('line-numbers')
|
||||||
}
|
item.style.whiteSpace = 'pre-wrap'
|
||||||
})
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 重新渲染之前检查所有的多余text
|
// 重新渲染之前检查所有的多余text
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user