diff --git a/README.md b/README.md index 3fe23f8..543cf47 100644 --- a/README.md +++ b/README.md @@ -90,10 +90,20 @@ lang: "en" # Plugins, implemented in ./plugins/PLUGIN_NAME # Use {{ vars.PLUGIN_NAME }} in the settings below +# The output of the plugin can be used below, e.g., {{vars.MediumFollowersCountPlugin}} plugins: # Automatically fetch Medium follower count - MediumFollowersCountPlugin: username: zhgchgli + # Automatically fetch Github repo star count + - GithubRepoStarsCountPlugin: + - ZhgChgLi/ZMarkupParser + - ZhgChgLi/ZReviewTender + - ZhgChgLi/ZMediumToMarkdown + - ZhgChgLi/linkyee + +# Google Analytics tracking id +google_analytics_id: # HTML Title title: "ZhgChgLi's Links" @@ -110,39 +120,66 @@ tagline: >- # List of links # icon: Use Font Awesome icons (https://fontawesome.com/search?o=r&m=free) -# title: The displayed text for the link +# text: The displayed text for the link +# title: The url title # url: The URL of the link # alt: Alternative text for accessibility # target: `_blank` opens in a new tab, `_self` opens in the same frame links: - link: icon: "fa-brands fa-medium" - title: "Tech Blog ({{vars.MediumFollowersCountPlugin}} Followers)" + text: "Tech Blog ({{vars.MediumFollowersCountPlugin}} Followers)" url: "https://blog.zhgchg.li" alt: "ZhgChgLi's Tech Blog" + title: "ZhgChgLi's Tech Blog" target: "_blank" - link: icon: "fa-brands fa-medium" - title: "Travelog ({{vars.MediumFollowersCountPlugin}} Followers)" + text: "Travelog ({{vars.MediumFollowersCountPlugin}} Followers)" url: "https://medium.com/ztravel" alt: "ZhgChgLi's Travelog" + title: "ZhgChgLi's Travelog" target: "_blank" - link: icon: "fa-solid fa-rss" - title: "Website" + text: "Website" url: "https://zhgchg.li/" alt: "ZhgChgLi's Website" + title: "ZhgChgLi's Website" target: "_blank" - link: - icon: "fa-brands fa-instagram" - title: "Instagram" - url: "https://www.instagram.com/zhgchgli/" - alt: "ZhgChgLi's Instagram" + icon: "fa-brands fa-swift" + text: "ZMarkupParser ({{vars.GithubRepoStarsCountPlugin['ZhgChgLi/ZMarkupParser']}} Stars)" + url: "https://github.com/ZhgChgLi/ZMarkupParser" + alt: "ZMarkupParser is a pure-Swift library that helps you to convert HTML strings to NSAttributedString with customized style and tags." + title: "ZMarkupParser is a pure-Swift library that helps you to convert HTML strings to NSAttributedString with customized style and tags." target: "_blank" + - link: + icon: "fa-brands fa-app-store-ios" + text: "ZReviewTender ({{vars.GithubRepoStarsCountPlugin['ZhgChgLi/ZReviewTender']}} Stars)" + url: "https://github.com/ZhgChgLi/ZReviewTender" + alt: "ZReviewTender is a tool for fetching app reviews from the App Store and Google Play Console and integrating them into your workflow." + title: "ZReviewTender is a tool for fetching app reviews from the App Store and Google Play Console and integrating them into your workflow." + target: "_blank" + - link: + icon: "fa-brands fa-markdown" + text: "ZMediumToMarkdown ({{vars.GithubRepoStarsCountPlugin['ZhgChgLi/ZMediumToMarkdown']}} Stars)" + url: "https://github.com/ZhgChgLi/ZMediumToMarkdown" + alt: "ZMediumToMarkdown is a powerful tool that allows you to effortlessly download and convert your Medium posts to Markdown format." + title: "ZMediumToMarkdown is a powerful tool that allows you to effortlessly download and convert your Medium posts to Markdown format." + target: "_blank" + - link: + icon: "fa-brands fa-github" + text: "linkyee ({{vars.GithubRepoStarsCountPlugin['ZhgChgLi/linkyee']}} Stars)" + url: "https://github.com/ZhgChgLi/linkyee" + alt: "linkyee is a fully customized, open-source LinkTree alternative deployed directly on GitHub Pages." + title: "linkyee is a fully customized, open-source LinkTree alternative deployed directly on GitHub Pages." + target: "_blank" + # List of social media links # icon: Use Font Awesome icons (https://fontawesome.com/search?o=r&m=free) -# title: The displayed title for the social media link +# title: The url title # url: The URL of the social media link # alt: Alternative text for accessibility # target: _blank opens in a new tab, _self opens in the same frame @@ -171,6 +208,12 @@ socials: title: "ZhgChgLi's LinkedIn" alt: "ZhgChgLi's LinkedIn" target: "_blank" + - social: + icon: "fa-brands fa-instagram" + url: "https://www.instagram.com/zhgchgli/" + title: "Instagram" + alt: "ZhgChgLi's Instagram" + target: "_blank" - social: icon: "fa-solid fa-envelope" url: "mailto:zhgchgli@gmail.com" @@ -185,7 +228,7 @@ footer: > # Footer copyright message # Linkyee is a 100% free, open-source project—feel free to modify the copyright message as you like. :) copyright: > - © 2024 ZhgChgLi. Powered by linkyee + © 2024 ZhgChgLi. Powered by linkyee ``` #### Please note that after each files modification, you need to wait for GitHub Actions to complete the `Automatic build` and `pages build and deployment` tasks. diff --git a/config.yml b/config.yml index 53db2c7..7eb6ca6 100644 --- a/config.yml +++ b/config.yml @@ -9,10 +9,17 @@ lang: "en" # Plugins, implemented in ./plugins/PLUGIN_NAME # Use {{ vars.PLUGIN_NAME }} in the settings below +# The output of the plugin can be used below, e.g., {{vars.MediumFollowersCountPlugin}} plugins: # Automatically fetch Medium follower count - MediumFollowersCountPlugin: username: zhgchgli + # Automatically fetch Github repo star count + - GithubRepoStarsCountPlugin: + - ZhgChgLi/ZMarkupParser + - ZhgChgLi/ZReviewTender + - ZhgChgLi/ZMediumToMarkdown + - ZhgChgLi/linkyee # Google Analytics tracking id google_analytics_id: @@ -32,39 +39,66 @@ tagline: >- # List of links # icon: Use Font Awesome icons (https://fontawesome.com/search?o=r&m=free) -# title: The displayed text for the link +# text: The displayed text for the link +# title: The url title # url: The URL of the link # alt: Alternative text for accessibility # target: `_blank` opens in a new tab, `_self` opens in the same frame links: - link: icon: "fa-brands fa-medium" - title: "Tech Blog ({{vars.MediumFollowersCountPlugin}} Followers)" + text: "Tech Blog ({{vars.MediumFollowersCountPlugin}} Followers)" url: "https://blog.zhgchg.li" alt: "ZhgChgLi's Tech Blog" + title: "ZhgChgLi's Tech Blog" target: "_blank" - link: icon: "fa-brands fa-medium" - title: "Travelog ({{vars.MediumFollowersCountPlugin}} Followers)" + text: "Travelog ({{vars.MediumFollowersCountPlugin}} Followers)" url: "https://medium.com/ztravel" alt: "ZhgChgLi's Travelog" + title: "ZhgChgLi's Travelog" target: "_blank" - link: icon: "fa-solid fa-rss" - title: "Website" + text: "Website" url: "https://zhgchg.li/" alt: "ZhgChgLi's Website" + title: "ZhgChgLi's Website" target: "_blank" - link: - icon: "fa-brands fa-instagram" - title: "Instagram" - url: "https://www.instagram.com/zhgchgli/" - alt: "ZhgChgLi's Instagram" + icon: "fa-brands fa-swift" + text: "ZMarkupParser ({{vars.GithubRepoStarsCountPlugin['ZhgChgLi/ZMarkupParser']}} Stars)" + url: "https://github.com/ZhgChgLi/ZMarkupParser" + alt: "ZMarkupParser is a pure-Swift library that helps you to convert HTML strings to NSAttributedString with customized style and tags." + title: "ZMarkupParser is a pure-Swift library that helps you to convert HTML strings to NSAttributedString with customized style and tags." target: "_blank" + - link: + icon: "fa-brands fa-app-store-ios" + text: "ZReviewTender ({{vars.GithubRepoStarsCountPlugin['ZhgChgLi/ZReviewTender']}} Stars)" + url: "https://github.com/ZhgChgLi/ZReviewTender" + alt: "ZReviewTender is a tool for fetching app reviews from the App Store and Google Play Console and integrating them into your workflow." + title: "ZReviewTender is a tool for fetching app reviews from the App Store and Google Play Console and integrating them into your workflow." + target: "_blank" + - link: + icon: "fa-brands fa-markdown" + text: "ZMediumToMarkdown ({{vars.GithubRepoStarsCountPlugin['ZhgChgLi/ZMediumToMarkdown']}} Stars)" + url: "https://github.com/ZhgChgLi/ZMediumToMarkdown" + alt: "ZMediumToMarkdown is a powerful tool that allows you to effortlessly download and convert your Medium posts to Markdown format." + title: "ZMediumToMarkdown is a powerful tool that allows you to effortlessly download and convert your Medium posts to Markdown format." + target: "_blank" + - link: + icon: "fa-brands fa-github" + text: "linkyee ({{vars.GithubRepoStarsCountPlugin['ZhgChgLi/linkyee']}} Stars)" + url: "https://github.com/ZhgChgLi/linkyee" + alt: "linkyee is a fully customized, open-source LinkTree alternative deployed directly on GitHub Pages." + title: "linkyee is a fully customized, open-source LinkTree alternative deployed directly on GitHub Pages." + target: "_blank" + # List of social media links # icon: Use Font Awesome icons (https://fontawesome.com/search?o=r&m=free) -# title: The displayed title for the social media link +# title: The url title # url: The URL of the social media link # alt: Alternative text for accessibility # target: _blank opens in a new tab, _self opens in the same frame @@ -93,6 +127,12 @@ socials: title: "ZhgChgLi's LinkedIn" alt: "ZhgChgLi's LinkedIn" target: "_blank" + - social: + icon: "fa-brands fa-instagram" + url: "https://www.instagram.com/zhgchgli/" + title: "Instagram" + alt: "ZhgChgLi's Instagram" + target: "_blank" - social: icon: "fa-solid fa-envelope" url: "mailto:zhgchgli@gmail.com" diff --git a/plugins/GithubRepoStarsCountPlugin.rb b/plugins/GithubRepoStarsCountPlugin.rb new file mode 100644 index 0000000..becfa66 --- /dev/null +++ b/plugins/GithubRepoStarsCountPlugin.rb @@ -0,0 +1,44 @@ +require_relative 'Plugin' +require 'net/http' +require 'nokogiri' +require 'uri' + +class GithubRepoStarsCountPlugin < Plugin + attr_reader :data, :repos + + def initialize(data) + @data = data + + repos = {} + data[0].each do |repo| + repos[repo] = 0 + end + @repos = repos + end + + def execute + + repos.each do |repo, value| + repos[repo] = load_repo_stars(repo) + end + + return repos + end + + def load_repo_stars(repo) + uri = URI("https://github.com/#{repo}") + + response = Net::HTTP.get_response(uri) + case response + when Net::HTTPSuccess then + document = Nokogiri::HTML(response.body) + stargazers_count_element = document.at('span#repo-stars-counter-star') + stargazers_count = stargazers_count_element&.text + + return stargazers_count || 0 + else + return 0 + end + end + +end \ No newline at end of file diff --git a/scaffold.rb b/scaffold.rb index e4586c7..42b0c5f 100644 --- a/scaffold.rb +++ b/scaffold.rb @@ -69,6 +69,7 @@ if !settings["links"].nil? settings["links"][index]["link"]["url"] = Liquid::Template.parse(settings["links"][index]["link"]["url"]).render(settings) settings["links"][index]["link"]["alt"] = Liquid::Template.parse(settings["links"][index]["link"]["alt"]).render(settings) settings["links"][index]["link"]["title"] = Liquid::Template.parse(settings["links"][index]["link"]["title"]).render(settings) + settings["links"][index]["link"]["text"] = Liquid::Template.parse(settings["links"][index]["link"]["text"]).render(settings) end end diff --git a/themes/default/index.html b/themes/default/index.html index 1107622..510b92c 100644 --- a/themes/default/index.html +++ b/themes/default/index.html @@ -17,8 +17,8 @@ @@ -27,7 +27,7 @@
{% for item in socials %} {% assign social = item.social %} - + {% endfor %} @@ -43,13 +43,13 @@ {% if google_analytics_id %} - + {% endif %}