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