feat(nx-dev): show alt text as label below markdown images
This commit is contained in:
parent
999dcfbb0f
commit
a4f07dbb64
@ -53,7 +53,7 @@ iframe[src*='youtube'] {
|
|||||||
aspect-ratio: 16 / 9;
|
aspect-ratio: 16 / 9;
|
||||||
}
|
}
|
||||||
.prose iframe,
|
.prose iframe,
|
||||||
.prose img {
|
.prose img:not(figure img) {
|
||||||
display: block;
|
display: block;
|
||||||
margin: 2rem auto;
|
margin: 2rem auto;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import {
|
|||||||
import { transformImagePath } from './helpers/transform-image-path';
|
import { transformImagePath } from './helpers/transform-image-path';
|
||||||
|
|
||||||
export const getImageSchema = (documentFilePath: string): Schema => ({
|
export const getImageSchema = (documentFilePath: string): Schema => ({
|
||||||
render: 'img',
|
render: 'figure',
|
||||||
attributes: {
|
attributes: {
|
||||||
src: { type: 'String', required: true },
|
src: { type: 'String', required: true },
|
||||||
alt: { type: 'String', required: true },
|
alt: { type: 'String', required: true },
|
||||||
@ -17,11 +17,15 @@ export const getImageSchema = (documentFilePath: string): Schema => ({
|
|||||||
const attributes = node.transformAttributes(config);
|
const attributes = node.transformAttributes(config);
|
||||||
const children = node.transformChildren(config);
|
const children = node.transformChildren(config);
|
||||||
const src = transformImagePath(documentFilePath)(attributes['src']);
|
const src = transformImagePath(documentFilePath)(attributes['src']);
|
||||||
|
const alt = attributes['alt'];
|
||||||
|
|
||||||
return new Tag(
|
return new Tag(this.render, { className: 'not-prose my-8 text-center' }, [
|
||||||
this.render,
|
new Tag('img', { src, alt, loading: 'lazy', className: 'mx-auto !my-0' }),
|
||||||
{ ...attributes, src, loading: 'lazy' },
|
new Tag(
|
||||||
children
|
'figcaption',
|
||||||
);
|
{ className: 'mt-2 text-sm text-slate-600 dark:text-slate-400' },
|
||||||
|
[alt]
|
||||||
|
),
|
||||||
|
]);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user