mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-24 13:24:05 -06:00
Removed data-slug requirement for non-preview images
This commit is contained in:
parent
435e6cf899
commit
6cc665d8db
@ -77,10 +77,6 @@ const OptimizeImages: Plugin<[Options], HtmlRoot> = (opts: Options) => {
|
|||||||
if (isAbsoluteURL(src)) return // Skip External images
|
if (isAbsoluteURL(src)) return // Skip External images
|
||||||
const ext = getFileExtension(src)
|
const ext = getFileExtension(src)
|
||||||
if (!ext || !supportedImageExts.has(ext)) return
|
if (!ext || !supportedImageExts.has(ext)) return
|
||||||
// `data-slug` is set by the OFM markdown transformer.
|
|
||||||
// This is the absolute file path compared to `src`, which can be relative.
|
|
||||||
const fullSlug = node.properties["dataSlug"] as FullSlug
|
|
||||||
if (!fullSlug) return
|
|
||||||
|
|
||||||
const width =
|
const width =
|
||||||
node.properties.width && node.properties.width !== "auto"
|
node.properties.width && node.properties.width !== "auto"
|
||||||
@ -100,6 +96,11 @@ const OptimizeImages: Plugin<[Options], HtmlRoot> = (opts: Options) => {
|
|||||||
|
|
||||||
// Replace original image source with preview image if custom dimension is defined
|
// Replace original image source with preview image if custom dimension is defined
|
||||||
if (width || height) {
|
if (width || height) {
|
||||||
|
// `data-slug` is set by the OFM markdown transformer.
|
||||||
|
// This is the absolute file path compared to `src`, which can be relative.
|
||||||
|
const fullSlug = node.properties["dataSlug"] as FullSlug
|
||||||
|
if (!fullSlug) return
|
||||||
|
|
||||||
node.properties.src = src.replace(
|
node.properties.src = src.replace(
|
||||||
new RegExp(`(?:${ext}|${targetOptimizedImageExt})$`),
|
new RegExp(`(?:${ext}|${targetOptimizedImageExt})$`),
|
||||||
`-preview${shouldOptimizeImage ? targetOptimizedImageExt : ext}`,
|
`-preview${shouldOptimizeImage ? targetOptimizedImageExt : ext}`,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user