Skip to content

Commit

Permalink
Added commit log
Browse files Browse the repository at this point in the history
  • Loading branch information
tassyguy committed Oct 16, 2023
1 parent 12700d5 commit a05191e
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 2 deletions.
9 changes: 9 additions & 0 deletions getLastCommitTimestamp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// getLastCommitTimestamp.js
const { execSync } = require('child_process');
const fs = require('fs');

const lastCommitTimestamp = execSync('git log -1 --format=%cd --date=iso')
.toString()
.trim();

fs.writeFileSync('public/lastCommitTimestamp.txt', lastCommitTimestamp);
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.1.0",
"private": true,
"scripts": {
"post-commit": "node getLastCommitTimestamp.js",
"dev": "node server.js",
"build": "next build",
"start": "next start",
Expand Down Expand Up @@ -34,4 +35,4 @@
"tailwindcss": "^3",
"typescript": "^5"
}
}
}
1 change: 1 addition & 0 deletions public/lastCommitTimestamp.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2023-10-16 14:42:04 -0400
2 changes: 2 additions & 0 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import React from 'react';
import Image from 'next/image';
import Header from '../components/Header';
import LastCommitTimestamp from '@/components/LastCommitTimestamp';
import Link from 'next/link';
import '../../styles/styles.scss';

Expand All @@ -17,6 +18,7 @@ const Home: React.FC = () => { // Get the section ID from the URL
<p>It&apos;s fine, I&apos;m fine. 🙃</p>
<p>This site was built using Next.JS, TypeScript, React, SCSS, and deployed using GitHub Actions.</p>
<Link href='https://github.com/tassyguy/my-resume-website'>Check out the repo for this website here!</Link>
<LastCommitTimestamp/>
<p>Current site roadmap:</p>
<ul className='features'>
<li>✅Write site in Next.JS</li>
Expand Down
30 changes: 30 additions & 0 deletions src/components/LastCommitTimestamp.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// LastCommitTimestamp.js
'use client';

import React, { useState, useEffect } from 'react';

const LastCommitTimestamp = () => {
const [timestamp, setTimestamp] = useState('');

useEffect(() => {
async function fetchTimestamp() {
try {
const response = await fetch('/lastCommitTimestamp.txt');
const data = await response.text();
setTimestamp(data);
} catch (error) {
console.error('Error fetching last commit timestamp:', error);
}
}

fetchTimestamp();
}, []);

return (
<div className={'timestamp'}>
Last Commit Timestamp: {timestamp}
</div>
);
};

export default LastCommitTimestamp;
2 changes: 1 addition & 1 deletion styles/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ body {
background-color: var(--md-sys-color-background);
}

p, ul, li, .section-header, .portfolio-header, .school, .about, .job-info {
p, ul, li, .section-header, .portfolio-header, .school, .about, .job-info, .timestamp {
color: var(--md-sys-color-on-background);
}

Expand Down

0 comments on commit a05191e

Please sign in to comment.