diff --git a/packages/frontend/src/components/MkEmbedCodeGenDialog.vue b/packages/frontend/src/components/MkEmbedCodeGenDialog.vue index 2b64fd891b..713e527a3f 100644 --- a/packages/frontend/src/components/MkEmbedCodeGenDialog.vue +++ b/packages/frontend/src/components/MkEmbedCodeGenDialog.vue @@ -124,12 +124,12 @@ function ok() { // 本URL生成用params const paramsForUrl = computed(() => ({ - header: header.value === true ? undefined : header.value, - autoload: autoload.value === false ? undefined : autoload.value, + header: header.value, + autoload: autoload.value, maxHeight: typeof maxHeight.value === 'number' ? Math.max(0, maxHeight.value) : undefined, colorMode: colorMode.value === 'auto' ? undefined : colorMode.value, - rounded: rounded.value === true ? undefined : rounded.value, - border: border.value === true ? undefined : border.value, + rounded: rounded.value, + border: border.value, })); // プレビュー用params(手動で更新を掛けるのでref) @@ -142,7 +142,7 @@ const embedPreviewUrl = computed(() => { const maxHeight = parseInt(paramClass.get('maxHeight')!); paramClass.set('maxHeight', maxHeight === 0 ? '500' : Math.min(maxHeight, 700).toString()); // プレビューであまりにも縮小されると見づらいため、700pxまでに制限 } - return `${url}/embed/${props.entity}/${_idOrUsername}?${paramClass.toString()}`; + return `${url}/embed/${props.entity}/${_idOrUsername}${paramClass.toString() ? '?' + paramClass.toString() : ''}`; }); const isEmbedWithScrollbar = computed(() => embedRouteWithScrollbar.includes(props.entity)); diff --git a/packages/frontend/src/scripts/get-embed-code.ts b/packages/frontend/src/scripts/get-embed-code.ts index 33e0601e12..946c2bc1a8 100644 --- a/packages/frontend/src/scripts/get-embed-code.ts +++ b/packages/frontend/src/scripts/get-embed-code.ts @@ -35,11 +35,22 @@ export type EmbedParams = { header?: boolean; }; +// パラメータのデフォルトの値 +export const defaultEmbedParams: EmbedParams = { + maxHeight: undefined, + colorMode: undefined, + rounded: true, + border: true, + autoload: false, + header: true, +}; + export function normalizeEmbedParams(params: EmbedParams): Record { // paramsのvalueをすべてstringに変換。undefinedやnullはプロパティごと消す const normalizedParams: Record = {}; for (const key in params) { - if (params[key] == null) { + // デフォルトの値と同じならparamsに含めない + if (params[key] == null || params[key] === defaultEmbedParams[key]) { continue; } switch (typeof params[key]) {