mirror of
https://github.com/d0zingcat/BroadcastChannel.git
synced 2026-05-20 23:16:48 +00:00
Merge branch 'dev'
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -23,6 +23,6 @@ pnpm-debug.log*
|
||||
# jetbrains setting folder
|
||||
.idea/
|
||||
|
||||
.vercel/
|
||||
.netlify/
|
||||
.vercel
|
||||
.netlify
|
||||
.wrangler
|
||||
|
||||
@@ -21,8 +21,11 @@
|
||||
"astro-seo": "^0.8.4",
|
||||
"cheerio": "1.0.0-rc.12",
|
||||
"dayjs": "^1.11.12",
|
||||
"flourite": "^1.3.0",
|
||||
"lru-cache": "^11.0.0",
|
||||
"ofetch": "^1.3.4",
|
||||
"prismjs": "^1.29.0",
|
||||
"prismjs-components-importer": "^0.2.0",
|
||||
"sanitize-html": "^2.13.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -31,6 +34,7 @@
|
||||
"@astrojs/netlify": "^5.4.0",
|
||||
"@astrojs/node": "^8.3.2",
|
||||
"@astrojs/vercel": "^7.7.2",
|
||||
"@types/prismjs": "^1.26.4",
|
||||
"astro-eslint-parser": "^1.0.2",
|
||||
"autoprefixer": "^10.4.20",
|
||||
"cssnano": "^7.0.4",
|
||||
|
||||
32
pnpm-lock.yaml
generated
32
pnpm-lock.yaml
generated
@@ -26,12 +26,21 @@ importers:
|
||||
dayjs:
|
||||
specifier: ^1.11.12
|
||||
version: 1.11.12
|
||||
flourite:
|
||||
specifier: ^1.3.0
|
||||
version: 1.3.0
|
||||
lru-cache:
|
||||
specifier: ^11.0.0
|
||||
version: 11.0.0
|
||||
ofetch:
|
||||
specifier: ^1.3.4
|
||||
version: 1.3.4
|
||||
prismjs:
|
||||
specifier: ^1.29.0
|
||||
version: 1.29.0
|
||||
prismjs-components-importer:
|
||||
specifier: ^0.2.0
|
||||
version: 0.2.0(prismjs@1.29.0)
|
||||
sanitize-html:
|
||||
specifier: ^2.13.0
|
||||
version: 2.13.0
|
||||
@@ -51,6 +60,9 @@ importers:
|
||||
'@astrojs/vercel':
|
||||
specifier: ^7.7.2
|
||||
version: 7.7.2(astro@4.12.3(@types/node@22.0.0)(typescript@5.5.4))
|
||||
'@types/prismjs':
|
||||
specifier: ^1.26.4
|
||||
version: 1.26.4
|
||||
astro-eslint-parser:
|
||||
specifier: ^1.0.2
|
||||
version: 1.0.2(typescript@5.5.4)
|
||||
@@ -1647,6 +1659,9 @@ packages:
|
||||
'@types/pg@8.6.1':
|
||||
resolution: {integrity: sha1-CZRQuNyXfoGXpE9SKc7e+VyHR/k=}
|
||||
|
||||
'@types/prismjs@1.26.4':
|
||||
resolution: {integrity: sha512-rlAnzkW2sZOjbqZ743IHUhFcvzaGbqijwOu8QZnZCjfQzBqFE3s4lOTJEsxikImav9uzz/42I+O7YUs1mWgMlg==}
|
||||
|
||||
'@types/shimmer@1.2.0':
|
||||
resolution: {integrity: sha512-UE7oxhQLLd9gub6JKIAhDq06T0F6FnztwMNRvYgjeQSBeMc1ZG/tA47EwfduvkuQS8apbkM/lpLpWsaCeYsXVg==}
|
||||
|
||||
@@ -2739,6 +2754,10 @@ packages:
|
||||
resolution: {integrity: sha512-9UbaD6XdAL97+k/n+N7JwX46K/M6Zc6KcFYskrYL8wbBV/Uyk0CTAMY0VT+qiK5PM7AIc9aTWYtq65U7T+aCNQ==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
flourite@1.3.0:
|
||||
resolution: {integrity: sha512-iuhWXuX07QwHMnJ1Irh4sD1bk/QFMHg8jVgWsjSAqoIqgIyJtRPnUNKyZAPXrw7pQkDvxb5AIz2KPihEoyVcqw==}
|
||||
engines: {node: '>=16'}
|
||||
|
||||
fraction.js@4.3.7:
|
||||
resolution: {integrity: sha512-ZsDfxO51wGAXREY55a7la9LScWpwv9RxIrYABrlvOFBlH/ShPnrtsXeuUIfXKKOVicNxQ+o8JTbJvjS4M89yew==}
|
||||
|
||||
@@ -3909,6 +3928,11 @@ packages:
|
||||
printable-characters@1.0.42:
|
||||
resolution: {integrity: sha512-dKp+C4iXWK4vVYZmYSd0KBH5F/h1HoZRsbJ82AVKRO3PEo8L4lBS/vLwhVtpwwuYcoIsVY+1JYKR268yn480uQ==}
|
||||
|
||||
prismjs-components-importer@0.2.0:
|
||||
resolution: {integrity: sha512-2WJBqocATZOOoApIH9y6QmZG7dkQsX9BKexbW6LjMZ9QBAxoDsmoAKTzOt3g9xgpTQVEydmkS4I4tSlguJ52Kg==}
|
||||
peerDependencies:
|
||||
prismjs: 1.28.0
|
||||
|
||||
prismjs@1.29.0:
|
||||
resolution: {integrity: sha512-Kx/1w86q/epKcmte75LNrEoT+lX8pBpavuAbvJWRXar7Hz8jrtF+e3vY751p0R8H9HdArwaCTNDDzHg/ScJK1Q==}
|
||||
engines: {node: '>=6'}
|
||||
@@ -6246,6 +6270,8 @@ snapshots:
|
||||
pg-protocol: 1.6.1
|
||||
pg-types: 2.2.0
|
||||
|
||||
'@types/prismjs@1.26.4': {}
|
||||
|
||||
'@types/shimmer@1.2.0': {}
|
||||
|
||||
'@types/unist@2.0.10': {}
|
||||
@@ -7668,6 +7694,8 @@ snapshots:
|
||||
|
||||
flattie@1.1.1: {}
|
||||
|
||||
flourite@1.3.0: {}
|
||||
|
||||
fraction.js@4.3.7: {}
|
||||
|
||||
fresh@0.5.2: {}
|
||||
@@ -9030,6 +9058,10 @@ snapshots:
|
||||
|
||||
printable-characters@1.0.42: {}
|
||||
|
||||
prismjs-components-importer@0.2.0(prismjs@1.29.0):
|
||||
dependencies:
|
||||
prismjs: 1.29.0
|
||||
|
||||
prismjs@1.29.0: {}
|
||||
|
||||
progress@2.0.3: {}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
import '../assets/item.css'
|
||||
import 'prismjs/themes/prism.css'
|
||||
import dayjs from '../lib/dayjs'
|
||||
import { getEnv } from '../lib/env'
|
||||
|
||||
|
||||
29
src/lib/prism.js
Normal file
29
src/lib/prism.js
Normal file
@@ -0,0 +1,29 @@
|
||||
import prism from 'prismjs'
|
||||
|
||||
import 'prismjs-components-importer/cjs/prism-c'
|
||||
import 'prismjs-components-importer/cjs/prism-clojure'
|
||||
import 'prismjs-components-importer/cjs/prism-cpp'
|
||||
import 'prismjs-components-importer/cjs/prism-csharp'
|
||||
import 'prismjs-components-importer/cjs/prism-css'
|
||||
import 'prismjs-components-importer/cjs/prism-dart'
|
||||
import 'prismjs-components-importer/cjs/prism-docker'
|
||||
import 'prismjs-components-importer/cjs/prism-elixir'
|
||||
import 'prismjs-components-importer/cjs/prism-go'
|
||||
import 'prismjs-components-importer/cjs/prism-markup'
|
||||
import 'prismjs-components-importer/cjs/prism-java'
|
||||
import 'prismjs-components-importer/cjs/prism-javascript'
|
||||
import 'prismjs-components-importer/cjs/prism-json'
|
||||
import 'prismjs-components-importer/cjs/prism-julia'
|
||||
import 'prismjs-components-importer/cjs/prism-kotlin'
|
||||
import 'prismjs-components-importer/cjs/prism-lua'
|
||||
import 'prismjs-components-importer/cjs/prism-markdown'
|
||||
import 'prismjs-components-importer/cjs/prism-pascal'
|
||||
import 'prismjs-components-importer/cjs/prism-php'
|
||||
import 'prismjs-components-importer/cjs/prism-python'
|
||||
import 'prismjs-components-importer/cjs/prism-ruby'
|
||||
import 'prismjs-components-importer/cjs/prism-rust'
|
||||
import 'prismjs-components-importer/cjs/prism-sql'
|
||||
import 'prismjs-components-importer/cjs/prism-typescript'
|
||||
import 'prismjs-components-importer/cjs/prism-yaml'
|
||||
|
||||
export default prism
|
||||
@@ -1,6 +1,8 @@
|
||||
import { $fetch } from 'ofetch'
|
||||
import * as cheerio from 'cheerio'
|
||||
import { LRUCache } from 'lru-cache'
|
||||
import flourite from 'flourite'
|
||||
import prism from '../prism'
|
||||
import { getEnv } from '../env'
|
||||
|
||||
const cache = new LRUCache({
|
||||
@@ -108,6 +110,17 @@ function modifyHTMLContent($, content, { index } = {}) {
|
||||
?.wrap('<label class="spoiler-button"></label>')
|
||||
?.before(`<input type="checkbox" />`)
|
||||
})
|
||||
$(content).find('pre').each((_index, pre) => {
|
||||
try {
|
||||
const code = $(pre).text()
|
||||
const language = flourite(code, { shiki: true })?.language
|
||||
const highlightedCode = prism.highlight(code, prism.languages[language], language)
|
||||
$(pre).html(`<code class="language-${language}">${highlightedCode}</code>`)
|
||||
}
|
||||
catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
})
|
||||
return content
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user