Skip to content

Commit

Permalink
deploy: 85ab262
Browse files Browse the repository at this point in the history
  • Loading branch information
mobeicanyue committed Dec 27, 2023
1 parent e4722a0 commit 84249bf
Show file tree
Hide file tree
Showing 11 changed files with 779 additions and 16 deletions.
682 changes: 682 additions & 0 deletions 2023/12/27/Fix-article-updated-time-on-github-pages/index.html

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions 2023/12/27/Use-lxgw-wenkai-in-fluid/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,12 @@ <h3 id="3-效果展示"><a href="#3-效果展示" class="headerlink" title="3.
<article class="post-prev col-6">


<a href="/2023/12/27/Fix-article-updated-time-on-github-pages/" title="修复 github pages 上的文章更新时间">
<i class="iconfont icon-arrowleft"></i>
<span class="hidden-mobile">修复 github pages 上的文章更新时间</span>
<span class="visible-mobile">上一篇</span>
</a>

</article>
<article class="post-next col-6">

Expand Down
8 changes: 7 additions & 1 deletion archives/2023/12/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,20 @@


<div class="list-group">
<p class="h4">共计 5 篇文章</p>
<p class="h4">共计 6 篇文章</p>
<hr>




<p class="h5">2023</p>

<a href="/2023/12/27/Fix-article-updated-time-on-github-pages/" class="list-group-item list-group-item-action">
<time>12-27</time>
<div class="list-group-item-title">修复 github pages 上的文章更新时间</div>
</a>


<a href="/2023/12/27/Use-lxgw-wenkai-in-fluid/" class="list-group-item list-group-item-action">
<time>12-27</time>
<div class="list-group-item-title">在 fluid 主题中使用霞鹜文楷</div>
Expand Down
8 changes: 7 additions & 1 deletion archives/2023/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,20 @@


<div class="list-group">
<p class="h4">共计 5 篇文章</p>
<p class="h4">共计 6 篇文章</p>
<hr>




<p class="h5">2023</p>

<a href="/2023/12/27/Fix-article-updated-time-on-github-pages/" class="list-group-item list-group-item-action">
<time>12-27</time>
<div class="list-group-item-title">修复 github pages 上的文章更新时间</div>
</a>


<a href="/2023/12/27/Use-lxgw-wenkai-in-fluid/" class="list-group-item list-group-item-action">
<time>12-27</time>
<div class="list-group-item-title">在 fluid 主题中使用霞鹜文楷</div>
Expand Down
8 changes: 7 additions & 1 deletion archives/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,20 @@


<div class="list-group">
<p class="h4">共计 5 篇文章</p>
<p class="h4">共计 6 篇文章</p>
<hr>




<p class="h5">2023</p>

<a href="/2023/12/27/Fix-article-updated-time-on-github-pages/" class="list-group-item list-group-item-action">
<time>12-27</time>
<div class="list-group-item-title">修复 github pages 上的文章更新时间</div>
</a>


<a href="/2023/12/27/Use-lxgw-wenkai-in-fluid/" class="list-group-item list-group-item-action">
<time>12-27</time>
<div class="list-group-item-title">在 fluid 主题中使用霞鹜文楷</div>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,48 @@



<div class="row mx-auto index-card">


<article class="col-12 col-md-12 mx-auto index-info">
<h2 class="index-header">

<a href="/2023/12/27/Fix-article-updated-time-on-github-pages/" target="_blank">
修复 github pages 上的文章更新时间
</a>
</h2>


<a class="index-excerpt index-excerpt__noimg" href="/2023/12/27/Fix-article-updated-time-on-github-pages/" target="_blank">
<div>
github actions 具体配置请参考前面的文章 1. 问题起因我开启了 fluid 配置的 但是在部署到 github pages 时,hexo 并不会像我们本地运行那样,显示的是文章的更新时间,而是显示的是部署的时间。 换句话说,你所有文章的更新时间都全部定格在 github actions 最新部署的那个时间(难绷)。 我们可以在 front-matter 加入 updated:
</div>
</a>

<div class="index-btm post-metas">

<div class="post-meta mr-3">
<i class="iconfont icon-date"></i>
<time datetime="2023-12-27 22:47" pubdate>
2023-12-27
</time>
</div>



<div class="post-meta">
<i class="iconfont icon-tags"></i>

<a href="/tags/github-actions/">#github-actions</a>

<a href="/tags/github-pages/">#github-pages</a>

</div>

</div>
</article>
</div>

<div class="row mx-auto index-card">


Expand Down
21 changes: 21 additions & 0 deletions local-search.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,27 @@



<entry>
<title>修复 github pages 上的文章更新时间</title>
<link href="/2023/12/27/Fix-article-updated-time-on-github-pages/"/>
<url>/2023/12/27/Fix-article-updated-time-on-github-pages/</url>

<content type="html"><![CDATA[<blockquote><p>github actions 具体配置请参考前面的文章</p></blockquote><h3 id="1-问题起因"><a href="#1-问题起因" class="headerlink" title="1. 问题起因"></a>1. 问题起因</h3><p>我开启了 fluid 配置的<br><img src="/../images/Fix-article-updated-time-on-github-pages/fluid-config.jpg" alt="fluid-config.jpg"></p><p>但是在部署到 github pages 时,<code>hexo 并不会像我们本地运行那样,显示的是文章的更新时间,而是显示的是部署的时间。</code> 换句话说,你所有文章的更新时间都全部定格在 github actions 最新部署的那个时间(难绷)。<br><img src="/../images/Fix-article-updated-time-on-github-pages/error-time.jpg" alt="error-time.jpg"></p><p>我们可以在 <code>front-matter</code> 加入 <code>updated: 更新时间</code> 解决</p><figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs yaml"><span class="hljs-attr">title:</span> <span class="hljs-string">article</span> <span class="hljs-string">title</span><br><span class="hljs-attr">date:</span> <span class="hljs-number">2023-01-01 00:00:00</span><br><br><span class="hljs-comment"># 添加 updated: 更新时间</span><br><span class="hljs-attr">updated:</span> <span class="hljs-number">2023-01-01 00:00:00</span><br></code></pre></td></tr></table></figure><p>但是很明显,这个需要我们手动去维护时间,这样很麻烦。</p><p>我们设想的是,文章的正常修改时间,就是文章的 commit 时间。</p><h3 id="2-解决方案"><a href="#2-解决方案" class="headerlink" title="2. 解决方案"></a>2. 解决方案</h3><p>修改 deploy.yml</p><ol><li><p>指定拉取代码的深度</p><figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs yaml"><span class="hljs-attr">uses:</span> <span class="hljs-string">actions/checkout@v4</span><br><span class="hljs-attr">with:</span><br> <span class="hljs-attr">fetch-depth:</span> <span class="hljs-number">0</span><br></code></pre></td></tr></table></figure><p><code>fetch-depth: 0</code> 指定了拉取代码的深度。在这里,设置为 0 表示完全拉取整个代码历史,而不是仅拉取最新的部分。这样可以获取完整的 Git 历史记录。</p></li><li><p>修复文件更新时间<br>在 build site 之前添加<sup id="fnref:1" class="footnote-ref"><a href="#fn:1" rel="footnote"><span class="hint--top hint--rounded" aria-label="参考竹林里有冰的 github acitons 文件 [workflows/deploy.yml](https://github.com/zhullyb/zhullyb.github.io/blob/master/.github/workflows/deploy.yml)">[1]</span></a></sup></p><figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs yaml"><span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">Fix</span> <span class="hljs-string">File</span> <span class="hljs-string">Updated</span> <span class="hljs-string">Date</span><br> <span class="hljs-attr">run:</span> <span class="hljs-string">|</span><br> <span class="hljs-string">git</span> <span class="hljs-string">ls-files</span> <span class="hljs-string">|</span> <span class="hljs-string">while</span> <span class="hljs-string">read</span> <span class="hljs-string">filepath;</span> <span class="hljs-string">do</span> <span class="hljs-string">touch</span> <span class="hljs-string">-d</span> <span class="hljs-string">&quot;$(git log -1 --format=&#x27;@%ct&#x27; $filepath)&quot;</span> <span class="hljs-string">&quot;$filepath&quot;</span> <span class="hljs-string">&amp;&amp;</span> <span class="hljs-string">echo</span> <span class="hljs-string">&quot;Fixed: $filepath&quot;</span><span class="hljs-string">;</span> <span class="hljs-string">done</span><br></code></pre></td></tr></table></figure><p>在这个脚本中,git ls-files 用于列出所有已跟踪的文件,然后通过 while read filepath 遍历每个文件。<br>对于每个文件,git log -1 --format&#x3D;‘@%ct’ $filepath 用于获取该文件的最后一次提交的时间戳(以秒为单位),并使用 touch -d 命令将文件的更新日期设置为相应的时间戳。<br>echo “Fixed: $filepath” 用于输出修复过的文件路径。</p></li></ol><p>这样我们就修复了 github pages 的文章更新时间。</p><section class="footnotes"><div class="footnote-list"><ol><li><span id="fn:1" class="footnote-text"><span>参考竹林里有冰的 github acitons 文件 <a href="https://github.com/zhullyb/zhullyb.github.io/blob/master/.github/workflows/deploy.yml">workflows&#x2F;deploy.yml</a><a href="#fnref:1" rev="footnote" class="footnote-backref"> ↩</a></span></span></li></ol></div></section>]]></content>



<tags>

<tag>github-actions</tag>

<tag>github-pages</tag>

</tags>

</entry>



<entry>
<title>在 fluid 主题中使用霞鹜文楷</title>
<link href="/2023/12/27/Use-lxgw-wenkai-in-fluid/"/>
Expand Down
18 changes: 6 additions & 12 deletions tags/github-actions/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<meta name="description" content="This is Canyue&#39;s blog.">
<meta property="og:type" content="website">
<meta property="og:title" content="标签 - github actions">
<meta property="og:title" content="标签 - github-actions">
<meta property="og:url" content="https://blog.ovvv.top/tags/github-actions/">
<meta property="og:site_name" content="Canyue">
<meta property="og:description" content="This is Canyue&#39;s blog.">
Expand All @@ -28,7 +28,7 @@



<title>标签 - github actions - Canyue</title>
<title>标签 - github-actions - Canyue</title>

<link rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />

Expand Down Expand Up @@ -192,7 +192,7 @@
<div class="banner-text text-center fade-in-up">
<div class="h2">

<span id="subtitle" data-typed-text="标签 - github actions"></span>
<span id="subtitle" data-typed-text="标签 - github-actions"></span>

</div>

Expand Down Expand Up @@ -224,23 +224,17 @@


<div class="list-group">
<p class="h4">共计 2 篇文章</p>
<p class="h4">共计 1 篇文章</p>
<hr>




<p class="h5">2023</p>

<a href="/2023/12/27/Configure-blog-domain/" class="list-group-item list-group-item-action">
<a href="/2023/12/27/Fix-article-updated-time-on-github-pages/" class="list-group-item list-group-item-action">
<time>12-27</time>
<div class="list-group-item-title">博客域名配置</div>
</a>


<a href="/2023/12/26/Init-my-first-hexo-blog/" class="list-group-item list-group-item-action">
<time>12-26</time>
<div class="list-group-item-title">我的第一篇 Hexo 博客</div>
<div class="list-group-item-title">修复 github pages 上的文章更新时间</div>
</a>

</div>
Expand Down
2 changes: 1 addition & 1 deletion tags/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@


<div class="text-center tagcloud">
<a href="/tags/deploy/" style="font-size: 22.5px; color: #779bd3">deploy</a> <a href="/tags/domain/" style="font-size: 15px; color: #bbe">domain</a> <a href="/tags/fluid/" style="font-size: 22.5px; color: #779bd3">fluid</a> <a href="/tags/github/" style="font-size: 15px; color: #bbe">github</a> <a href="/tags/github-actions/" style="font-size: 22.5px; color: #779bd3">github actions</a> <a href="/tags/github-pages/" style="font-size: 15px; color: #bbe">github pages</a> <a href="/tags/hexo/" style="font-size: 30px; color: #337ab7">hexo</a>
<a href="/tags/deploy/" style="font-size: 22.5px; color: #779bd3">deploy</a> <a href="/tags/domain/" style="font-size: 15px; color: #bbe">domain</a> <a href="/tags/fluid/" style="font-size: 22.5px; color: #779bd3">fluid</a> <a href="/tags/github/" style="font-size: 15px; color: #bbe">github</a> <a href="/tags/github-actions/" style="font-size: 22.5px; color: #779bd3">github actions</a> <a href="/tags/github-pages/" style="font-size: 15px; color: #bbe">github pages</a> <a href="/tags/github-actions/" style="font-size: 15px; color: #bbe">github-actions</a> <a href="/tags/github-pages/" style="font-size: 15px; color: #bbe">github-pages</a> <a href="/tags/hexo/" style="font-size: 30px; color: #337ab7">hexo</a>
</div>

</div>
Expand Down

0 comments on commit 84249bf

Please sign in to comment.