• R语言
  • 【已解决】blogdown xmag 主题如何通过 iframe 插入外链音乐

很奇怪,我在 https://www.xiangyunhuang.com.cn/2019/05/another-hello-markdown/ 博客使用

<iframe frameborder="0" marginwidth="0" marginheight="0" width=400 height=80 src="https://music.163.com/outchain/player?type=2&id=34341360&auto=0&height=66"></iframe>

插入音乐,没有问题,但是在博客中

https://xiangyun.rbind.io/2020/08/ten-years-ten-months/

用同样的方式插入音乐却出了问题,无法显示,对比看了没看出名堂,求助

文章源码

https://github.com/rbind/xiangyun/blob/master/content/post/2020-08-15-ten-years-ten-months.md

仓库位置

https://github.com/rbind/xiangyun

hugo-xmag 主题位置

https://github.com/yihui/hugo-xmag

我使用的是默认的 hugo-xmag 主题设置

部署环境

用 netlify 部署的, HUGO 版本 0.67.0

    Cloud2016 怎么部署的,hugo啥版本?

    最近某个hugo的md解释器goldmark默认忽略md里的html,可能是这个问题

      tctcab 大神,我服了,真如你所说,我把版本降低到 0.55.6 就可以了。而更新到最新版本 0.74.3 仍然不行。
      但是降低版本号似乎不是个好办法,比如我要是更新到最新的 hugo 版本,然后解决方案是什么?

        Cloud2016 更改标题为「【已解决】blogdown xmag 主题如何通过 iframe 插入外链音乐

        这是 Hugo 里我最感到恼火的问题,没有之一。当时 bep(Hugo 主要开发者)做的这个决定实在是太糟糕了,害我背了好多黑锅。Markdown 里混入 HTML 代码是很正常的事情,他却以莫须有的安全原因,默认把 HTML 代码禁掉了。这种问题出现后对普通用户来说实在是太难查找到原因了,包括我最初都被它困惑了好一阵子,后来才研究出来原来有这么个选项。

        3 年 后

        我在自己的帖子中也插入了外链音乐,在本地建站是可以显示音乐并正常播放,但push到网上的博客之后却没有显示这个插入外链音乐的帖子。

        我插入的外链音乐如下:<iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=330 height=86 src="//music.163.com/outchain/player?type=2&id=1874946820&auto=1&height=66"></iframe>

        提出问题以前,我根据本贴tctcab大哥和谢大哥的建议都试了一遍。

        由于我的config文件是.yaml的,所以代码如下:

        markup: 
          goldmark: 
            renderer: 
              unsafe: true

        但其实没求助之前以上代码就已经存在,只是unsafe那里是yes,后来我改成了现在的true,但一样不行。

        奇怪的地方在于:修改前后本地建站预览都是有外链音乐显示,还可以正常播放,但不知为什么把帖子上传之后,网站里却没有显示这篇帖子(仅仅是没有显示帖子,其他的帖子、主页面什么的都正常显示)。

        帖子源码:
        https://github.com/residualsun1/Residualsun/blob/main/content/en/post/2023/05/may-have-hope.md?plain=1

        设置unsafe的config.yaml的源码:
        https://github.com/residualsun1/Residualsun/blob/main/config/_default/config.yaml

        仓库位置:
        https://github.com/residualsun1/Residualsun

        主题模板anatole位置:
        https://github.com/lxndrblz/anatole

        部署环境:
        使用的是Netlify。

        R配置环境:

        > sessionInfo()
        R version 4.2.3 (2023-03-15 ucrt)
        Platform: x86_64-w64-mingw32/x64 (64-bit)
        Running under: Windows 10 x64 (build 22621)
        
        Matrix products: default
        
        locale:
        [1] LC_COLLATE=Chinese (Simplified)_China.utf8  LC_CTYPE=Chinese (Simplified)_China.utf8   
        [3] LC_MONETARY=Chinese (Simplified)_China.utf8 LC_NUMERIC=C                               
        [5] LC_TIME=Chinese (Simplified)_China.utf8    
        
        attached base packages:
        [1] stats     graphics  grDevices utils     datasets  methods   base     
        
        other attached packages:
        [1] shiny_1.7.4
        
        loaded via a namespace (and not attached):
         [1] Rcpp_1.0.10      rstudioapi_0.14  knitr_1.43       servr_0.27       magrittr_2.0.3  
         [6] xtable_1.8-4     R6_2.5.1         rlang_1.1.1      fastmap_1.1.1    tools_4.2.3     
        [11] xfun_0.39        miniUI_0.1.1.1   cli_3.6.1        jquerylib_0.1.4  htmltools_0.5.5 
        [16] ellipsis_0.3.2   yaml_2.3.7       digest_0.6.31    lifecycle_1.0.3  bookdown_0.34   
        [21] processx_3.8.1   later_1.3.1      sass_0.4.6       promises_1.2.0.1 ps_1.7.5        
        [26] memoise_2.0.1    cachem_1.0.8     evaluate_0.21    mime_0.12        rmarkdown_2.21  
        [31] blogdown_1.17.2  bslib_0.4.2      compiler_4.2.3   jsonlite_1.8.4   httpuv_1.6.11  

        烦请各位前辈指导。

          CyrusYip 【已解决】感谢你的及时回复!

          帖子未显示的问题

          确实是时区的问题,我仿照你的设置,在文件路径themes/anatole/exampleSite/config/_default/congfig.toml中添加了buildFuture = true,再次push后帖子正常显示了,问题已解决啦。

          关于用parmalink贴代码

          我在你的.toml文件中看到是这样的格式设置:

          [permalinks]
            post = "/post/:year/:month/:day/:slug/"

          但怎么具体贴出的话我还是没有理解,可以麻烦你贴一个源码举个例子吗?

            residual-sun 建议新开帖子提问,方便以后有类似问题的人搜索和找到解决办法。如果本帖的内容跟你要问的有关联,你可以在新帖子里引用帖子的链接。

              Liechi 好的!那我把刚刚的回复修改简短一些,然后给新的问题开一个新的帖子。