Skip to content

Commit

Permalink
Update footer component (#118)
Browse files Browse the repository at this point in the history
* refactor: footer init

* feat: Add dynamic footer sitemap rendering

- Add TypeScript to script setup in Footer.vue
- Define interfaces for List, Sitemap, and Props in Footer.vue
- Render footer links dynamically based on sitemap data in Footer.vue
- Update config interface in config.ts to include footerLinks
- Import FooterSitemap interface in config.ts
- Pass siteName and sitemap data to LazyPublicFooter in default.vue

* style: Update primary color to a new hue and adjust foreground color

* feat: Update primary color in Catalog.vue

Changed primary color class in Catalog.vue from using hex values to using
semantic class names for better readability and consistency.

* refactor: Update Props interface in Footer.vue

Changed the sitemap property in the Props interface to be optional by adding a question mark. Updated references to sitemap property to refer to props.sitemap. Also updated the sitemap prop in the default layout to config.footerLinks.

* feat: Update Footer component to use optional sitemap props

Updated the Footer component to make the sitemap prop optional by adding a '?' to the prop type. Also changed references to sitemap to use props.sitemap. Additionally, corrected typo in layouts/default.vue by changing 'config.stiemap' to 'config.footerLinks'.
  • Loading branch information
nexmoe authored May 3, 2024
1 parent 98b2893 commit d6feae3
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 14 deletions.
4 changes: 2 additions & 2 deletions assets/css/tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
--border: 214.3 31.8% 91.4%;
--input: 214.3 31.8% 91.4%;

--primary: 222.2 47.4% 11.2%;
--primary-foreground: 210 40% 98%;
--primary: 47.75deg 92.27% 59.41%;
--primary-foreground: 39deg 62.5% 6.27%;

--secondary: 210 40% 96.1%;
--secondary-foreground: 222.2 47.4% 11.2%;
Expand Down
2 changes: 1 addition & 1 deletion components/public/Catalog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,6 @@ onUnmounted(() => {
}
.active {
@apply bg-[#f7d038] text-[#1a1306] hover:bg-[#f7d038];
@apply bg-primary text-primary-foreground hover:bg-primary;
}
</style>
46 changes: 37 additions & 9 deletions components/public/Footer.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,46 @@
<script setup>
<script setup lang="ts">
import dayjs from 'dayjs'
const config = await useGetConfig()
interface List {
title: string
url: string
}
export interface Sitemap {
title: string
list: List[]
}
export interface Props {
sitemap?: Sitemap[]
siteName: string
}
const props = defineProps<Props>()
</script>

<template>
<div class="container flex">
<div class="footer my-16">
Copyright © {{ dayjs(new Date()).format('YYYY') }} {{ config.siteName }}, Powered by <a
class="underline"
href="https://github.com/nexmoe/roam-space" target="_blank"
>Roam Space</a>
<footer class="mt-12 bg-white dark:bg-gray-900">
<div class="mx-auto w-full max-w-screen-xl">
<div v-if="props.sitemap" class="grid grid-cols-2 gap-8 px-4 py-6 lg:py-8 md:grid-cols-4">
<div v-for="item in props.sitemap" :key="item.title">
<h2 class="mb-6 text-sm font-semibold text-gray-900 uppercase dark:text-white">{{ item.title }}</h2>
<ul v-for="list in item.list" :key="list.title"
class="text-gray-500 dark:text-gray-400 font-medium">
<li class="mb-4">
<a :href="list.url" class="hover:underline">{{ list.title }}</a>
</li>
</ul>
</div>
</div>
<div class="px-4 py-6 md:flex md:items-center md:justify-between">
<span class="text-sm text-gray-500 dark:text-gray-300 sm:text-center">© {{ dayjs(new
Date()).format('YYYY') }} {{ props.siteName }} All Rights Reserved. Powered by <a class="underline"
href="https://github.com/nexmoe/roam-space" target="_blank">Roam Space</a>
</span>
</div>
</div>
</div>
</footer>
</template>

<style>
Expand Down
2 changes: 1 addition & 1 deletion components/public/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const config = await useGetConfig()
}
.item.active {
@apply bg-[#f7d038] text-[#1a1306];
@apply bg-primary text-primary-foreground;
}
.author {}
Expand Down
7 changes: 6 additions & 1 deletion layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@ useHead({
lang: 'zh-CN',
},
})
const config = await useGetConfig()
</script>

<template>
<div>
<PublicHeader />
<slot />
<LazyPublicTool />
<LazyPublicFooter v-once />
<LazyPublicFooter
v-once
:site-name="config.siteName"
:sitemap="config.footerLinks"
/>
</div>
</template>

Expand Down
3 changes: 3 additions & 0 deletions server/trpc/routers/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { publicProcedure, router } from '../trpc'
import type { Props as SocialProps } from '~/components/public/Social.vue'
import type { Sitemap as FooterSitemap } from '~/components/public/Footer.vue'

import defaultData from '~/config/hero.json'

interface PrismaConfigItem {
Expand All @@ -14,6 +16,7 @@ interface Config {
tags?: string[]
menus?: Menu[]
socials?: SocialProps[]
footerLinks?: FooterSitemap[]
siteUrl: string
siteName: string
siteDescription: string
Expand Down

0 comments on commit d6feae3

Please sign in to comment.