Skip to content

Commit

Permalink
✨ use similarity to recommend instead of top 3
Browse files Browse the repository at this point in the history
  • Loading branch information
mickm3n committed Jul 26, 2024
1 parent 6f79868 commit 1266b8c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
13 changes: 7 additions & 6 deletions templates/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@ <h2>提及本篇的文章</h2>
</article>
<h2>相關文章推薦</h2>
<div class="cards-container">
{% 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 %}
</div>
Expand Down
13 changes: 7 additions & 6 deletions templates/reading-note.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@ <h2>提及本篇的文章</h2>
</article>
<h2>相關文章推薦</h2>
<div class="cards-container">
{% 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 %}
</div>
Expand Down

0 comments on commit 1266b8c

Please sign in to comment.