From 102e90688b1dc7b03abef34a725f1b82604ed78d Mon Sep 17 00:00:00 2001 From: marsonshine Date: Thu, 25 Jun 2026 13:56:36 +0800 Subject: [PATCH] refactor: Optimize document navigation logic and improve background service timer handling --- _layouts/default.html | 83 +++++++++++-------- .../BadPracticeBackgroundService.cs | 8 +- .../HighPerformanceBackgroundService.cs | 12 ++- 3 files changed, 61 insertions(+), 42 deletions(-) diff --git a/_layouts/default.html b/_layouts/default.html index 34132f4..eb149d4 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -85,40 +85,51 @@

{{ page.description | default: site.description | de
+ {% assign sibling_count = 0 %} + {% assign section_home = nil %} + {% assign prev_page = nil %} + {% assign next_page = nil %} {% if page.path contains 'docs/' and page.path != 'docs/README.md' %} - {% assign sibling_pages = site.pages | where_exp: "item", "item.path contains 'docs/' and item.path contains '.md' and item.dir == page.dir" | sort: "url" %} - {% assign section_home = sibling_pages | where_exp: "item", "item.name == 'README.md'" | first %} - {% assign prev_page = nil %} - {% assign next_page = nil %} + {% assign section_pages = site.pages | where: "dir", page.dir | sort: "url" %} {% assign seen_current = false %} - {% for item in sibling_pages %} - {% if item.url == page.url %} - {% assign seen_current = true %} - {% elsif seen_current and next_page == nil %} - {% assign next_page = item %} - {% elsif seen_current == false %} - {% assign prev_page = item %} + {% for item in section_pages %} + {% if item.path contains 'docs/' and item.path contains '.md' %} + {% assign sibling_count = sibling_count | plus: 1 %} + {% if item.name == 'README.md' %} + {% assign section_home = item %} + {% endif %} + {% if item.url == page.url %} + {% assign seen_current = true %} + {% elsif seen_current == false %} + {% assign prev_page = item %} + {% elsif next_page == nil %} + {% assign next_page = item %} + {% endif %} {% endif %} {% endfor %}