|
| 1 | +{% extends '_layout.njk' %} |
| 2 | +{% import '_macro/sidebar.njk' as sidebar_template with context %} |
| 3 | + |
| 4 | +{% block title %}{{ page.title }}{% endblock %} |
| 5 | + |
| 6 | +{% block class %}archive posts-collapse{% endblock %} |
| 7 | + |
| 8 | +{% block content %} |
| 9 | + |
| 10 | +<style> |
| 11 | + .card-container, .project-container { |
| 12 | + display: flex; |
| 13 | + flex-wrap: wrap; |
| 14 | + gap: 20px; |
| 15 | + justify-content: space-between; |
| 16 | + margin: 0; |
| 17 | + padding: 0; |
| 18 | + } |
| 19 | +
|
| 20 | + .project { |
| 21 | + width: 48%; /* Full width for each project */ |
| 22 | + padding: 15px; |
| 23 | + padding-top: 4px; |
| 24 | + box-sizing: border-box; |
| 25 | + background-color: #f9f9f9; |
| 26 | + border: 1px solid #ddd; |
| 27 | + border-radius: 8px; |
| 28 | + box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.1); |
| 29 | + text-align: left; |
| 30 | + text-decoration: none; |
| 31 | + color: #333; |
| 32 | + display: flex; |
| 33 | + flex-direction: column; |
| 34 | + gap: 10px; |
| 35 | + } |
| 36 | +
|
| 37 | + .project:hover { |
| 38 | + cursor: pointer; |
| 39 | + border-color: #bbb; |
| 40 | + } |
| 41 | +
|
| 42 | + .project-header { |
| 43 | + display: flex; |
| 44 | + align-items: center; |
| 45 | + justify-content: space-between; |
| 46 | + margin-bottom: 10px; |
| 47 | + } |
| 48 | +
|
| 49 | + .project-logo { |
| 50 | + max-height: 50px; |
| 51 | + object-fit: contain; |
| 52 | + margin-right: 2px; |
| 53 | + } |
| 54 | +
|
| 55 | + .project-name { |
| 56 | + font-size: 20px; |
| 57 | + font-weight: bold; |
| 58 | + flex-grow: 1; |
| 59 | + } |
| 60 | +
|
| 61 | + .project-description { |
| 62 | + font-size: 14px; |
| 63 | + } |
| 64 | +
|
| 65 | + .project-details { |
| 66 | + display: flex; |
| 67 | + justify-content: flex-start; |
| 68 | + gap: 20px; /* Add space between details */ |
| 69 | + font-size: 12px; |
| 70 | + color: #666; |
| 71 | + } |
| 72 | +
|
| 73 | + /* Fixed widths for consistent vertical alignment */ |
| 74 | + .project-details .language { |
| 75 | + width: 50px; /* Fixed width for language */ |
| 76 | + } |
| 77 | +
|
| 78 | + .project-details .stars, .project-details .forks { |
| 79 | + width: 30px; /* Fixed width for stars and forks */ |
| 80 | + } |
| 81 | +
|
| 82 | + .project-details span { |
| 83 | + display: flex; |
| 84 | + align-items: center; |
| 85 | + gap: 5px; |
| 86 | + justify-content: space-between; |
| 87 | + } |
| 88 | +
|
| 89 | + .project-details i { |
| 90 | + color: #333; |
| 91 | + } |
| 92 | +
|
| 93 | + @media (max-width: 800px) { |
| 94 | + .project { |
| 95 | + width: calc(100% - 20px); /* Full width on smaller screens */ |
| 96 | + margin: 0 auto; |
| 97 | + } |
| 98 | +
|
| 99 | + /* Remove fixed widths on smaller screens for flexibility */ |
| 100 | + .project-details .language, |
| 101 | + .project-details .stars, |
| 102 | + .project-details .forks { |
| 103 | + width: auto; |
| 104 | + } |
| 105 | + } |
| 106 | +</style> |
| 107 | + |
| 108 | +<h1>Open Source Projects</h1> |
| 109 | +<div class="intro"> |
| 110 | + <p>{{ page.content }}</p> |
| 111 | +</div> |
| 112 | + |
| 113 | +{% for section in page.sections %} |
| 114 | + <section class="github-section"> |
| 115 | + <h3>{{ section.title }}</h3> |
| 116 | + {% if section.description %} |
| 117 | + <p>{{ section.description }}</p> |
| 118 | + {% endif %} |
| 119 | + |
| 120 | + <div class="project-container"> |
| 121 | + {% for item in section.items %} |
| 122 | + <a href="{{ item.url or item.github_url }}" class="project" data-repo="{{ item.github_url }}"> |
| 123 | + <div class="project-header"> |
| 124 | + <span> |
| 125 | + <div class="project-name">{{ item.name }}</div> |
| 126 | + {% if item.github_url %} |
| 127 | + <div class="project-details"> |
| 128 | + <!-- Fixed width for consistent alignment, using FontAwesome icons --> |
| 129 | + <span class="language"><i class="fas fa-code"></i> <span id="{{ item.name | lower | replace(' ', '-') }}-language">...</span></span> |
| 130 | + <span class="stars"><i class="far fa-star"></i> <span id="{{ item.name | lower | replace(' ', '-') }}-stars">...</span></span> |
| 131 | + <span class="forks"><i class="fas fa-code-branch"></i> <span id="{{ item.name | lower | replace(' ', '-') }}-forks">...</span></span> |
| 132 | + </div> |
| 133 | + {% endif %} |
| 134 | + </span> |
| 135 | + {% if item.logo %} |
| 136 | + <span style="width: {{ item.logo_scale or '100%' }}"> |
| 137 | + <img src="{{ item.logo }}" alt="{{ item.name }} logo" class="project-logo"> |
| 138 | + </span> |
| 139 | + {% endif %} |
| 140 | + </div> |
| 141 | + <div class="project-description">{{ item.description }}</div> |
| 142 | + </a> |
| 143 | + {% endfor %} |
| 144 | + </div> |
| 145 | + </section> |
| 146 | +{% endfor %} |
| 147 | + |
| 148 | +<script src="https://kit.fontawesome.com/a076d05399.js" crossorigin="anonymous"></script> <!-- FontAwesome Kit --> |
| 149 | +<script> |
| 150 | + document.addEventListener('DOMContentLoaded', function () { |
| 151 | + const projects = document.querySelectorAll('.project'); |
| 152 | +
|
| 153 | + projects.forEach(project => { |
| 154 | + const githubUrl = project.getAttribute('data-repo'); |
| 155 | + if (githubUrl) { |
| 156 | + // Construct the GitHub API URL by inserting "api." after "https://" |
| 157 | + const apiUrl = githubUrl.replace('https://github.com/', 'https://api.github.com/repos/'); |
| 158 | +
|
| 159 | + fetch(apiUrl) |
| 160 | + .then(response => response.json()) |
| 161 | + .then(data => { |
| 162 | + // Use project name to generate IDs |
| 163 | + const idPrefix = data.name.toLowerCase().replace(/ /g, '-'); |
| 164 | +
|
| 165 | + document.getElementById(`${idPrefix}-language`).textContent = data.language || 'N/A'; |
| 166 | + document.getElementById(`${idPrefix}-stars`).textContent = data.stargazers_count || 0; |
| 167 | + document.getElementById(`${idPrefix}-forks`).textContent = data.forks_count || 0; |
| 168 | + }) |
| 169 | + .catch(error => console.error('Error fetching GitHub data:', error)); |
| 170 | + } |
| 171 | + }); |
| 172 | + }); |
| 173 | +</script> |
| 174 | +{% endblock %} |
0 commit comments