forked from cotes2020/jekyll-theme-chirpy
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: update backlinks section in post.html and add backlinks gen…
…erator plugin - Update the backlinks section in the post.html layout file to include a conditional check for displaying backlinks. - Add a new backlinks generator plugin in the _plugins directory to identify and add backlinks to each document. - Modify the post.html layout file to include the generated backlinks in a styled box. Related to cotes2020#123
- Loading branch information
Showing
4 changed files
with
50 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module Jekyll | ||
class BacklinksGenerator < Generator | ||
def generate(site) | ||
all_notes = site.collections['docs'].docs | ||
all_posts = site.posts.docs | ||
all_pages = site.pages | ||
|
||
all_docs = all_notes + all_posts + all_pages | ||
|
||
# Identify backlinks and add them to each doc | ||
all_docs.each do |current_doc| | ||
backlinks = all_docs.select do |doc| | ||
doc.content.include?(current_doc.url) | ||
end | ||
current_doc.data['backlinks'] = backlinks | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters