Skip to content

Commit 5f14c52

Browse files
committed
single line message in Footer
1 parent f98008a commit 5f14c52

File tree

10 files changed

+50
-35
lines changed

10 files changed

+50
-35
lines changed

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ curl http://152.70.160.21:1080
99
ssh -R 1080:localhost:3000 amd2
1010
curl http://amd2.nemanjamitic.com:1080
1111

12-
# flush
12+
# flush, works without server and ssh reboot
1313
sudo iptables -F
1414
# list
1515
sudo iptables -L

docs/working-notes/todo3.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,12 +412,13 @@ style giscus, tags and share, astrowind, use existing styleguide
412412
move giscus mode, add another theme change event handler
413413
fix content width
414414
migrate scroll to top and toast to react
415-
fix footer
416-
fix share, just small gray icons
415+
fix footer
416+
fix share, just small gray icons
417417
use vertical margins and margin collapsing for all vertical spacings, no paddings, when in same parent
418418
remove tag-lg, fix button size on mobile
419419
alert component style
420420
improve lighthouse, accessibility, aria attrs
421421
2 prerendered paginations, 3 and 5 items
422+
must export_ vars in .mdx or acor error, ask?
422423
```
423424

src/components/Footer.astro

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,38 @@ import Link from '@/components/Link.astro';
66
import { ROUTES } from '@/constants/routes';
77
import { CONFIG } from '@/config';
88
import { getLatestCommitInfo } from '@/libs/git';
9-
import { trimHttpProtocol } from '@/utils/strings';
9+
import { shortDate } from '@/utils/datetime';
10+
import { limitString, trimHttpProtocol } from '@/utils/strings';
1011
11-
const { SITE_URL, AUTHOR_LINKEDIN, AUTHOR_GITHUB } = CONFIG;
12+
const { SITE_URL, AUTHOR_LINKEDIN, AUTHOR_GITHUB, REPO_URL } = CONFIG;
1213
const domain = trimHttpProtocol(SITE_URL);
14+
const messageLength = 20 as const;
15+
16+
const { time, fullHash, message } = getLatestCommitInfo();
17+
18+
const commitUrl = `${REPO_URL}/commit/${fullHash}`;
19+
20+
const shortDateStr = shortDate(new Date(time));
21+
const trimmedMessage = limitString(message, messageLength);
1322
14-
const { time, hash, message } = getLatestCommitInfo();
1523
// footer is full width for border, div has max-w
1624
---
1725

1826
<footer class="border-t border-base-300 py-8 px-4">
1927
<div class="max-w-6xl md:mx-auto flex justify-center md:justify-start">
2028
<div class="flex justify-between gap-4 flex-col-reverse md:flex-row md:w-full">
21-
<div class="flex gap-2 flex-col text-sm text-content">
22-
<div class="flex gap-2 flex-col md:flex-row">
23-
<label class="font-bold text-nowrap">Under construciton:</label>
24-
<div class="flex gap-2 flex-col md:flex-row">
25-
<Link href="https://github.com/paularmstrong/paularmstrong.dev">Starter project</Link>
26-
<Link href="https://github.com/nemanjam/nemanjam.github.io#references">
27-
All references
28-
</Link>
29-
</div>
30-
</div>
31-
<div class="flex gap-2 flex-col md:flex-row">
32-
<label class="font-bold text-nowrap">Latest commit:</label>
33-
<div class="flex gap-2 flex-col xs:flex-row flex-wrap">
34-
<span>{time}</span>
35-
<span>{hash}</span>
36-
<span>{message}</span>
37-
</div>
38-
</div>
29+
<!-- left column -->
30+
<div class="flex items-center gap-2 flex-wrap text-sm text-content whitespace-nowrap">
31+
<label class="font-bold">Latest commit:</label>
32+
<span class="flex items-center gap-2 flex-wrap">
33+
<span> {shortDateStr} </span>
34+
<Link href={commitUrl} title="Commit url" target="_blank">
35+
{trimmedMessage}
36+
</Link>
37+
</span>
3938
</div>
4039

40+
<!-- right column -->
4141
<ul class="flex gap-2 flex-wrap xs:flex-nowrap lg:items-center">
4242
<li>
4343
<Link

src/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ dotenv.config({ path: envFileName });
2828
const configData: ConfigType = {
2929
NODE_ENV: process.env.NODE_ENV,
3030
PREVIEW_MODE: process.env.PREVIEW_MODE,
31-
/** without '/' */
31+
/** all urls without '/' */
3232
SITE_URL: process.env.SITE_URL,
3333
SITE_TITLE: 'Nemanja Mitic',
3434
SITE_DESCRIPTION: 'I am Nemanja, full stack developer',
@@ -38,6 +38,7 @@ const configData: ConfigType = {
3838
AUTHOR_EMAIL: '[email protected]',
3939
AUTHOR_GITHUB: 'https://github.com/nemanjam',
4040
AUTHOR_LINKEDIN: 'https://www.linkedin.com/in/nemanja-mitic',
41+
REPO_URL: 'https://github.com/nemanjam/nemanjam.github.io',
4142
};
4243

4344
// todo: Config should go into import.meta.env in astro.config.ts

src/constants/metadata.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const { SITE_URL, SITE_DESCRIPTION, SITE_TITLE } = CONFIG;
1212
/** Must be url from public folder. */
1313
export const defaultOgImage = `${SITE_URL}/images/default/default-open-graph-image.jpg`;
1414

15-
export const dotSeparator = '';
15+
export const titleSeparator = '-';
1616

1717
export const DEFAULT_METADATA: Required<Metadata> = {
1818
title: SITE_TITLE,

src/constants/routes.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* Folders - all urls with both leading and trailing '/'.
3+
* Files - without trailing '/'.
4+
*/
5+
16
export const ROUTES = {
27
HOME: '/',
38
BLOG: '/blog/',

src/libs/git.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,25 @@ import { execSync } from 'child_process';
22

33
export interface GitResult {
44
time: string;
5-
hash: string;
5+
shortHash: string;
6+
fullHash: string;
67
message: string;
78
}
89

910
export const getLatestCommitInfo = (): GitResult => {
1011
const separator = '___';
11-
const command = `git log -1 --pretty=format:"%ad${separator}%h${separator}%s" --date=format:'%Y-%m-%d %H:%M:%S'`;
12+
const command = `git log -1 --pretty=format:"%ad${separator}%h${separator}%H${separator}%s" --date=format:'%Y-%m-%d %H:%M:%S'`;
1213
const output = execSync(command).toString().trim().split(separator);
1314

14-
if (output.length !== 3) {
15+
if (output.length !== 4) {
1516
throw new Error('Could not parse the latest Git commit output.');
1617
}
1718

1819
const result = {
1920
time: output[0],
20-
hash: output[1],
21-
message: output[2],
21+
shortHash: output[1],
22+
fullHash: output[2],
23+
message: output[3],
2224
};
2325

2426
return result;

src/schemas/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ export const configSchema = z.object({
2222
AUTHOR_EMAIL: z.string().email(),
2323
AUTHOR_GITHUB: z.string().url(),
2424
AUTHOR_LINKEDIN: z.string().url(),
25+
REPO_URL: z.string().url(),
2526
});

src/utils/datetime.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
import { format } from 'date-fns';
22

33
export const dateFormats = {
4-
// Jan 13, 2024
4+
/** Jan 13, 2024 */
55
cardDate: 'MMM dd, yyyy',
6-
// 2024-02-26
6+
/** 2024-02-26 */
77
isoDate: 'yyyy-MM-dd',
8+
/** Tue, 16th July, 9am */
9+
shortDate: 'do MMMM, haaa',
810
} as const;
911

1012
export const formatDate = (date: Date): string => format(date, dateFormats.cardDate);
13+
1114
export const formatDateIso = (date: Date): string => format(date, dateFormats.isoDate);
15+
16+
export const shortDate = (date: Date): string => format(date, dateFormats.shortDate);

src/utils/metadata.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DEFAULT_METADATA, dotSeparator, PAGE_METADATA } from '@/constants/metadata';
1+
import { DEFAULT_METADATA, PAGE_METADATA, titleSeparator } from '@/constants/metadata';
22
import { CONFIG } from '@/config';
33
import { getOpenGraphImagePath } from '@/libs/api/open-graph/image-path';
44

@@ -22,7 +22,7 @@ export const handleTitle = (metadata: Metadata): Metadata => {
2222

2323
const newMetadata = {
2424
...metadata,
25-
title: passedTitle ? `${passedTitle} ${dotSeparator} ${AUTHOR_NAME}` : defaultTitle,
25+
title: passedTitle ? `${passedTitle} ${titleSeparator} ${AUTHOR_NAME}` : defaultTitle,
2626
};
2727

2828
return newMetadata;

0 commit comments

Comments
 (0)