refactor: enhance content collections and update localization

- Modified the meta collection to include files with 'meta**.json' for improved matching.
- Added new translation keys for 'blog' in English and Chinese localization files.
- Updated social links in the layout to use the XTwitterIcon for consistency.
- Adjusted image paths in the features page for better organization.
- Removed unused LocaleSwitcher import from the footer component.
This commit is contained in:
javayhu 2025-03-30 21:10:47 +08:00
parent 91f1d59b7c
commit 5636a917ef
7 changed files with 38 additions and 14 deletions

View File

@ -29,7 +29,7 @@ const docs = defineCollection({
const metas = defineCollection({ const metas = defineCollection({
name: 'meta', name: 'meta',
directory: 'content/docs', directory: 'content/docs',
include: '**/meta.json', include: '**/meta**.json',
parser: 'json', parser: 'json',
schema: createMetaSchema, schema: createMetaSchema,
}); });

View File

@ -188,8 +188,9 @@
"previousPage": "Previous", "previousPage": "Previous",
"nextPage": "Next", "nextPage": "Next",
"chooseLanguage": "Select language", "chooseLanguage": "Select language",
"title": "MkSaaS Docs",
"homepage": "Homepage", "homepage": "Homepage",
"title": "MkSaaS Docs" "blog": "Blog"
}, },
"Marketing": { "Marketing": {
"navbar": { "navbar": {

View File

@ -184,8 +184,9 @@
"previousPage": "上一页", "previousPage": "上一页",
"nextPage": "下一页", "nextPage": "下一页",
"chooseLanguage": "选择语言", "chooseLanguage": "选择语言",
"title": "MkSaaS文档",
"homepage": "首页", "homepage": "首页",
"title": "MkSaaS 文档" "blog": "博客"
}, },
"Marketing": { "Marketing": {
"navbar": { "navbar": {

View File

@ -1,4 +1,4 @@
import { Icons } from '@/components/icons/icons'; import { XTwitterIcon } from '@/components/icons/x';
import { ModeSwitcher } from '@/components/layout/mode-switcher'; import { ModeSwitcher } from '@/components/layout/mode-switcher';
import { Logo } from '@/components/logo'; import { Logo } from '@/components/logo';
import { websiteConfig } from '@/config'; import { websiteConfig } from '@/config';
@ -8,6 +8,7 @@ import { source } from '@/lib/docs/source';
import { I18nProvider, Translations } from 'fumadocs-ui/i18n'; import { I18nProvider, Translations } from 'fumadocs-ui/i18n';
import { DocsLayout } from 'fumadocs-ui/layouts/docs'; import { DocsLayout } from 'fumadocs-ui/layouts/docs';
import type { BaseLayoutProps } from 'fumadocs-ui/layouts/shared'; import type { BaseLayoutProps } from 'fumadocs-ui/layouts/shared';
import { BookIcon, HomeIcon } from 'lucide-react';
import { Locale } from 'next-intl'; import { Locale } from 'next-intl';
import { getTranslations } from 'next-intl/server'; import { getTranslations } from 'next-intl/server';
import type { ReactNode } from 'react'; import type { ReactNode } from 'react';
@ -26,6 +27,20 @@ interface DocsLayoutProps {
params: Promise<{ locale: Locale }>; params: Promise<{ locale: Locale }>;
} }
/**
* 1. Configure navigation
* https://fumadocs.vercel.app/docs/ui/navigation/links
* https://fumadocs.vercel.app/docs/ui/navigation/sidebar
*
* example:
* https://github.com/fuma-nama/fumadocs/blob/dev/apps/docs/app/layout.config.tsx
*
* 2. Organizing Pages
* https://fumadocs.vercel.app/docs/ui/page-conventions
*
* example:
* https://github.com/fuma-nama/fumadocs/blob/dev/apps/docs/content/docs/ui/meta.json
*/
export default async function DocsRootLayout({ children, params }: DocsLayoutProps) { export default async function DocsRootLayout({ children, params }: DocsLayoutProps) {
const { locale } = await params; const { locale } = await params;
const t = await getTranslations({ locale, namespace: 'DocsPage' }); const t = await getTranslations({ locale, namespace: 'DocsPage' });
@ -42,7 +57,7 @@ export default async function DocsRootLayout({ children, params }: DocsLayoutPro
}; };
// Docs layout configurations // Docs layout configurations
const baseOptions: BaseLayoutProps = { const docsOptions: BaseLayoutProps = {
i18n: docsI18nConfig, i18n: docsI18nConfig,
githubUrl: websiteConfig.social.github ?? undefined, githubUrl: websiteConfig.social.github ?? undefined,
nav: { nav: {
@ -57,13 +72,20 @@ export default async function DocsRootLayout({ children, params }: DocsLayoutPro
{ {
text: t('homepage'), text: t('homepage'),
url: '/', url: '/',
active: 'nested-url', icon: <HomeIcon />,
active: 'none',
},
{
text: t('blog'),
url: '/blog',
icon: <BookIcon />,
active: 'none',
}, },
...(websiteConfig.social.twitter ...(websiteConfig.social.twitter
? [ ? [
{ {
type: "icon" as const, type: "icon" as const,
icon: <Icons.x />, icon: <XTwitterIcon />,
text: "X", text: "X",
url: websiteConfig.social.twitter, url: websiteConfig.social.twitter,
secondary: true, secondary: true,
@ -84,7 +106,7 @@ export default async function DocsRootLayout({ children, params }: DocsLayoutPro
locale={locale} locale={locale}
translations={translations} translations={translations}
> >
<DocsLayout tree={source.pageTree[locale]} {...baseOptions}> <DocsLayout tree={source.pageTree[locale]} {...docsOptions}>
{children} {children}
</DocsLayout> </DocsLayout>
</I18nProvider> </I18nProvider>

View File

@ -22,19 +22,19 @@ export default function Features() {
const images = { const images = {
'item-1': { 'item-1': {
image: '/charts.png', image: '/images/blocks/charts.png',
alt: 'Database visualization', alt: 'Database visualization',
}, },
'item-2': { 'item-2': {
image: '/music.png', image: '/images/blocks/music.png',
alt: 'Security authentication', alt: 'Security authentication',
}, },
'item-3': { 'item-3': {
image: '/mail2.png', image: '/images/blocks/mail2.png',
alt: 'Identity management', alt: 'Identity management',
}, },
'item-4': { 'item-4': {
image: '/payments.png', image: '/images/blocks/payments.png',
alt: 'Analytics dashboard', alt: 'Analytics dashboard',
}, },
}; };

View File

@ -9,7 +9,6 @@ import { LocaleLink } from '@/i18n/navigation';
import { cn } from '@/lib/utils'; import { cn } from '@/lib/utils';
import { useTranslations } from 'next-intl'; import { useTranslations } from 'next-intl';
import React from 'react'; import React from 'react';
import LocaleSwitcher from './locale-switcher';
import { ThemeSelector } from './theme-selector'; import { ThemeSelector } from './theme-selector';
export function Footer({ className }: React.HTMLAttributes<HTMLElement>) { export function Footer({ className }: React.HTMLAttributes<HTMLElement>) {

View File

@ -44,6 +44,7 @@ import {
UserPlusIcon UserPlusIcon
} from 'lucide-react'; } from 'lucide-react';
import { useTranslations } from 'next-intl'; import { useTranslations } from 'next-intl';
import { XTwitterIcon } from './components/icons/x';
/** /**
* website config, without translations * website config, without translations
@ -527,7 +528,7 @@ export function getSocialLinks(): MenuItem[] {
socialLinks.push({ socialLinks.push({
title: 'Twitter', title: 'Twitter',
href: websiteConfig.social.twitter, href: websiteConfig.social.twitter,
icon: <TwitterIcon className="size-4 shrink-0" />, icon: <XTwitterIcon className="size-4 shrink-0" />,
}); });
} }