From 793bc52f198bb14142bc981d867bb90978cbc59b Mon Sep 17 00:00:00 2001 From: ccbikai Date: Sun, 11 Aug 2024 10:14:03 +0800 Subject: [PATCH] feat: enhance code highlighting with flourite Integrate flourite for improved language detection in code blocks, replacing manual detection logic. This enhances accuracy and supports a broader range of languages for syntax highlighting. Additionally, streamline CSS inclusion for code highlighting by importing directly from the package, reducing reliance on external CDN. --- package.json | 1 + pnpm-lock.yaml | 12 ++++++++++++ src/components/item.astro | 1 + src/layouts/base.astro | 4 ---- src/lib/telegram/index.js | 36 ++++++++++++------------------------ 5 files changed, 26 insertions(+), 28 deletions(-) diff --git a/package.json b/package.json index 1153891..f1de8f7 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fff0b33..1b3a3a1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -26,12 +26,18 @@ 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 sanitize-html: specifier: ^2.13.0 version: 2.13.0 @@ -2739,6 +2745,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==} @@ -7668,6 +7678,8 @@ snapshots: flattie@1.1.1: {} + flourite@1.3.0: {} + fraction.js@4.3.7: {} fresh@0.5.2: {} diff --git a/src/components/item.astro b/src/components/item.astro index bb49ece..f7bd399 100644 --- a/src/components/item.astro +++ b/src/components/item.astro @@ -1,5 +1,6 @@ --- import '../assets/item.css' +import 'prismjs/themes/prism.css' import dayjs from '../lib/dayjs' import { getEnv } from '../lib/env' diff --git a/src/layouts/base.astro b/src/layouts/base.astro index cd0fdc1..f434601 100644 --- a/src/layouts/base.astro +++ b/src/layouts/base.astro @@ -57,10 +57,6 @@ const FOOTER_INJECT = getEnv(import.meta.env, Astro, 'FOOTER_INJECT') title={channel?.title} href={origin + '/rss.xml'} /> -