Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Frees-Ling committed Apr 10, 2024
1 parent ff1e314 commit 0f891e6
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 14 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/install-and-configure.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Install and Configure

on:
push:
branches:
- main # 可以根据您的实际情况修改为其他分支

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7 # 可以根据您的项目的实际需求修改为其他版本

- name: Install dependencies and configure Faraday
run: |
gem install faraday-retry
# 在这里添加您的Faraday配置命令
require 'faraday'
require 'faraday_middleware' # 如果需要的话,还可以引入其他的Faraday中间件
# 创建一个Faraday连接
@conn = Faraday.new(url: 'http://example.com') do |faraday|
# 将faraday-retry中间件添加到Faraday连接中
faraday.use FaradayMiddleware::Retry, exceptions: [Faraday::TimeoutError, Faraday::ConnectionFailed]
# 在这里您还可以添加其他的中间件或做其他的配置
end
- name: Commit and push changes
run: |
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
git commit -am "Add faraday-retry gem and configure Faraday"
git push
31 changes: 18 additions & 13 deletions src/pages/tags/[tag]/[page].astro
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,28 @@ export async function getStaticPaths() {
const totalPages = getPageNumbers(tagPosts.length);
return totalPages.map(page => ({
params: { tag, page },
params: { tag, page: page.toString() },
props: { tag, tagName },
}));
});
}
const { page } = Astro.params;
const { tag, tagName } = Astro.props;
const posts = await getCollection("blog", ({ data }) => !data.draft);
const postsByTag = getPostsByTag(posts, tag);
const pagination = getPagination({
posts: postsByTag,
page,
});
export function getStaticProps({ params }) {
const { tag, page } = params;
const { data: posts } = getCollection("blog", ({ data }) => !data.draft);
const tagPosts = getPostsByTag(posts, tag);
const pagination = getPagination({
posts: tagPosts,
page: parseInt(page),
});
return {
props: {
...pagination,
tag,
tagName: tagPosts.length > 0 ? tagPosts[0].tag : "",
},
};
}
---

<TagPosts {...pagination} {tag} {tagName} />
<TagPosts {...pagination} tag={tag} tagName={tagName} />
2 changes: 1 addition & 1 deletion src/pages/tags/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ let tags = getUniqueTags(posts);
<Header activeNav="tags" />
<Main pageTitle="Tags" pageDesc="All the tags used in posts.">
<ul>
{tags.map(({ tag }) => <Tag {tag} size="lg" />)}
{tags.map(({ tag }) => <Tag tag={tag} size="lg" />)}
</ul>
</Main>
<Footer />
Expand Down

0 comments on commit 0f891e6

Please sign in to comment.