mirror of
https://github.com/Lumither/nocturne.git
synced 2026-10-17 18:36:21 +00:00
feat(global) new api rule, NextImage support, test openresty
This commit is contained in:
9 files changed
+47
-13
No files matched your search
@@ -1,6 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Card, CardBody, CardFooter } from '@nextui-org/card';
|
import { Card, CardBody, CardFooter } from '@nextui-org/card';
|
||||||
import { Chip, Image } from '@nextui-org/react';
|
import { Chip, Image } from '@nextui-org/react';
|
||||||
|
import NextImage from 'next/image';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { MdCalendarMonth, MdNorthEast } from 'react-icons/md';
|
import { MdCalendarMonth, MdNorthEast } from 'react-icons/md';
|
||||||
|
|
||||||
@@ -28,16 +29,18 @@ function BlogPostCard({ post }: Props) {
|
|||||||
isHoverable
|
isHoverable
|
||||||
>
|
>
|
||||||
|
|
||||||
{ header_img !== '' && <div className={ `w-full overflow-visible` }>
|
|
||||||
|
{ header_img !== '' && <div className={ `w-full overflow h-80 relative` }>
|
||||||
<Image
|
<Image
|
||||||
|
as={ NextImage }
|
||||||
alt={ 'cover picture' }
|
alt={ 'cover picture' }
|
||||||
src={ header_img }
|
src={ header_img }
|
||||||
className={ `z-20 h-80 w-full object-cover rounded-b-none` }
|
className={ `w-full object-cover rounded-b-none` }
|
||||||
style={ {
|
style={ {
|
||||||
'maskImage': 'linear-gradient(black 95%, transparent)',
|
'maskImage': 'linear-gradient(black 95%, transparent)',
|
||||||
'backdropFilter': 'blur(20px)'
|
'backdropFilter': 'blur(20px)'
|
||||||
} }
|
} }
|
||||||
width={ `100%` }
|
fill
|
||||||
removeWrapper
|
removeWrapper
|
||||||
></Image>
|
></Image>
|
||||||
</div> }
|
</div> }
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
export default async function fetch_posts_list(): Promise<any> {
|
export default async function fetch_posts_list(): Promise<any> {
|
||||||
const response = await axios(`http://localhost:${ process.env.BACKEND_PORT }/api/get/post_list`);
|
const response = await axios(`${ process.env.BACKEND_URL }/get_post_list`);
|
||||||
if (response.status !== 200) {
|
if (response.status !== 200) {
|
||||||
throw new Error(response.statusText);
|
throw new Error(response.statusText);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
'use server';
|
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import Markdown from 'react-markdown';
|
import Markdown from 'react-markdown';
|
||||||
import { Card, CardBody } from '@nextui-org/card';
|
import { Card, CardBody } from '@nextui-org/card';
|
||||||
@@ -19,7 +17,7 @@ async function Generate(props: Props) {
|
|||||||
|
|
||||||
let response: any;
|
let response: any;
|
||||||
try {
|
try {
|
||||||
response = await axios(`http://localhost:${ process.env.BACKEND_PORT }/api/get/post/${ props.id }`);
|
response = await axios(`${ process.env.BACKEND_URL }/get_post/${ props.id }`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return (
|
return (
|
||||||
<Card className={ `w-full` }>
|
<Card className={ `w-full` }>
|
||||||
@@ -38,7 +36,7 @@ async function Generate(props: Props) {
|
|||||||
<Card className={ `w-full max-w-full relative` }>
|
<Card className={ `w-full max-w-full relative` }>
|
||||||
<CardBody>
|
<CardBody>
|
||||||
<Markdown
|
<Markdown
|
||||||
className={ `p-5 max-w-full text-justify text-pretty会 prose prose-sm dark:prose-invert md:prose-md lg:prose-lg` }
|
className={ `p-5 max-w-full text-justify text-pretty prose prose-sm dark:prose-invert md:prose-md lg:prose-lg` }
|
||||||
remarkPlugins={ [ remarkGfm, remarkToc, remarkFrontmatter ] }
|
remarkPlugins={ [ remarkGfm, remarkToc, remarkFrontmatter ] }
|
||||||
rehypePlugins={ [ rehypeHighlight, rehypeRaw, rehypeSanitize ] }
|
rehypePlugins={ [ rehypeHighlight, rehypeRaw, rehypeSanitize ] }
|
||||||
>{ (post_data as any)['content'] }</Markdown>
|
>{ (post_data as any)['content'] }</Markdown>
|
||||||
|
|||||||
+3
-3
@@ -32,9 +32,9 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
.expect("failed to load database");
|
.expect("failed to load database");
|
||||||
|
|
||||||
let app = Router::new()
|
let app = Router::new()
|
||||||
.route("/api/post/refresh", post(refresh))
|
.route("/refresh_posts", post(refresh))
|
||||||
.route("/api/get/post_list", get(get_post_list))
|
.route("/get_post_list", get(get_post_list))
|
||||||
.route("/api/get/post/:post_id", get(get_post))
|
.route("/get_post/:post_id", get(get_post))
|
||||||
.with_state(db_pool);
|
.with_state(db_pool);
|
||||||
|
|
||||||
let listener = tokio::net::TcpListener::bind(format!("0.0.0.0:{}", port)).await?;
|
let listener = tokio::net::TcpListener::bind(format!("0.0.0.0:{}", port)).await?;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { Button, Image } from '@nextui-org/react';
|
import { Button, Image } from '@nextui-org/react';
|
||||||
|
import NextImage from 'next/image';
|
||||||
import {
|
import {
|
||||||
IoFileTrayFull,
|
IoFileTrayFull,
|
||||||
IoHome,
|
IoHome,
|
||||||
@@ -115,11 +116,13 @@ function Navbar() {
|
|||||||
<div className={ `hidden md:block` }>
|
<div className={ `hidden md:block` }>
|
||||||
<div className={ `flex justify-center items-center my-7` }>
|
<div className={ `flex justify-center items-center my-7` }>
|
||||||
<Image
|
<Image
|
||||||
|
as={ NextImage }
|
||||||
src={ 'https://oss.lumither.com/blog/pictures/compr/1717153492846703409_avatar.webp' }
|
src={ 'https://oss.lumither.com/blog/pictures/compr/1717153492846703409_avatar.webp' }
|
||||||
alt={ 'avatar' }
|
alt={ 'avatar' }
|
||||||
width={ 200 }
|
width={ 200 }
|
||||||
height={ 200 }
|
height={ 200 }
|
||||||
className={ 'rounded-full justify-self-center' }
|
className={ 'rounded-full justify-self-center' }
|
||||||
|
fetchPriority={ 'high' }
|
||||||
removeWrapper
|
removeWrapper
|
||||||
></Image>
|
></Image>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+10
-1
@@ -1,4 +1,13 @@
|
|||||||
/** @type {import('next').NextConfig} */
|
/** @type {import('next').NextConfig} */
|
||||||
const nextConfig = {};
|
const nextConfig = {
|
||||||
|
images: {
|
||||||
|
remotePatterns: [
|
||||||
|
{
|
||||||
|
protocol: 'https',
|
||||||
|
hostname: 'oss.lumither.com'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export default nextConfig;
|
export default nextConfig;
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
location / {
|
||||||
|
default_type text/html;
|
||||||
|
proxy_pass http://localhost:3000;
|
||||||
|
proxy_redirect off;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /api/ {
|
||||||
|
rewrite ^/api(/.*)$ $1 break;
|
||||||
|
proxy_pass http://localhost:3001;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
}
|
||||||
Executable
+4
@@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
rm -rf /opt/openresty/nginx/lua
|
||||||
|
cp -r ./lua /opt/openresty/nginx
|
||||||
+2
-1
@@ -24,7 +24,8 @@
|
|||||||
"rehype-sanitize": "^6.0.0",
|
"rehype-sanitize": "^6.0.0",
|
||||||
"remark-frontmatter": "^5.0.0",
|
"remark-frontmatter": "^5.0.0",
|
||||||
"remark-gfm": "^4.0.0",
|
"remark-gfm": "^4.0.0",
|
||||||
"remark-toc": "^9.0.0"
|
"remark-toc": "^9.0.0",
|
||||||
|
"sharp": "^0.33.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tailwindcss/typography": "^0.5.13",
|
"@tailwindcss/typography": "^0.5.13",
|
||||||
|
|||||||
Reference in new issue
Block a user