mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-19 19:04:06 -06:00
Merge 9ffd33f76c into bacd19c4ea
This commit is contained in:
commit
f4e38378e7
@ -72,6 +72,7 @@ const config: QuartzConfig = {
|
|||||||
Plugin.CrawlLinks({ markdownLinkResolution: "shortest" }),
|
Plugin.CrawlLinks({ markdownLinkResolution: "shortest" }),
|
||||||
Plugin.Description(),
|
Plugin.Description(),
|
||||||
Plugin.Latex({ renderEngine: "katex" }),
|
Plugin.Latex({ renderEngine: "katex" }),
|
||||||
|
Plugin.ViewImage(),
|
||||||
],
|
],
|
||||||
filters: [Plugin.RemoveDrafts()],
|
filters: [Plugin.RemoveDrafts()],
|
||||||
emitters: [
|
emitters: [
|
||||||
|
|||||||
@ -11,3 +11,4 @@ export { SyntaxHighlighting } from "./syntax"
|
|||||||
export { TableOfContents } from "./toc"
|
export { TableOfContents } from "./toc"
|
||||||
export { HardLineBreaks } from "./linebreaks"
|
export { HardLineBreaks } from "./linebreaks"
|
||||||
export { RoamFlavoredMarkdown } from "./roam"
|
export { RoamFlavoredMarkdown } from "./roam"
|
||||||
|
export { ViewImage } from "./viewImage"
|
||||||
|
|||||||
47
quartz/plugins/transformers/viewImage.ts
Normal file
47
quartz/plugins/transformers/viewImage.ts
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
import { QuartzTransformerPlugin } from "../types"
|
||||||
|
|
||||||
|
// ViewImage.js灯箱插件
|
||||||
|
// 简化版实现
|
||||||
|
export const ViewImage: QuartzTransformerPlugin = () => {
|
||||||
|
return {
|
||||||
|
name: "ViewImage",
|
||||||
|
externalResources() {
|
||||||
|
return {
|
||||||
|
js: [
|
||||||
|
{
|
||||||
|
src: "https://cdn.jsdelivr.net/gh/Tokinx/ViewImage/view-image.min.js",
|
||||||
|
loadTime: "afterDOMReady",
|
||||||
|
contentType: "external",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
script: `
|
||||||
|
// 简单的初始化代码
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
if (window.ViewImage) {
|
||||||
|
// 使用更通用的选择器
|
||||||
|
ViewImage.init('article img, .content img');
|
||||||
|
// 添加视觉反馈
|
||||||
|
const style = document.createElement('style');
|
||||||
|
style.textContent = 'article img, .content img { cursor: zoom-in; border: 2px dashed #284b63; }';
|
||||||
|
document.head.appendChild(style);
|
||||||
|
console.log('ViewImage灯箱插件已初始化');
|
||||||
|
} else {
|
||||||
|
console.error('ViewImage库未加载成功');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
`,
|
||||||
|
loadTime: "afterDOMReady",
|
||||||
|
contentType: "inline",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 告诉TypeScript我们添加的内容
|
||||||
|
declare module "vfile" {
|
||||||
|
interface DataMap {
|
||||||
|
viewImage?: boolean
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user