From f618757b63cf2c41ff1c26953e8c49c94c2e53f7 Mon Sep 17 00:00:00 2001 From: Rohan Deb Sarkar Date: Sun, 24 Jul 2022 22:45:39 +0530 Subject: [PATCH] Adds support for repositories (#760) * Add support for github repo cards * add support for dark theme * Add support for custom theme * repositories * fix * make it simpler * spcaing * responsive fix * adds support for usernames * make it modular * fix * show icons * cache_seconds * fix * Revert "cache_seconds" This reverts commit a9dd4d5d43d212676e1c1dba8ec8086c7fdb7cd7. * add last line * fix * github only * fix * Add instructions * Add `README.md` instructions * Add `nav_order` --- README.md | 26 +++++++++++++++++++++++++ _config.yml | 14 ++++++++++++-- _data/repositories.yml | 12 ++++++++++++ _includes/repository/repo.html | 14 ++++++++++++++ _includes/repository/repo_user.html | 6 ++++++ _pages/cv.md | 2 +- _pages/dropdown.md | 2 +- _pages/repositories.md | 30 +++++++++++++++++++++++++++++ _pages/teaching.md | 2 +- _sass/_base.scss | 8 ++++++++ _sass/_themes.scss | 14 ++++++++++++++ 11 files changed, 125 insertions(+), 5 deletions(-) create mode 100644 _data/repositories.yml create mode 100644 _includes/repository/repo.html create mode 100644 _includes/repository/repo_user.html create mode 100644 _pages/repositories.md diff --git a/README.md b/README.md index 566d35e..c9b9a71 100644 --- a/README.md +++ b/README.md @@ -439,6 +439,32 @@ Easily create beautiful grids within your blog posts and project pages: ### Other features +#### GitHub repositories and user stats +**al-folio** uses [github-readme-stats](https://github.com/anuraghazra/github-readme-stats) to display GitHub repositories and user stats on the the `/repositories/` page. + +Edit the `_data/repositories.yml` and change the `github_users` and `github_repos` lists to include your own GitHub profile and repositories to the the `/repositories/` page. + +You may also use the following codes for displaying this in any other pages. +``` + +{% if site.data.repositories.github_users %} +
+ {% for user in site.data.repositories.github_users %} + {% include repository/repo_user.html username=user %} + {% endfor %} +
+{% endif %} + + +{% if site.data.repositories.github_repos %} +
+ {% for repo in site.data.repositories.github_repos %} + {% include repository/repo.html repository=repo %} + {% endfor %} +
+{% endif %} +``` + #### Theming Six beautiful theme colors have been selected to choose from. The default is purple, but you can quickly change it by editing `$theme-color` variable in the `_sass/_themes.scss` file. diff --git a/_config.yml b/_config.yml index 78c02ae..f91243d 100644 --- a/_config.yml +++ b/_config.yml @@ -23,6 +23,18 @@ baseurl: /al-folio # the subpath of your site, e.g. /blog/ last_updated: false # set to true if you want to display last updated in the footer impressum_path: # set to path to include impressum link in the footer, use the same path as permalink in a page, helps to conform with EU GDPR +# ----------------------------------------------------------------------------- +# Theme +# ----------------------------------------------------------------------------- + +# code highlighter theme +highlight_theme_light: github # https://github.com/jwarby/jekyll-pygments-themes +highlight_theme_dark: native # https://github.com/jwarby/jekyll-pygments-themes + +# repo color theme +repo_theme_light: default # https://github.com/anuraghazra/github-readme-stats/blob/master/themes/README.md +repo_theme_dark: dark # https://github.com/anuraghazra/github-readme-stats/blob/master/themes/README.md + # ----------------------------------------------------------------------------- # RSS Feed # ----------------------------------------------------------------------------- @@ -133,8 +145,6 @@ news_limit: 5 # leave blank to include all the news in the `_news` folder # Markdown and syntax highlight markdown: kramdown highlighter: rouge -highlight_theme_light: github # https://github.com/jwarby/jekyll-pygments-themes -highlight_theme_dark: native # https://github.com/jwarby/jekyll-pygments-themes kramdown: input: GFM syntax_highlighter_opts: diff --git a/_data/repositories.yml b/_data/repositories.yml new file mode 100644 index 0000000..5205c9f --- /dev/null +++ b/_data/repositories.yml @@ -0,0 +1,12 @@ +github_users: + - torvalds + - alshedivat + +github_repos: + - alshedivat/al-folio + - twbs/bootstrap + - jekyll/jekyll + - jquery/jquery + - FortAwesome/Font-Awesome + - jpswalsh/academicons + - mathjax/MathJax diff --git a/_includes/repository/repo.html b/_includes/repository/repo.html new file mode 100644 index 0000000..6344b86 --- /dev/null +++ b/_includes/repository/repo.html @@ -0,0 +1,14 @@ +{% assign repo_url = include.repository | split: '/' %} + +{% if site.data.repositories.github_users contains repo_url.first %} + {% assign show_owner = false %} +{% else %} + {% assign show_owner = true %} +{% endif %} + +
+ + {{ include.repository }} + {{ include.repository }} + +
diff --git a/_includes/repository/repo_user.html b/_includes/repository/repo_user.html new file mode 100644 index 0000000..ae06a05 --- /dev/null +++ b/_includes/repository/repo_user.html @@ -0,0 +1,6 @@ +
+ + {{ include.username }} + {{ include.username }} + +
diff --git a/_pages/cv.md b/_pages/cv.md index d879c1f..65d016a 100644 --- a/_pages/cv.md +++ b/_pages/cv.md @@ -3,6 +3,6 @@ layout: cv permalink: /cv/ title: cv nav: true -nav_order: 3 +nav_order: 4 cv_pdf: example_pdf.pdf --- diff --git a/_pages/dropdown.md b/_pages/dropdown.md index 4a8a805..7ac6574 100644 --- a/_pages/dropdown.md +++ b/_pages/dropdown.md @@ -2,7 +2,7 @@ layout: page title: submenus nav: true -nav_order: 5 +nav_order: 6 dropdown: true children: - title: publications diff --git a/_pages/repositories.md b/_pages/repositories.md new file mode 100644 index 0000000..57ef220 --- /dev/null +++ b/_pages/repositories.md @@ -0,0 +1,30 @@ +--- +layout: page +permalink: /repositories/ +title: repositories +description: Edit the `_data/repositories.yml` and change the `github_users` and `github_repos` lists to include your own GitHub profile and repositories. +nav: true +nav_order: 3 +--- + +## GitHub users + +{% if site.data.repositories.github_users %} +
+ {% for user in site.data.repositories.github_users %} + {% include repository/repo_user.html username=user %} + {% endfor %} +
+{% endif %} + +--- + +## GitHub Repositories + +{% if site.data.repositories.github_repos %} +
+ {% for repo in site.data.repositories.github_repos %} + {% include repository/repo.html repository=repo %} + {% endfor %} +
+{% endif %} diff --git a/_pages/teaching.md b/_pages/teaching.md index 1a6c5be..ea93b1c 100644 --- a/_pages/teaching.md +++ b/_pages/teaching.md @@ -4,7 +4,7 @@ permalink: /teaching/ title: teaching description: Materials for courses you taught. Replace this text with your description. nav: true -nav_order: 4 +nav_order: 5 --- For now, this page is assumed to be a static description of your courses. You can convert it to a collection similar to `_projects/` so that you can have a dedicated page for each course. diff --git a/_sass/_base.scss b/_sass/_base.scss index 887eb9c..a755d59 100644 --- a/_sass/_base.scss +++ b/_sass/_base.scss @@ -312,6 +312,14 @@ footer.sticky-bottom { } } +// Repositories + +@media (min-width: 768px) { + .repo { + max-width: 50%; + } +} + // Blog .header-bar { diff --git a/_sass/_themes.scss b/_sass/_themes.scss index 118bca7..ddab07f 100644 --- a/_sass/_themes.scss +++ b/_sass/_themes.scss @@ -24,6 +24,13 @@ padding-top: 12px; display : block; } + + .repo-img-light { + display: block; + } + .repo-img-dark { + display: none; + } } html[data-theme='dark'] { @@ -48,4 +55,11 @@ html[data-theme='dark'] { .fa-moon { display : none; } + + .repo-img-light { + display: none; + } + .repo-img-dark { + display: block; + } }