Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions src/components/AppFooter.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
import CounterAnalytics from '@/components/analytics/CounterAnalytics.astro'
import GoogleAnalytics from '@/components/analytics/GoogleAnalytics.astro'
import Swetrix from '@/components/analytics/Swetrix.astro'
import Icon from '@/components/Icon.astro'
import siteConfig from '@/configs/site'
import { getPluginConfig, isPluginEnabled } from '@/utils/plugin'

const { author } = siteConfig
const { name, nickname, email, homepage, github, twitter, telegram, reddit } =
author
const socialNetworks: Record<string, string> = {
github,
twitter,
telegram,
reddit,
}
---

<footer class="my-9 text-primary">
<div class="flex justify-center items-center mb-3">
<a href={`mailto:${email}`} class="footer-icon">
<Icon name={'bi:envelope-fill'} size={32} />
</a>
{
Object.keys(socialNetworks).map((network: string) => (
<a href={socialNetworks[network]} class="footer-icon">
<Icon name={`bi:${network}`} size={32} />
</a>
))
}
</div>
<div class="flex justify-center items-center">
Built with
<span class="px-2">
<Icon name="bi:suit-heart-fill" />
</span>
by
<span class="px-2">
<a href={homepage}>{nickname} ({name})</a>.
</span>
</div>
</footer>
{
isPluginEnabled('googleAnalytics') ? (
<GoogleAnalytics {...getPluginConfig('googleAnalytics')} />
) : (
''
)
}
{isPluginEnabled('swetrix') ? <Swetrix {...getPluginConfig('swetrix')} /> : ''}
{
isPluginEnabled('counterAnalytics') ? (
<CounterAnalytics {...getPluginConfig('counterAnalytics')} />
) : (
''
)
}

<style>
a.footer-icon {
@apply text-primary hover:text-secondary mx-1;
}
</style>
4 changes: 2 additions & 2 deletions src/components/AppHeader.astro
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Icon from './Icon.astro'
export interface Props extends HTMLAttributes<'svg'> {}

const { ...props } = Astro.props
const { title, description, authorAvatar } = siteConfig
const { title, description, author } = siteConfig
---

<div class="header-container">
Expand All @@ -22,7 +22,7 @@ const { title, description, authorAvatar } = siteConfig
<div class="header-logo mr-3">
<a href="/">
<img
src={authorAvatar}
src={author.avatar}
alt="Author's avatar"
class="rounded-full"
style="margin-bottom: 0 !important;"
Expand Down
20 changes: 15 additions & 5 deletions src/configs/site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,29 @@ const env = process.env
export default {
title: 'LeetCode Blog',
description: 'Solutions for LeetCode problems - Written by ansidev',
author: 'ansidev',
authorAvatar: '/ansidev.png',
author: {
name: 'Le Minh Tri',
nickname: 'ansidev',
email: 'ansidev@gmail.com',
avatar: '/ansidev.png',
homepage: 'https://ansidev.xyz',
github: 'https://github.com/ansidev',
twitter: 'https://twitter.com/ansidev',
telegram: 'https://t.me/ansidev',
reddit: 'https://reddit.com/u/ansidev',
},
favicon: '/favicon.ico',
faviconMimeType: 'image/x-icon',
plugins: {
counterAnalytics: {
pid: env.COUNTER_ANALYTICS_ID,
projectId: env.COUNTER_ANALYTICS_ID,
utcOffset: 7,
},
googleAnalytics: {
id: env.GA_ID,
projectId: env.GA_ID,
},
swetrix: {
pid: env.SWETRIX_ID,
projectId: env.SWETRIX_ID,
},
}
}
2 changes: 2 additions & 0 deletions src/layouts/AppLayout.astro
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
import AppFooter from '@/components/AppFooter.astro'
import AppHeader from '@/components/AppHeader.astro'
import SEOMeta from '@/components/SEOMeta.astro'
import siteConfig from '@/configs/site'
Expand Down Expand Up @@ -30,5 +31,6 @@ const pageDescription =
<body class="max-w-8xl mx-auto bg-site-bg">
<AppHeader class={headerCssClasses} />
<slot />
<AppFooter />
</body>
</html>
2 changes: 1 addition & 1 deletion src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const { title, description, author } = siteConfig
<AppLayout
title={title}
description={description}
author={author}
author={author.name}
headerCssClasses="max-w-xl px-8"
>
<main class="mx-auto my-4 p-4 max-w-2xl text-site-header-text">
Expand Down
8 changes: 8 additions & 0 deletions src/utils/plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import _get from 'lodash.get'

import siteConfig from '@/configs/site'

const { plugins } = siteConfig

export const isPluginEnabled = (pluginName: string) => typeof _get(plugins, pluginName) === 'object'
export const getPluginConfig = (key: string) => _get(plugins, key)