diff --git a/tests/test_theme_registry.py b/tests/test_theme_registry.py index c5f534e..e3f8e93 100644 --- a/tests/test_theme_registry.py +++ b/tests/test_theme_registry.py @@ -282,6 +282,7 @@ def test_trade_pro_listing_layout_structure(factory): cat1 = factory.get(f'/preview/{sid}/{bid}/categories/pumps/') assert cat1.status_code == 200, cat1.text[:200] s1 = BeautifulSoup(cat1.text, 'html.parser') + assert len(s1.find_all('h1')) == 1 nav1 = s1.select_one('nav.sf-tp-pagination') assert nav1 is not None assert len(s1.select('.sf-tp-card-grid--listing .sf-tp-card')) == 100 @@ -295,6 +296,7 @@ def test_trade_pro_listing_layout_structure(factory): cat2 = factory.get(f'/preview/{sid}/{bid}/categories/pumps/page/2/') assert cat2.status_code == 200, cat2.text[:200] s2 = BeautifulSoup(cat2.text, 'html.parser') + assert len(s2.find_all('h1')) == 1 nav2 = s2.select_one('nav.sf-tp-pagination') assert len(s2.select('.sf-tp-card-grid--listing .sf-tp-card')) == 5 prev = nav2.select_one('a[rel="prev"]') @@ -330,8 +332,8 @@ def test_trade_pro_listing_layout_structure(factory): # ── 空列表(/cases/ 无案例):整段隐藏换友好空态,不渲染筛选 ── cases = factory.get(f'/preview/{sid}/{bid}/cases/').text assert 'sf-tp-listing-empty' in cases - assert '[data-pro-filter-search]' not in cases - assert 'nav.sf-tp-pagination' not in cases + assert 'data-pro-filter-search' not in cases + assert 'sf-tp-pagination' not in cases def test_frontend_entries_include_trade_pro(): diff --git a/themes/trade-pro/pages/listing.html b/themes/trade-pro/pages/listing.html index 10dcb30..b5dc139 100644 --- a/themes/trade-pro/pages/listing.html +++ b/themes/trade-pro/pages/listing.html @@ -9,7 +9,9 @@ 1. kind 分支按列表内容类型:post 类(/news/、/post/ 等文章集合)用 新闻行形态;其余(product/vehicle/brand/case/service)复用产品卡片 栅格——cms 只定义了这两种列表设计,品牌/案例/服务映射到产品卡形态 - (与 brand.html 相关产品、product.html 相关产品一致)。 + (与 brand.html 相关产品、product.html 相关产品一致)。非空列表只信 + 首项内容类型;路由子串仅作空列表 fallback 且排除 category(否则 + /categories/post-sales-service/ 这类 slug 会被误判成新闻分支)。 2. 产品分类侧栏仅产品类列表渲染(侧栏链接是产品分类语义,出现在 /brands/ 等页面会误导);文章分支的侧栏是 cms 新闻三盒。空分类 数据时侧栏整段隐藏,主列变单栏。 @@ -27,7 +29,7 @@ 路由一致(第 1 页 = 栏目根,形如 /products/page/2/ 递增)。 6. 空列表:筛选、栅格、分页整段隐藏,替换为友好空态提示(cms 站点 恒有内容,平台必须处理 noindex 栏目占位页的空集)。 #} -{% set tp_post_like = (listing and listing[0].type == 'post') or ('news' in route or 'post' in route) %} +{% set tp_post_like = (listing[0].type == 'post') if listing else (kind == 'listing' and ('news' in route or 'post' in route)) %} {% set tp_eyebrow = 'NEWS & INSIGHTS' if tp_post_like else 'PRODUCT CATALOGUE' %} {% set tp_hero_img = safe_image(page.cover) %} {% set tp_lead = page.summary or ('Industry updates, project stories and exhibition news from our team.' if tp_post_like else 'Browse the full catalogue with specifications, brands and categories.') %} @@ -84,7 +86,7 @@ @@ -102,7 +104,9 @@
{{ tp_lead }}
+ {# 导语不与 hero 重复:主列头行改条目/页数计数(cms SectionHead 的 + intro 位在平台无独立文案来源,用真实数据代替装饰性复述) #} +{{ listing|length }} items{% if pagination and pagination.pages > 1 %} · {{ pagination.pages }} pages{% endif %}