hash mode

This commit is contained in:
2023-08-02 09:05:44 +00:00
parent c1ec16e35d
commit 15a1f49bdb
8 changed files with 2443 additions and 3046 deletions

View File

@@ -17,14 +17,12 @@
}, },
"dependencies": { "dependencies": {
"@emotion/react": "^11.10.5", "@emotion/react": "^11.10.5",
"@grafana/faro-react": "^1.0.2",
"@grafana/faro-web-tracing": "^1.0.2",
"@mantine/core": "6.0.0", "@mantine/core": "6.0.0",
"@mantine/form": "^6.0.0", "@mantine/form": "^6.0.0",
"@mantine/hooks": "^6.0.0", "@mantine/hooks": "^6.0.0",
"@mantine/notifications": "^6.0.0", "@mantine/notifications": "^6.0.0",
"@reduxjs/toolkit": "^1.9.3", "@reduxjs/toolkit": "^1.9.3",
"@tabler/icons-react": "^2.7.0", "@tabler/icons-react": "^2.30.0",
"axios": "^1.3.4", "axios": "^1.3.4",
"dayjs": "^1.11.7", "dayjs": "^1.11.7",
"i18next": ">=21.0.0", "i18next": ">=21.0.0",
@@ -88,7 +86,5 @@
"ts-jest": "^29.0.5", "ts-jest": "^29.0.5",
"typescript": "^4.9.5", "typescript": "^4.9.5",
"vite": "^4.1.1" "vite": "^4.1.1"
}, }
"readme": "ERROR: No README data found!",
"_id": "mantine-vite-template@0.0.0"
} }

View File

@@ -12,6 +12,7 @@ import { useDocumentTitle, useMediaQuery } from "@mantine/hooks";
import { IconSearch, IconSettings } from "@tabler/icons-react"; import { IconSearch, IconSettings } from "@tabler/icons-react";
import { Dispatch, SetStateAction, createContext, useContext } from "react"; import { Dispatch, SetStateAction, createContext, useContext } from "react";
import { useNavigate } from "react-router"; import { useNavigate } from "react-router";
import { Link } from "react-router-dom";
const useStyles = createStyles((theme) => ({ const useStyles = createStyles((theme) => ({
header: { header: {
@@ -75,7 +76,7 @@ export function HeaderSearch() {
<Header height={56} className={classes.header}> <Header height={56} className={classes.header}>
<div className={classes.inner}> <div className={classes.inner}>
<span> <span>
<Text weight={600} component="a" href="/"> <Text weight={600} component={Link} to="/">
DS-Next DS-Next
</Text> </Text>
{!isMobile && ( {!isMobile && (
@@ -94,7 +95,7 @@ export function HeaderSearch() {
required required
/> />
</form> </form>
<ActionIcon component="a" href="/settings"> <ActionIcon component={Link} to="/settings">
<IconSettings /> <IconSettings />
</ActionIcon> </ActionIcon>
</Group> </Group>

View File

@@ -1,6 +1,7 @@
import { Card, Group, Image, Text, createStyles } from "@mantine/core"; import { Card, Group, Image, Text, createStyles } from "@mantine/core";
import dayjs from "dayjs"; import dayjs from "dayjs";
import relativeTime from "dayjs/plugin/relativeTime"; import relativeTime from "dayjs/plugin/relativeTime";
import { Link } from "react-router-dom";
dayjs.extend(relativeTime); dayjs.extend(relativeTime);
@@ -34,18 +35,18 @@ export function ParagraphCard({
return ( return (
<Card withBorder radius="md" p={0} className={classes.card}> <Card withBorder radius="md" p={0} className={classes.card}>
<Group noWrap spacing={0}> <Group noWrap spacing={0}>
<a href={url}> <Link to={url}>
{cover && <Image src={cover} height={140} width={140} />} {cover && <Image src={cover} height={140} width={140} />}
</a> </Link>
<div className={classes.body}> <div className={classes.body}>
<Text transform="uppercase" color="dimmed" weight={700} size="xs"> <Text transform="uppercase" color="dimmed" weight={700} size="xs">
{tags.map((tag, index) => ( {tags.map((tag, index) => (
<> <>
{index > 0 && " • "} {index > 0 && " • "}
<Text <Text
component="a" component={Link}
key={index} key={index}
href={`/tag/${encodeURIComponent(tag)}`} to={`/tag/${encodeURIComponent(tag)}`}
> >
{tag} {tag}
</Text> </Text>
@@ -56,8 +57,8 @@ export function ParagraphCard({
className={classes.title} className={classes.title}
mt="xs" mt="xs"
mb="md" mb="md"
component="a" component={Link}
href={url} to={url}
> >
{title} {title}
</Text> </Text>
@@ -65,8 +66,8 @@ export function ParagraphCard({
<Group spacing="xs" noWrap> <Group spacing="xs" noWrap>
<Text <Text
size="xs" size="xs"
component="a" component={Link}
href={`/author/${encodeURIComponent(author)}`} to={`/author/${encodeURIComponent(author)}`}
> >
{author} {author}
</Text> </Text>

View File

@@ -14,6 +14,7 @@ import { useContext, useEffect } from "react";
import { useLoaderData } from "react-router"; import { useLoaderData } from "react-router";
import { TitleContext } from "@/component/Header/Header"; import { TitleContext } from "@/component/Header/Header";
import { Link } from "react-router-dom";
function stripStyles(content: string) { function stripStyles(content: string) {
const element = document.createElement("div"); const element = document.createElement("div");
@@ -78,8 +79,8 @@ export default function ParagraphPage() {
<Group> <Group>
<Text c="dimmed"> {dayjs().to(dayjs(paragraph.time))}</Text> <Text c="dimmed"> {dayjs().to(dayjs(paragraph.time))}</Text>
<UnstyledButton <UnstyledButton
component="a" component={Link}
href={`/author/${encodeURIComponent( to={`/author/${encodeURIComponent(
paragraph.author || "unknown" paragraph.author || "unknown"
)}`} )}`}
> >
@@ -93,8 +94,8 @@ export default function ParagraphPage() {
{paragraph.tags?.map((tag) => ( {paragraph.tags?.map((tag) => (
<UnstyledButton <UnstyledButton
key={tag} key={tag}
component="a" component={Link}
href={`/tag/${encodeURIComponent(tag)}`} to={`/tag/${encodeURIComponent(tag)}`}
> >
<Badge fz="xs" variant="dot"> <Badge fz="xs" variant="dot">
{tag} {tag}

View File

@@ -61,7 +61,7 @@ export default function SearchPage(props: SearchPageProps) {
{paragraphs.map((paragraph) => { {paragraphs.map((paragraph) => {
return ( return (
<Grid.Col xs={12} sm={6} key={paragraph._id}> <Grid.Col xs={12} sm={6} key={paragraph._id}>
<ParagraphCard {...paragraph} /> <ParagraphCard {...paragraph} key={paragraph._id} />
</Grid.Col> </Grid.Col>
); );
})} })}

View File

@@ -1,5 +1,5 @@
import { lazy } from "react"; import { lazy } from "react";
import { createBrowserRouter } from "react-router-dom"; import { createHashRouter } from "react-router-dom";
import { remark } from "remark"; import { remark } from "remark";
import remarkHtml from "remark-html"; import remarkHtml from "remark-html";
@@ -16,7 +16,7 @@ const LoadingPage = lazy(async () => import("@/page/Loading"));
const ParagraphPage = lazy(async () => import("@/page/Paragraph")); const ParagraphPage = lazy(async () => import("@/page/Paragraph"));
const SettingsPage = lazy(async () => import("@/page/Settings")); const SettingsPage = lazy(async () => import("@/page/Settings"));
const router = createBrowserRouter([ const router = createHashRouter([
{ {
path: "/", path: "/",
element: <MainLayout />, element: <MainLayout />,

View File

@@ -8,16 +8,16 @@ export interface OptionsState {
const optionsSlice = createSlice({ const optionsSlice = createSlice({
name: "stats", name: "stats",
initialState: { initialState: {
zincsearchUrl: "https://zincsearch.k8s.yoshino-s.xyz", zincsearchUrl: "https://zincsearch.yoshino-s.xyz",
s3Url: "https://s3.yoshino-s.xyz", s3Url: "https://minio-hdd.yoshino-s.xyz",
} as OptionsState, } as OptionsState,
reducers: { reducers: {
setZincsearchUrl: (state, action: PayloadAction<string | undefined>) => { setZincsearchUrl: (state, action: PayloadAction<string | undefined>) => {
state.zincsearchUrl = state.zincsearchUrl =
action.payload ?? "https://zincsearch.k8s.yoshino-s.xyz"; action.payload ?? "https://zincsearch.yoshino-s.xyz";
}, },
setS3Url: (state, action: PayloadAction<string | undefined>) => { setS3Url: (state, action: PayloadAction<string | undefined>) => {
state.s3Url = action.payload ?? "https://s3.yoshino-s.xyz"; state.s3Url = action.payload ?? "https://minio-hdd.yoshino-s.xyz";
}, },
}, },
}); });

5436
yarn.lock

File diff suppressed because it is too large Load Diff