mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-09 15:05:35 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
01298661a5 | ||
|
|
2de2556a20 | ||
|
|
6005374340 | ||
|
|
eac0c135d6 | ||
|
|
aef2db6071 |
@@ -1,7 +1,9 @@
|
||||
import { isSSREnableForPage } from '#config/ssr';
|
||||
import {
|
||||
PREFER_DARK_THEME,
|
||||
DARK_THEME_DEFAULT_VALUE,
|
||||
PREFER_DARK_THEME,
|
||||
} from '#user/constants/theme';
|
||||
import logger from '@adonisjs/core/services/logger';
|
||||
import { defineConfig } from '@adonisjs/inertia';
|
||||
|
||||
export default defineConfig({
|
||||
@@ -32,5 +34,10 @@ export default defineConfig({
|
||||
ssr: {
|
||||
enabled: true,
|
||||
entrypoint: 'inertia/app/ssr.tsx',
|
||||
pages: (_, page) => {
|
||||
const ssrEnabled = isSSREnableForPage(page);
|
||||
logger.debug(`Page "${page}" SSR enabled: ${ssrEnabled}`);
|
||||
return ssrEnabled;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
2
config/ssr.ts
Normal file
2
config/ssr.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export const CSR_ROUTES = ['dashboard'];
|
||||
export const isSSREnableForPage = (page: string) => !CSR_ROUTES.includes(page);
|
||||
@@ -1,8 +1,9 @@
|
||||
import { resolvePageComponent } from '@adonisjs/inertia/helpers';
|
||||
import { createInertiaApp } from '@inertiajs/react';
|
||||
import { isSSREnableForPage } from 'config-ssr';
|
||||
import 'dayjs/locale/en';
|
||||
import 'dayjs/locale/fr';
|
||||
import { hydrateRoot } from 'react-dom/client';
|
||||
import { createRoot, hydrateRoot } from 'react-dom/client';
|
||||
import '../i18n/index';
|
||||
|
||||
const appName = import.meta.env.VITE_APP_NAME || 'MyLinks';
|
||||
@@ -20,6 +21,13 @@ createInertiaApp({
|
||||
},
|
||||
|
||||
setup({ el, App, props }) {
|
||||
hydrateRoot(el, <App {...props} />);
|
||||
const componentName = props.initialPage.component;
|
||||
const isSSREnabled = isSSREnableForPage(componentName);
|
||||
console.debug(`Page "${componentName}" SSR enabled: ${isSSREnabled}`);
|
||||
if (isSSREnabled) {
|
||||
hydrateRoot(el, <App {...props} />);
|
||||
} else {
|
||||
createRoot(el).render(<App {...props} />);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -36,7 +36,12 @@ export default function CollectionItem({
|
||||
title={collection.name}
|
||||
>
|
||||
<FolderIcon className={classes.linkIcon} />
|
||||
<Text lineClamp={1} maw={'200px'} style={{ wordBreak: 'break-all' }}>
|
||||
<Text
|
||||
lineClamp={1}
|
||||
maw={'200px'}
|
||||
w="100%"
|
||||
style={{ wordBreak: 'break-all' }}
|
||||
>
|
||||
{collection.name}
|
||||
</Text>
|
||||
{showLinks && (
|
||||
@@ -45,7 +50,7 @@ export default function CollectionItem({
|
||||
c="var(--mantine-color-gray-5)"
|
||||
ml={4}
|
||||
>
|
||||
— {linksCount}0
|
||||
— {linksCount}
|
||||
</Text>
|
||||
)}
|
||||
</Link>
|
||||
|
||||
@@ -35,7 +35,7 @@ export function DashboardHeader({ navbar, aside }: DashboardHeaderProps) {
|
||||
const { activeCollection } = useActiveCollection();
|
||||
return (
|
||||
<AppShell.Header style={{ display: 'flex', alignItems: 'center' }}>
|
||||
<Group justify="space-between" px="md" flex={1}>
|
||||
<Group justify="space-between" px="md" flex={1} wrap="nowrap">
|
||||
<Group h="100%" wrap="nowrap">
|
||||
<Burger
|
||||
opened={navbar.opened}
|
||||
@@ -57,7 +57,7 @@ export function DashboardHeader({ navbar, aside }: DashboardHeaderProps) {
|
||||
)}
|
||||
</Box>
|
||||
</Group>
|
||||
<Group>
|
||||
<Group wrap="nowrap">
|
||||
<ShareCollection />
|
||||
|
||||
<Menu withinPortal shadow="md" width={225}>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import PATHS from '#core/constants/paths';
|
||||
import { Link } from '@inertiajs/react';
|
||||
import { route } from '@izzyjs/route/client';
|
||||
import { Anchor, Group, Text } from '@mantine/core';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
@@ -21,7 +20,7 @@ export function MantineFooter() {
|
||||
const items = links.map((link) => (
|
||||
<Anchor
|
||||
c="dimmed"
|
||||
component={Link}
|
||||
component={ExternalLink}
|
||||
key={link.label}
|
||||
href={link.link}
|
||||
size="sm"
|
||||
|
||||
@@ -17,7 +17,6 @@ import { useTranslation } from 'react-i18next';
|
||||
import ExternalLink from '~/components/common/external_link';
|
||||
import { MantineLanguageSwitcher } from '~/components/common/language_switcher';
|
||||
import { MantineThemeSwitcher } from '~/components/common/theme_switcher';
|
||||
import { MantineUserCard } from '~/components/common/user_card';
|
||||
import useUser from '~/hooks/use_user';
|
||||
import classes from './mobile.module.css';
|
||||
|
||||
@@ -31,7 +30,9 @@ export default function Navbar() {
|
||||
<Box pb={40}>
|
||||
<header className={classes.header}>
|
||||
<Group justify="space-between" h="100%">
|
||||
<Image src="/logo-light.png" h={35} alt="MyLinks's logo" />
|
||||
<Link href="/">
|
||||
<Image src="/logo-light.png" h={35} alt="MyLinks's logo" />
|
||||
</Link>
|
||||
|
||||
<Group h="100%" gap={0} visibleFrom="sm">
|
||||
<Link href="/" className={classes.link}>
|
||||
@@ -102,11 +103,13 @@ export default function Navbar() {
|
||||
|
||||
<Group justify="center" grow pb="xl" px="md">
|
||||
{!isAuthenticated ? (
|
||||
<Button component="a" href={route('auth').path}>
|
||||
<Button component="a" href={route('auth').path} w={110}>
|
||||
{t('login')}
|
||||
</Button>
|
||||
) : (
|
||||
<MantineUserCard />
|
||||
<Button component={Link} href={route('dashboard').path} w={110}>
|
||||
Dashboard
|
||||
</Button>
|
||||
)}
|
||||
</Group>
|
||||
</ScrollArea>
|
||||
|
||||
@@ -6,8 +6,9 @@
|
||||
"jsx": "react-jsx",
|
||||
"resolveJsonModule": true,
|
||||
"paths": {
|
||||
"~/*": ["./*"]
|
||||
"~/*": ["./*"],
|
||||
"config-ssr": ["../config/ssr"]
|
||||
}
|
||||
},
|
||||
"include": ["./**/*.ts", "./**/*.tsx"]
|
||||
"include": ["./**/*.ts", "./**/*.tsx", "../config/ssr.ts"]
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "my-links",
|
||||
"version": "3.0.2",
|
||||
"version": "3.0.3",
|
||||
"type": "module",
|
||||
"license": "GPL-3.0-only",
|
||||
"scripts": {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import { getDirname } from '@adonisjs/core/helpers';
|
||||
import inertia from '@adonisjs/inertia/client';
|
||||
import react from '@vitejs/plugin-react';
|
||||
import adonisjs from '@adonisjs/vite/client';
|
||||
import react from '@vitejs/plugin-react';
|
||||
import { defineConfig } from 'vite';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
@@ -21,6 +21,7 @@ export default defineConfig({
|
||||
resolve: {
|
||||
alias: {
|
||||
'~/': `${getDirname(import.meta.url)}/inertia/`,
|
||||
'config-ssr': `${getDirname(import.meta.url)}/config/ssr.ts`,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user