embedCode関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
The text of one embed. The module one imports the package; the data one is a data:image/svg+xml address for an <img>.
インポート
import { embedCode } from "@johnmorrisdotca/uchusen-rockets";
定義
function embedCode(options: RocketOptions, kind?: EmbedKind, settings?: EmbedSettings): string
引数
| 名前 | 型 | 説明 |
|---|---|---|
options | RocketOptions | The rocket and how it looks. |
kind (省略可) | "data" | "iframe" | "link" | "svg" | "module" | "element" | Which way to write it. Defaults to the element. |
settings (省略可) | EmbedSettings | Where the demo and the CDN are, if not the package's own. |
戻り値
string
The text to paste into a page. A painted rocket's credit is part of it.
例
import { embedCode } from "@johnmorrisdotca/uchusen-rockets";
console.log(embedCode({ rocket: "falcon-9", variant: "block-5", look: "thick" }));
console.log(embedCode({ rocket: "falcon-9", variant: "block-5" }, "iframe"));<script type="importmap">
{ "imports": { "three": "https://cdn.jsdelivr.net/npm/three@0.186.1/build/three.module.js", "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.186.1/examples/jsm/" } }
</script>
<script type="module" src="https://cdn.jsdelivr.net/npm/@johnmorrisdotca/uchusen-rockets@0/dist/element.js"></script>
<uchusen-rocket
rocket="falcon-9"
variant="block-5"
look="thick"
></uchusen-rocket>
<iframe
src="https://johnmorrisdotca.github.io/uchusen-rockets/embed.html?rocket=falcon-9&variant=block-5"
title="Rocket"
loading="lazy"
style="width:100%;max-width:480px;aspect-ratio:3 / 4;border:0"
></iframe>出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。