diff --git a/.github/workflows/install-and-configure.yml b/.github/workflows/install-and-configure.yml new file mode 100644 index 0000000..e5049e2 --- /dev/null +++ b/.github/workflows/install-and-configure.yml @@ -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 diff --git a/src/pages/tags/[tag]/[page].astro b/src/pages/tags/[tag]/[page].astro index 412dd1b..14cbbe5 100644 --- a/src/pages/tags/[tag]/[page].astro +++ b/src/pages/tags/[tag]/[page].astro @@ -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 : "", + }, + }; +} --- - + diff --git a/src/pages/tags/index.astro b/src/pages/tags/index.astro index 97d07b1..1eae4b1 100644 --- a/src/pages/tags/index.astro +++ b/src/pages/tags/index.astro @@ -17,7 +17,7 @@ let tags = getUniqueTags(posts);
    - {tags.map(({ tag }) => )} + {tags.map(({ tag }) => )}