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`
This commit is contained in:
Rohan Deb Sarkar 2022-07-24 22:45:39 +05:30 committed by GitHub
parent 99b14c436f
commit f618757b63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 125 additions and 5 deletions

View File

@ -439,6 +439,32 @@ Easily create beautiful grids within your blog posts and project pages:
### Other features ### 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.
```
<!-- code for GitHub users -->
{% if site.data.repositories.github_users %}
<div class="repositories d-flex flex-wrap flex-md-row flex-column justify-content-between align-items-center">
{% for user in site.data.repositories.github_users %}
{% include repository/repo_user.html username=user %}
{% endfor %}
</div>
{% endif %}
<!-- code for GitHub repositories -->
{% if site.data.repositories.github_repos %}
<div class="repositories d-flex flex-wrap flex-md-row flex-column justify-content-between align-items-center">
{% for repo in site.data.repositories.github_repos %}
{% include repository/repo.html repository=repo %}
{% endfor %}
</div>
{% endif %}
```
#### Theming #### Theming
Six beautiful theme colors have been selected to choose from. 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. The default is purple, but you can quickly change it by editing `$theme-color` variable in the `_sass/_themes.scss` file.

View File

@ -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 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 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 # 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 and syntax highlight
markdown: kramdown markdown: kramdown
highlighter: rouge 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: kramdown:
input: GFM input: GFM
syntax_highlighter_opts: syntax_highlighter_opts:

12
_data/repositories.yml Normal file
View File

@ -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

View File

@ -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 %}
<div class="repo p-2 text-center">
<a href="https://github.com/{{ include.repository }}">
<img class="repo-img-light w-100" alt="{{ include.repository }}" src="https://github-readme-stats.vercel.app/api/pin/?username={{ repo_url.first }}&repo={{ repo_url.last }}&theme={{ site.repo_theme_light }}&show_owner={{ show_owner }}">
<img class="repo-img-dark w-100" alt="{{ include.repository }}" src="https://github-readme-stats.vercel.app/api/pin/?username={{ repo_url.first }}&repo={{ repo_url.last }}&theme={{ site.repo_theme_dark }}&show_owner={{ show_owner }}">
</a>
</div>

View File

@ -0,0 +1,6 @@
<div class="repo p-2 text-center">
<a href="https://github.com/{{ include.username }}">
<img class="repo-img-light w-100" alt="{{ include.username }}" src="https://github-readme-stats.vercel.app/api/?username={{ include.username }}&theme={{ site.repo_theme_light }}&show_icons=true">
<img class="repo-img-dark w-100" alt="{{ include.username }}" src="https://github-readme-stats.vercel.app/api/?username={{ include.username }}&theme={{ site.repo_theme_dark }}&show_icons=true">
</a>
</div>

View File

@ -3,6 +3,6 @@ layout: cv
permalink: /cv/ permalink: /cv/
title: cv title: cv
nav: true nav: true
nav_order: 3 nav_order: 4
cv_pdf: example_pdf.pdf cv_pdf: example_pdf.pdf
--- ---

View File

@ -2,7 +2,7 @@
layout: page layout: page
title: submenus title: submenus
nav: true nav: true
nav_order: 5 nav_order: 6
dropdown: true dropdown: true
children: children:
- title: publications - title: publications

30
_pages/repositories.md Normal file
View File

@ -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 %}
<div class="repositories d-flex flex-wrap flex-md-row flex-column justify-content-between align-items-center">
{% for user in site.data.repositories.github_users %}
{% include repository/repo_user.html username=user %}
{% endfor %}
</div>
{% endif %}
---
## GitHub Repositories
{% if site.data.repositories.github_repos %}
<div class="repositories d-flex flex-wrap flex-md-row flex-column justify-content-between align-items-center">
{% for repo in site.data.repositories.github_repos %}
{% include repository/repo.html repository=repo %}
{% endfor %}
</div>
{% endif %}

View File

@ -4,7 +4,7 @@ permalink: /teaching/
title: teaching title: teaching
description: Materials for courses you taught. Replace this text with your description. description: Materials for courses you taught. Replace this text with your description.
nav: true 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. 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.

View File

@ -312,6 +312,14 @@ footer.sticky-bottom {
} }
} }
// Repositories
@media (min-width: 768px) {
.repo {
max-width: 50%;
}
}
// Blog // Blog
.header-bar { .header-bar {

View File

@ -24,6 +24,13 @@
padding-top: 12px; padding-top: 12px;
display : block; display : block;
} }
.repo-img-light {
display: block;
}
.repo-img-dark {
display: none;
}
} }
html[data-theme='dark'] { html[data-theme='dark'] {
@ -48,4 +55,11 @@ html[data-theme='dark'] {
.fa-moon { .fa-moon {
display : none; display : none;
} }
.repo-img-light {
display: none;
}
.repo-img-dark {
display: block;
}
} }