figure()
Alt metni olan görselleri <figure> ve <figcaption> elemanları ile sarmalar.
import { figure } from "@unifast/node";İmza
function figure(): UnifastPluginParametreler
Yok.
Kullanım
import { compile, figure } from "@unifast/node";
const md = ``;
const result = compile(md, {
plugins: [figure()],
});
// Görsel, <figcaption> içeren bir <figure> ile sarmalanırÖrnekler
Temel figure sarmalama
Bir görselin alt metni olduğunda, figure() onu bir <figure> elemanıyla sarmalar ve alt metnini içeren bir <figcaption> ekler:
import { compile, figure } from "@unifast/node";
const md = ``;
const result = compile(md, { plugins: [figure()] });
console.log(result.output);
// <figure><img src="landscape.jpg" alt="A beautiful landscape"><figcaption>A beautiful landscape</figcaption></figure>Alt metni olmayan görsel
Alt metni olmayan görseller sarmalanmaz, çünkü görüntülenecek anlamlı bir altyazı yoktur:
import { compile, figure } from "@unifast/node";
const md = ``;
const result = compile(md, { plugins: [figure()] });
console.log(result.output);
// <p><img src="decorative.png" alt=""></p>