アイキャッチ画像をカスタマイズできるようになったらしいので遊んでみる

はてなインターン 2024 でアイキャッチ画像カスタマイズが開発されたらしいので試してみる。

staff.hatenablog.com

どう?自分のブログに合うように作ってみたけど反映されてる??

2024/9/6 追記

正しく反映されていそう!!とりあえずアイキャッチのHTML公開します。商用利用可でご自由にお使いください。

<!DOCTYPE html>
<html lang="{BlogLanguage}">
  <!-- ここで BlogLanguage を指定すると言語を指定することができます -->
  <!-- 言語に適した改行の処理に影響があるため指定を推奨します -->
  <head>
    <meta charset="utf-8">
    <style>
      :root{
        --bg-main: #ffffff;
        --bg-secondary: #ffffff;
        --text-main: #1f1f1f;
        --text-back: #ffffff;
        --content-rounded: 15px;
      }
      * {
        margin: 0;
        padding: 0;
      }
      body {
        background-color: var(--bg-secondary);
        color: var(--text-main);
        font-weight: normal;
        font-family: 'Noto Sans CJK JP';
        line-height: 1.4;
        height: calc(100vh - 70px);
        padding: 35px 35px;
      }

      .body-inner {
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        word-break: break-word;

        height: 100%;

        box-shadow: 0px 1px 26px -3px #a0acc0;
        border-radius: var(--content-rounded);
      }

      /* カテゴリによるカスタマイズ */
      /* 後述の通り、変数を使ってカテゴリのclassを付与すると
      カテゴリごとにデザインをカスタマイズすることができます */
      body.category-日記 {
        background-color: #fff;
      }

      /* コンテンツ部分の共通設定 */
      body > div {
        background-color: var(--bg-main);
      }

      .footer-margin {
        height: 56px; /* Xのシェア時には、アイキャッチの下部に
        タイトル要素が重ねて表示されるため空白を用意しておくことを推奨します */
      }

      /* ヘッダの設定 */
      .header {
        width: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
        padding-top: 18px;
      }
      .header > :first-child {
        margin-left: 24px;
      }
      .header > :last-child {
        margin-right: 24px;
      }
      .header .base {
        display: flex;
        flex-direction: row;
        align-items: center;
      }
      .icon > svg, .icon > img {
        border-radius: 50%;
        width: 64px;
        margin-right: 12px;
      }
      .blog-title {
        max-width: 60%;
      }
      .blog-title .title {
        font-size: 48px;
        font-weight: bold;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        color: transparent;

        background: linear-gradient(128deg, #17c9c9 0%, #336cff 100%);
        background-clip: text;
        -webkit-background-clip: text;
      }
      .spacer {
        flex-grow: 1;
      }
      .category {
        display: flex;
        justify-content: center;
        gap: 15px;
        max-width: 25%;
      }
      .category span {
        display: block;
        box-sizing: border-box;
        padding: 2px 12px;
        border-radius: 8px;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        font-size: 30px;
        line-height: 1.3;
        font-weight: bold;
        color: #fff;

        background: linear-gradient(128deg, rgba(238, 34, 51, 0.8666666667) 0%, #EC44BD 100%);
      }

      /* メインコンテンツの設定 */
      .main-wrapper {
        flex: 1;
        width: 100%;
        display:flex;
      }
      .main {
        width: 75%;
        display: flex;
        flex-direction: column;
        justify-content: center;
        margin: 20px auto 8px;
        overflow: hidden;
        text-align: center;
      }
      .entry-title {
        display: -webkit-box;
        -webkit-line-clamp: 4; /* 行数の上限 */
        line-clamp: 4;
        -webkit-box-orient: vertical;
        overflow: hidden;
        overflow-wrap : break-word;
        word-break: auto-phrase;
        color: var(--text-main);
        font-size: 56px;
        line-height: 1.3;
        font-weight: bold;
      }
      .entry-posted-date {
        font-size: 25px;
        font-weight: 600;
        margin-bottom: 10px;
        color: #A0AEC0;
      }
    </style>
  </head>
  <body class="category-{FirstCategory}">
    <div class="body-inner">
      <div class="header">
        <div class="icon">
          <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAAAXNSR0IArs4c6QAAFx5JREFUeF7tXQt0VdWZ/vc+N7ytVNOOM0OdQB0KuSq5CQKVh4n4RlGU8KraXMGlYu2oNTOu6UwN1teICuJSRNSE8tAGQQmIoguJBqV1MDc8bqhtNWgdHyUWRnlIcs/+h33OPffuc84+z9zAdRZZiwU39zz2+b/zv77//zcEjv/klQRIXq3m+GLgOCB59hIcB+Q4IHkmgTxbzrdF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gcmC6LrhxJCSpFBRKdE9BYn/m/9s/6fIhif+aSQ5psopAiS5inJK3bJNp3sLsGGve63BZCwz/etO+84IHkG2XFAjgOSZxLIs+Uc15A8A+T/ABxxzGSdh5hFAAAAAElFTkSuQmCC" />
        </div>
        <div class="blog-title">
          <div class="title">{BlogTitle}</div>
        </div>
        <div class="spacer"></div>
        <div class="category">
          <span>{FirstCategory}</span>
        </div>
      </div>
      <div class="main-wrapper">
        <div class="main">
          <p class="entry-posted-date">{PostedYear}/{PostedMonth}/{PostedDate}</p>
          <div class="entry-title">{Title}</div>
        </div>
      </div>
      <div class="footer-margin"></div>
    </div>
  </body>
</html>