From 1266b8ce2e4833457395aa69931ce34a52b48839 Mon Sep 17 00:00:00 2001 From: Mick Zhuang Date: Fri, 26 Jul 2024 16:31:52 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20use=20similarity=20to=20recommend?= =?UTF-8?q?=20instead=20of=20top=203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/page.html | 13 +++++++------ templates/reading-note.html | 13 +++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/templates/page.html b/templates/page.html index ba11d34..5009362 100644 --- a/templates/page.html +++ b/templates/page.html @@ -50,12 +50,13 @@

提及本篇的文章

相關文章推薦

- {% set top_3_nn = load_data(path="static/data/top_3_nn.json") %} - {% if top_3_nn[page.path] %} - {% set top_3_nn_paths = top_3_nn[page.path] | split(pat=":") %} - {% for path in top_3_nn_paths %} - {% set nn_page = get_page(path=path) %} - {{ macro::card(nn_page=nn_page, relevance="70%") }} + {% set similar_posts = load_data(path="static/data/similar_posts.json") %} + {% if similar_posts[page.path] %} + {% set similar_posts_with_relevance = similar_posts[page.path] | split(pat=":") %} + {% for similar_post_with_relevance in similar_posts_with_relevance %} + {% set parts = similar_post_with_relevance | split(pat="|") %} + {% set nn_page = get_page(path=parts[0]) %} + {{ macro::card(nn_page=nn_page, relevance=parts[1]) }} {% endfor %} {% endif %}
diff --git a/templates/reading-note.html b/templates/reading-note.html index 29cb460..536b824 100644 --- a/templates/reading-note.html +++ b/templates/reading-note.html @@ -51,12 +51,13 @@

提及本篇的文章

相關文章推薦

- {% set top_3_nn = load_data(path="static/data/top_3_nn.json") %} - {% if top_3_nn[page.path] %} - {% set top_3_nn_paths = top_3_nn[page.path] | split(pat=":") %} - {% for path in top_3_nn_paths %} - {% set nn_page = get_page(path=path) %} - {{ macro::card(nn_page=nn_page, relevance="70%") }} + {% set similar_posts = load_data(path="static/data/similar_posts.json") %} + {% if similar_posts[page.path] %} + {% set similar_posts_with_relevance = similar_posts[page.path] | split(pat=":") %} + {% for similar_post_with_relevance in similar_posts_with_relevance %} + {% set parts = similar_post_with_relevance | split(pat="|") %} + {% set nn_page = get_page(path=parts[0]) %} + {{ macro::card(nn_page=nn_page, relevance=parts[1]) }} {% endfor %} {% endif %}