Auto-Commit: 2026-10-03 22:51:23
This commit is contained in:
1 parent
13ef5e1d13
commit
7769592d8d
3 files changed
+84
No files matched your search
@@ -14,3 +14,7 @@ test-results
|
||||
playwright-report
|
||||
tests
|
||||
*.md
|
||||
|
||||
test-media
|
||||
|
||||
media
|
||||
@@ -0,0 +1,36 @@
|
||||
const fs = require('fs');
|
||||
let tile = fs.readFileSync('src/components/MediaTile.tsx', 'utf8');
|
||||
|
||||
const regex = /\)\s*:\s*\(\s*\/\* eslint-disable-next-line @next\/next\/no-img-element \*\/\s*<img[\s\S]*?<\/div>\s*\)\s*}/;
|
||||
|
||||
// Wait, the regex needs to match exactly up to the end of the img block.
|
||||
const regex2 = /\)\s*:\s*\(\s*\/\* eslint-disable-next-line @next\/next\/no-img-element \*\/\s*<img[\s\S]*?\/>\s*\)/;
|
||||
|
||||
const newBlock = `) : isVideo ? (
|
||||
<video
|
||||
src={\`/api/media/\${item.relativePath}?type=preview\`}
|
||||
poster={\`/api/media/\${item.relativePath}?type=poster\`}
|
||||
autoPlay
|
||||
muted
|
||||
loop
|
||||
playsInline
|
||||
onLoadedData={(e) => {
|
||||
const target = e.target as HTMLVideoElement;
|
||||
target.parentElement?.classList.remove('loading-skeleton');
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
/* eslint-disable-next-line @next/next/no-img-element */
|
||||
<img
|
||||
src={\`/api/media/\${item.relativePath}?type=thumb\`}
|
||||
alt={item.filename}
|
||||
loading="lazy"
|
||||
onLoad={(e) => {
|
||||
const target = e.target as HTMLImageElement;
|
||||
target.parentElement?.classList.remove('loading-skeleton');
|
||||
}}
|
||||
/>
|
||||
)`;
|
||||
|
||||
tile = tile.replace(regex2, newBlock);
|
||||
fs.writeFileSync('src/components/MediaTile.tsx', tile, 'utf8');
|
||||
@@ -0,0 +1,44 @@
|
||||
const fs = require('fs');
|
||||
let tile = fs.readFileSync('src/components/MediaTile.tsx', 'utf8');
|
||||
|
||||
const oldRender = `) : (
|
||||
/* eslint-disable-next-line @next/next/no-img-element */
|
||||
<img
|
||||
src={isVideo ? \`/api/media/\${item.relativePath}?type=poster\` : \`/api/media/\${item.relativePath}?type=thumb\`}
|
||||
alt={item.filename}
|
||||
loading="lazy"
|
||||
onLoad={(e) => {
|
||||
const target = e.target as HTMLImageElement;
|
||||
target.parentElement?.classList.remove('loading-skeleton');
|
||||
}}
|
||||
/>
|
||||
)}`;
|
||||
|
||||
const newRender = `) : isVideo ? (
|
||||
<video
|
||||
src={\`/api/media/\${item.relativePath}?type=preview\`}
|
||||
poster={\`/api/media/\${item.relativePath}?type=poster\`}
|
||||
autoPlay
|
||||
muted
|
||||
loop
|
||||
playsInline
|
||||
onLoadedData={(e) => {
|
||||
const target = e.target as HTMLVideoElement;
|
||||
target.parentElement?.classList.remove('loading-skeleton');
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
/* eslint-disable-next-line @next/next/no-img-element */
|
||||
<img
|
||||
src={\`/api/media/\${item.relativePath}?type=thumb\`}
|
||||
alt={item.filename}
|
||||
loading="lazy"
|
||||
onLoad={(e) => {
|
||||
const target = e.target as HTMLImageElement;
|
||||
target.parentElement?.classList.remove('loading-skeleton');
|
||||
}}
|
||||
/>
|
||||
)}`;
|
||||
|
||||
tile = tile.replace(oldRender, newRender);
|
||||
fs.writeFileSync('src/components/MediaTile.tsx', tile, 'utf8');
|
||||
Reference in new issue
Block a user