unimal-jp / spear

The spear OSS repository
https://late-cloud-6411.spearly.app
MIT License
10 stars 1 forks source link

Image from CMS in `a` tag is not displayed #94

Open oxo-yuta opened 1 year ago

oxo-yuta commented 1 year ago

Describe the bug

I loaded images from the CMS and tried to display them, but they did not display properly. The following error was displayed in the terminal.

BadRequestError: Bad Request
    at createHttpError (/Users/yuta/private/oxo-tech-site-spear/node_modules/send/index.js:979:12)
    at SendStream.error (/Users/yuta/private/oxo-tech-site-spear/node_modules/send/index.js:270:31)
    at SendStream.pipe (/Users/yuta/private/oxo-tech-site-spear/node_modules/send/index.js:516:10)
    at /Users/yuta/private/oxo-tech-site-spear/node_modules/live-server/index.js:97:5
    at call (/Users/yuta/private/oxo-tech-site-spear/node_modules/connect/index.js:239:7)
    at next (/Users/yuta/private/oxo-tech-site-spear/node_modules/connect/index.js:183:5)
    at Function.handle (/Users/yuta/private/oxo-tech-site-spear/node_modules/connect/index.js:186:3)
    at Server.app (/Users/yuta/private/oxo-tech-site-spear/node_modules/connect/index.js:51:37)
    at Server.emit (node:events:520:28)
    at parserOnIncoming (node:_http_server:951:12)

the source is below

<article class="article" cms-loop cms-content-type="posts">
  <a href="{%= posts_#url %}" class="article-imageLink">
    <img src="{%= posts_eye-catch %}" alt="" class="article-image">
  </a>
  <div class="article-rightBlock">
    <time class="article-date">{%= posts_post-date %}</time>
    <a href="{%= posts_#url %}" class="article-titleLink">
      <h2 class="article-title">{%= posts_title %}  </h2>
    </a>
    <span class="article-tag">{%= posts_tags %} </span>
    <p class="article-description">{%= posts_digest %}</p>
    <div class="article-author" cms-loop cms-field="author" cms-item-variable="author">
      <img class="article-author-image" src="{%= posts_author_image %}"/>
      <span class="article-author-name">{%= author_name %}</span>
    </div>
  </div>
</article>

and what I get is

<article class="article" cms-loop="">
  <a href="./?contentId=keychron-v10" class="article-titleLink">
    <h2 class="article-title">AliceレイアウトなKeychron V10を買いました(タッチタイピングできない)</h2>
  </a>
  <span class="article-tag">Keyboad</span>
  <p class="article-description">我流のタイピングである程度の速度は出るのですが、よく打ち間違えるし、たまにキーボードを見ないと文字が打てません。 そこで僕はこう考えました。「Aliceレイアウトなら嫌でもタッチタイピングできるようになるんじゃね?」</p>
  <div class="article-author" cms-loop="" cms-field="author" cms-item-variable="author">
    <img class="article-author-image" src="{%= posts_author_image %}">
    <span class="article-author-name">{%= author_name%}</span>
  </div>
</article>

The a tag with the article-imageLink class is missing entirely. this code works fine with original cms.js from Spearly CMS

Expected behavior Embed contents correctly

oxo-yuta commented 1 year ago

I'm not sure the cause is that img tag is in a tag 😅 If it's wrong, please change the name of issue 🙏