DoIt icon indicating copy to clipboard operation
DoIt copied to clipboard

[BUG] 连续使用多个 Music Shortcodes 时歌曲无法被正常渲染

Open ryan4yin opened this issue 3 years ago • 8 comments

Describe the bug 描述你遇到的错误

一篇文章中如果使用了多个 music shortcodes,并且它们之间无任何填充,会导致 aplayer/meting-js 未被页面载入,歌曲无法显示,示例如下:

<!-- 庭前鹤高歌 - 河津樱 -->
{{< music server="netease" type="song" id="1466346187" >}}

<!-- 明日见黄花 - 永动机 -->
{{< music server="netease" type="song" id="519225198" >}}

<!-- 1400424646 - She Her Her Hers -->
{{< music server="netease" type="song" id="1400424646" >}}

这样渲染出的页面无法显示歌曲,有 meting-js 标签但是无任何内容:

<div class="content" id="content"><blockquote>
<meting-js server="netease" type="song" id="1466346187" theme="#448aff"></meting-js>
<meting-js server="netease" type="song" id="519225198" theme="#448aff"></meting-js>
<meting-js server="netease" type="song" id="1400424646" theme="#448aff"></meting-js>
</div>

本地测试发现在文章里随便加点东西,偶尔又能正常渲染出歌曲,偶尔又不行,没找到规律。

推测是 music 这个 shortcodes 的 {{- .Page.Scratch.SetInMap "this" "music" true -}} 这一行有些问题,但是水平有限无法解决。

Expected behavior 期待的行为

只要正确使用了 music shortcodes,就应该能渲染出歌曲来。

Screenshots 屏幕截图

No response

Build Environment 构建环境

  • OS Version: MacOS 12.3.1
  • Hugo Version: hugo v0.96.0+extended darwin/amd64 BuildDate=unknown
  • Theme Version: e2d825a83cfe9b765488ec47a121cce803e2ee5f

Preview Environment 预览环境

No response

Additional Information 补充信息

No response

ryan4yin avatar May 29 '22 07:05 ryan4yin

目前只发现一篇文章有这个问题,我换成了 playlist 仍然无法解决,文章地址:

https://thiscute.world/posts/weeds-on-this-side-flowers-on-the-other/

markdown 内容:

https://raw.githubusercontent.com/ryan4yin/thiscute.world/main/content/posts/weeds-on-this-side-flowers-on-the-other/index.md

ryan4yin avatar May 29 '22 08:05 ryan4yin

https://github.com/ryan4yin/thiscute.world/blob/b88a94d03f5b00460b116ee018e7bbf90d90364c/layouts/shortcodes/statistics_summary.html#L3

.WordCount 似乎会带来 side effect 然后把所有 .Scratch 里的 map data 清空。将 .WordCount 替换成任意其他数值均可正常渲染。(如 {{ $scratch.Add "wordcount" 0 }}

image

HEIGE-PCloud avatar May 29 '22 22:05 HEIGE-PCloud

DoIt 自身的实现并没有问题,无论多少个 music shortcode 都可以正常渲染 https://hugodoit.com/music-tests/

HEIGE-PCloud avatar May 29 '22 22:05 HEIGE-PCloud

将 Categories 改为 categories: ["随笔"] 也可以修复这个问题。给我整不会了。。。

HEIGE-PCloud avatar May 29 '22 23:05 HEIGE-PCloud

将 Categories 改为 categories: ["随笔"] 也可以修复这个问题。给我整不会了。。。

我测试发现这样的修改实际上是没用的,是在本地预览的时候,对文章随便做点小改动,动态更新后问题就修复了,但是 ctrl+c 退出后重新运行预览命令,问题就又出现了。

ryan4yin avatar May 30 '22 02:05 ryan4yin

@HEIGE-PCloud {{ $scratch.Add "wordcount" 0 }} 这个我试了下好像也没用,不知道是啥问题 emmm,我也只在这一篇文章上遇到了这个毛病...

ryan4yin avatar May 30 '22 02:05 ryan4yin

@ryan4yin 你预览的时候记得开 —disableFastRender

HEIGE-PCloud avatar May 30 '22 05:05 HEIGE-PCloud

@HEIGE-PCloud 今天 brew upgrade 更新了一波本地环境,莫名其妙地 music 跟 mermaid 两个 shortcodes 又恢复正常了(之前这两个都有问题)。 但是仅仅是本地构建恢复了...同样的构建命令,同样的 hugo 版本号,构建出的结果不一样...

本地环境:

  • OS Version: MacOS 12.3.1
  • Hugo Version: hugo v0.100.1+extended darwin/amd64 BuildDate=unknown
  • Theme Version: d98f7076a171d8e94f1afba2fedb62b90998233a

构建日志:

❯ hugo --minify --ignoreCache --gc --cleanDestinationDir --forceSyncStatic 
Start building sites … 
hugo v0.100.1+extended darwin/amd64 BuildDate=unknown

                   | ZH-CN | EN   
-------------------+-------+------
  Pages            |   247 |  13  
  Paginator pages  |     6 |   0  
  Non-page files   |    71 |   3  
  Static files     |   250 | 250  
  Processed images |     0 |   0  
  Aliases          |   168 |   5  
  Sitemaps         |     2 |   1  
  Cleaned          |     6 |   6  

Total in 1725 ms

产生的静态文件变更(mermaid 正常了):https://github.com/ryan4yin/thiscute.world/commit/a0f984404b62978c2e7ce994fa23ec9fe6ef071b

vercel 配置的 Hugo 版本:

{
  "build": {
    "env": {
      "HUGO_VERSION": "0.100.1"
    }
  }
}

vercel 构建日志:

Cloning github.com/ryan4yin/thiscute.world (Branch: main, Commit: f84eb9c)
Cloning completed: 2.977s
Installing build runtime...
Build runtime installed: 1.990s
Looking up build cache...
Build cache downloaded [11.00 B]: 9.314ms
Installing Hugo version 0.100.1
Start building sites … 
hugo v0.100.1-0afb4866e345d31cbbcbab4349e43f1d36122806+extended linux/amd64 BuildDate=2022-06-01T10:11:48Z VendorInfo=gohugoio
                   | ZH-CN | EN   
-------------------+-------+------
  Pages            |   247 |  13  
  Paginator pages  |     6 |   0  
  Non-page files   |    71 |   3  
  Static files     |   250 | 250  
  Processed images |     0 |   0  
  Aliases          |   168 |   5  
  Sitemaps         |     2 |   1  
  Cleaned          |     4 |   4  
Total in 1626 ms
Generated build outputs:
 - Static files: 1236
 - Serverless Functions: 0
 - Edge Functions: 0
Deployed outputs in 5s
Build completed. Populating build cache...
Uploading build cache [11.00 B]...
Build cache uploaded: 285.809ms
Done with "config.toml"

但是生成出来的内容就是不一样,vercel 这个就是不会加载 mermaid 图像...

我也用 github actions 跑了一波 hugo v0.100.1,也是同样有问题,github action 配置如下:

https://github.com/ryan4yin/thiscute.world/blob/2f9304e5153044a98d8160bcecd317d463b37957/.github/workflows/gh-pages.yaml

不知道我本地环境是哪里有更新导致问题修复了...目前临时通过在本地渲染,解决了这个问题,但是不是长久之计 emmm

ryan4yin avatar Jun 08 '22 18:06 ryan4yin