Added a new development page where it shows the status of the site
This commit is contained in:
74
src/pages/development.astro
Normal file
74
src/pages/development.astro
Normal file
@@ -0,0 +1,74 @@
|
||||
---
|
||||
import Layout from '../layouts/Layout.astro';
|
||||
import { getPermalink } from '../utils/permalinks';
|
||||
import { getTranslation } from '../i18n/translations';
|
||||
|
||||
const lang = Astro.params.lang || 'en';
|
||||
const t = getTranslation(lang);
|
||||
|
||||
// Fetch Git repository data at build time
|
||||
const GIT_API_URL = 'https://git.365devnet.eu/api/v4/projects/Richard%2F365devnet';
|
||||
const GIT_COMMITS_URL = `${GIT_API_URL}/repository/commits`;
|
||||
|
||||
// Fetch commits data
|
||||
let commits: any[] = [];
|
||||
try {
|
||||
const commitsResponse = await fetch(GIT_COMMITS_URL, {
|
||||
headers: {
|
||||
'PRIVATE-TOKEN': import.meta.env.GITLAB_TOKEN || '',
|
||||
},
|
||||
});
|
||||
|
||||
if (commitsResponse.ok) {
|
||||
commits = await commitsResponse.json();
|
||||
} else {
|
||||
console.error('Failed to fetch commits:', commitsResponse.statusText);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error fetching commits:', error);
|
||||
}
|
||||
|
||||
// Format date to a readable format
|
||||
const formatDate = (dateString: string) => {
|
||||
return new Date(dateString).toLocaleDateString(lang, {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric',
|
||||
});
|
||||
};
|
||||
---
|
||||
|
||||
<Layout>
|
||||
<div class="max-w-4xl mx-auto px-4 py-8">
|
||||
<h1 class="text-4xl font-bold mb-8">{t.development.title || 'Development Progress'}</h1>
|
||||
|
||||
<div class="space-y-8">
|
||||
<section>
|
||||
<h2 class="text-2xl font-semibold mb-4">{t.development.latestCommits || 'Latest Commits'}</h2>
|
||||
{commits.length > 0 ? (
|
||||
<div class="space-y-4">
|
||||
{commits.slice(0, 10).map((commit) => (
|
||||
<div class="bg-gray-50 dark:bg-gray-800 p-4 rounded-lg">
|
||||
<div class="flex justify-between items-start">
|
||||
<div>
|
||||
<h3 class="font-medium">{commit.title}</h3>
|
||||
<p class="text-sm text-gray-600 dark:text-gray-400">{commit.message}</p>
|
||||
</div>
|
||||
<span class="text-sm text-gray-500">{formatDate(commit.committed_date)}</span>
|
||||
</div>
|
||||
<div class="mt-2 text-sm">
|
||||
<span class="text-gray-500">Commit:</span>{" "}
|
||||
<code class="bg-gray-100 dark:bg-gray-700 px-2 py-1 rounded">
|
||||
{commit.id.slice(0, 7)}
|
||||
</code>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<p class="text-gray-600 dark:text-gray-400">Unable to fetch commit history at this time.</p>
|
||||
)}
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</Layout>
|
||||
Reference in New Issue
Block a user