diff --git a/app/components/home/Activity.vue b/app/components/home/Activity.vue index f315e8c..f9c7c9a 100644 --- a/app/components/home/Activity.vue +++ b/app/components/home/Activity.vue @@ -2,154 +2,124 @@ import type { Activity } from '~~/types' import { IDEs } from '~~/types' -const { data: activity, refresh } = await useAsyncData('activity', () => $fetch('/api/activity'), - { lazy: true } -) +const { data: activity, refresh } = await useAsyncData('activity', () => $fetch('/api/activity'), { lazy: true }) +useIntervalFn(refresh, 5000) -useIntervalFn(refresh, 1000) - -const codingActivities = computed(() => { +const currentSession = computed(() => { const list = activity.value?.data.activities ?? [] - return list - .filter(a => IDEs.some(ide => ide.name === a.name)) - .map(a => ({ ...a, name: a.assets?.small_text === 'Cursor' ? 'Cursor' : a.name })) -}) + const ideActivity = list.find(a => IDEs.some(ide => ide.name === a.name)) -const codingActivity = computed(() => { - if (!codingActivities.value.length) return null - return codingActivities.value.length > 1 - ? codingActivities.value[Math.floor(Math.random() * codingActivities.value.length)] - : codingActivities.value[0] -}) + if (!ideActivity) return null -const isActive = computed(() => { - const act = codingActivity.value - if (!act) return false + const name = ideActivity.assets?.small_text === 'Cursor' ? 'Cursor' : ideActivity.name - const { name, details = '', state = '' } = act + const isIdling = ideActivity.details?.includes('Idling') || (!ideActivity.state?.toLowerCase().includes('editing') && name !== 'Visual Studio Code') - if (name === 'Visual Studio Code' || name === 'Cursor') - return !details.includes('Idling') - - return state.toLowerCase().includes('editing') -}) - -type FormattedActivity = { - name: string - project: string - state: string - start: { - ago: string - formatted: { date: string, time: string } - } -} | null - -const formattedActivity = computed(() => { - const act = codingActivity.value - if (!act) return null - - const { name, details = '', state = '', timestamps } = act - - const project = details - ? (details.charAt(0).toUpperCase() + details.slice(1).replace('Workspace:', '').trim()) - : '' - - const stateWord = (state && state.split(' ').length >= 2 ? state.split(' ')[1] : 'Secret project') as string - const ago = useTimeAgo(timestamps.start).value - - const formatDate = (date: number, format: string) => - useDateFormat(date, format).value + const rawProject = ideActivity.details ? ideActivity.details.replace('Workspace:', '').replace('Editing', '').trim() : 'Unknown Context' + const project = rawProject.charAt(0).toUpperCase() + rawProject.slice(1) + const file = ideActivity.state?.replace('Editing', '').trim() || 'No active file' return { name, project, - state: stateWord, - start: { - ago, - formatted: { - date: formatDate(timestamps.start, 'DD MMM YYYY'), - time: formatDate(timestamps.start, 'HH:mm') - } - } + file, + isIdling, + startTime: ideActivity.timestamps?.start, + icon: IDEs.find(ide => ide.name === name)?.icon ?? 'i-ph-code-duotone' } }) -const editorIcon = computed(() => { - const name = formattedActivity.value?.name ?? codingActivity.value?.name - return IDEs.find(ide => ide.name === name)?.icon ?? 'file' +const timeAgo = useTimeAgo(computed(() => currentSession.value?.startTime ?? new Date())) + +const statusColor = computed(() => { + if (!currentSession.value) return 'red' + return currentSession.value.isIdling ? 'orange' : 'green' +}) + +const statusLabel = computed(() => { + if (!currentSession.value) return 'System Offline' + if (currentSession.value.isIdling) return 'System Idling' + return 'Active Development' }) diff --git a/app/components/home/CatchPhrase.vue b/app/components/home/CatchPhrase.vue index 2d36237..9c97d6a 100644 --- a/app/components/home/CatchPhrase.vue +++ b/app/components/home/CatchPhrase.vue @@ -1,18 +1,11 @@ - - diff --git a/app/components/home/Quote.vue b/app/components/home/Quote.vue index 1622c7d..4b98310 100644 --- a/app/components/home/Quote.vue +++ b/app/components/home/Quote.vue @@ -1,19 +1,32 @@ diff --git a/app/components/home/Skills.vue b/app/components/home/Skills.vue index e16daea..fdabb6a 100644 --- a/app/components/home/Skills.vue +++ b/app/components/home/Skills.vue @@ -20,11 +20,13 @@ const { skills } = await useContent() :key="skill.id" >
-

+

{{ skill.name }}

- -
+

+ {{ skill.description }} +

+
('stats', () => $fetch('/api/stats')) -const time = useTimeAgo(new Date(stats.value?.coding.range.start ?? 0)).value.split(' ')[0] -const date = useDateFormat(new Date(stats.value?.coding.range.start ?? 0), 'DD MMMM YYYY') -const hours = usePrecision((stats.value?.coding.grand_total.total_seconds_including_other_language ?? 0) / 3600, 0) +const startDate = computed(() => stats.value?.coding.range.start ? new Date(stats.value.coding.range.start) : new Date()) +const yearsCollected = useTimeAgo(startDate).value +const formattedDate = useDateFormat(startDate, 'MMM DD, YYYY').value -const editors = computed(() => stats.value?.editors.slice(0, 3).map(editor => `${editor.name} (${editor.percent}%)`).join(', ')) -const os = computed(() => stats.value?.os.slice(0, 2).map(os => `${os.name} (${os.percent}%)`).join(', ')) -const languages = computed(() => stats.value?.languages.slice(0, 3).map(language => `${language.name} (${language.percent}%)`).join(', ')) +const totalHours = usePrecision((stats.value?.coding.grand_total.total_seconds_including_other_language ?? 0) / 3600, 0) + +const topLanguages = computed(() => stats.value?.languages.slice(0, 4) || []) +const topEditors = computed(() => stats.value?.editors.slice(0, 3) || []) +const topOS = computed(() => stats.value?.os.slice(0, 2) || []) diff --git a/app/components/home/timeline/Education.vue b/app/components/home/timeline/Education.vue new file mode 100644 index 0000000..ef83de6 --- /dev/null +++ b/app/components/home/timeline/Education.vue @@ -0,0 +1,64 @@ + + + diff --git a/app/components/home/timeline/Experiences.vue b/app/components/home/timeline/Experiences.vue new file mode 100644 index 0000000..ee7d575 --- /dev/null +++ b/app/components/home/timeline/Experiences.vue @@ -0,0 +1,64 @@ + + + diff --git a/app/pages/index.vue b/app/pages/index.vue index c5850b3..96472e8 100644 --- a/app/pages/index.vue +++ b/app/pages/index.vue @@ -16,12 +16,5 @@ const { data: page } = await useAsyncData('index', () => { :value="page" class="mt-8 md:mt-16" /> - - - - - - -