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