Skip to content

Commit 199a573

Browse files
committed
feat: command palette 3
1 parent 234bdd3 commit 199a573

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

public/images/herdaim.jpg

103 KB
Loading

src/components/CommandPalette.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,14 @@ const CommandPalette = ({ isOpen, setIsOpen, openGenericModal }) => {
6868
case 'viewSource':
6969
window.open('https://github.com/fezcode/fezcode.github.io', '_blank', 'noopener,noreferrer');
7070
break;
71-
case 'randomPost':
71+
case 'randomPost': {
7272
const posts = items.filter(i => i.type === 'post');
7373
if (posts.length > 0) {
7474
const randomPost = posts[Math.floor(Math.random() * posts.length)];
7575
navigate(randomPost.path);
7676
}
7777
break;
78+
}
7879
case 'sendEmailFezcode':
7980
window.open('mailto:samil.bulbul@gmail.com', '_blank', 'noopener,noreferrer');
8081
break;
@@ -93,7 +94,7 @@ const CommandPalette = ({ isOpen, setIsOpen, openGenericModal }) => {
9394
case 'scrollToBottom':
9495
window.scrollTo({ top: document.documentElement.scrollHeight, behavior: 'smooth' });
9596
break;
96-
case 'showSiteStats':
97+
case 'showSiteStats': {
9798
const postCount = items.filter(i => i.type === 'post').length;
9899
const projectCount = items.filter(i => i.type === 'project').length;
99100
const logCount = items.filter(i => i.type === 'log').length;
@@ -107,9 +108,29 @@ const CommandPalette = ({ isOpen, setIsOpen, openGenericModal }) => {
107108
</div>
108109
));
109110
break;
111+
}
110112
case 'showVersion':
111113
openGenericModal('Application Version', <p>Version: <strong>v{version}</strong></p>);
112114
break;
115+
case 'latestPost': {
116+
const posts = items.filter(i => i.type === 'post');
117+
if (posts.length > 0) {
118+
posts.sort((a, b) => new Date(b.date) - new Date(a.date));
119+
navigate(posts[0].path);
120+
}
121+
break;
122+
}
123+
case 'latestLog': {
124+
const logs = items.filter(i => i.type === 'log');
125+
if (logs.length > 0) {
126+
logs.sort((a, b) => new Date(b.date) - new Date(a.date));
127+
navigate(logs[0].path);
128+
}
129+
break;
130+
}
131+
case 'herDaim':
132+
openGenericModal('Her Daim', <img src="/images/herdaim.jpg" alt="Her Daim" className="max-w-full h-auto" />);
133+
break;
113134
default:
114135
break;
115136
}

src/hooks/useSearchableData.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ const useSearchableData = () => {
7373
{ title: 'Scroll to Bottom', type: 'command', commandId: 'scrollToBottom' },
7474
{ title: 'Show Site Stats', type: 'command', commandId: 'showSiteStats' },
7575
{ title: 'Show Version', type: 'command', commandId: 'showVersion' },
76+
{ title: 'Go to Latest Post', type: 'command', commandId: 'latestPost' },
77+
{ title: 'Go to Latest Log', type: 'command', commandId: 'latestLog' },
78+
{ title: 'Her Daim', type: 'command', commandId: 'herDaim' },
7679
];
7780

7881
setItems([...staticRoutes, ...customCommands, ...allPosts, ...allProjects, ...allLogs, ...allApps]);

0 commit comments

Comments
 (0)