embedCode関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
The text that puts a body in a page, for one way of making the page. Each way is built, parsed or run by the package's tests: the plain HTML one with a script tag from jsDelivr, an ES module, a React component,
a Vue single-file component, an Angular standalone component, a Svelte component, and an iframe of the demo's embed.html.
インポート
import { embedCode } from "@johnmorrisdotca/wakusei-planets";
定義
function embedCode(options: EmbedOptions, kind?: EmbedKind, settings?: EmbedSettings): string
引数
| 名前 | 型 | 説明 |
|---|---|---|
options | EmbedOptions | The body, its look, the date, the moons, the turn and the size. |
kind (省略可) | "html" | "iframe" | "module" | "react" | "vue" | "angular" | "svelte" | The way the page is made; |
settings (省略可) | EmbedSettings | The CDN and the demo's address, when they are not the package's own. |
戻り値
string
The text to paste into the page's source.
例
import { embedCode } from "@johnmorrisdotca/wakusei-planets";
console.log(embedCode({ body: "jupiter", look: "realistic", time: "now", moons: true }, "react"));import { useEffect } from "react";
export function Planet() {
useEffect(() => {
// The element needs a browser, so it is imported in an effect, never at the top of the file.
void import("@johnmorrisdotca/wakusei-planets/element");
void import("@johnmorrisdotca/wakusei-planets/jupiter");
}, []);
return <wakusei-body body="jupiter" look="realistic" time="now" moons />;
}出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。