mirror of
https://github.com/SrIzan10/mainwebsite.git
synced 2026-06-06 00:56:58 +00:00
Refractor/cloudflare-pages (#8)
* move to cf pages * no static exports * empty commit * generate blog posts * add to build * move to src on the script * edge runtime
This commit is contained in:
1
.yarnrc.yml
Normal file
1
.yarnrc.yml
Normal file
@@ -0,0 +1 @@
|
||||
nodeLinker: node-modules
|
||||
@@ -5,7 +5,7 @@
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "node src/blogPostGenerator.js && next dev",
|
||||
"build": "next build",
|
||||
"build": "node src/blogPostGenerator.js && next build",
|
||||
"start": "node src/blogPostGenerator.js;next start",
|
||||
"lint": "next lint"
|
||||
},
|
||||
@@ -14,8 +14,6 @@
|
||||
"@emotion/styled": "^11.11.0",
|
||||
"@mui/lab": "^5.0.0-alpha.153",
|
||||
"@mui/material": "^5.14.18",
|
||||
"@vercel/edge-config": "^0.4.1",
|
||||
"@vercel/speed-insights": "^1.0.2",
|
||||
"dayjs": "^1.11.10",
|
||||
"feed": "^4.2.2",
|
||||
"glob": "^10.3.10",
|
||||
@@ -37,5 +35,6 @@
|
||||
"eslint": "^8",
|
||||
"eslint-config-next": "14.0.2",
|
||||
"typescript": "^5"
|
||||
}
|
||||
},
|
||||
"packageManager": "yarn@4.1.1"
|
||||
}
|
||||
|
||||
@@ -5,13 +5,15 @@ import { atomDark } from 'react-syntax-highlighter/dist/esm/styles/prism'
|
||||
import BlogNavBar from "../../../_components/NavBar";
|
||||
import '../../../_css/BlogPost.css';
|
||||
import React from "react";
|
||||
import jsonDataArray from '../../../../../public/blogPosts.json';
|
||||
import jsonDataArray from '@/blogPosts.json';
|
||||
import { redirect } from "next/navigation";
|
||||
import { Metadata } from 'next';
|
||||
import dayjs from 'dayjs';
|
||||
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
||||
dayjs.extend(customParseFormat)
|
||||
|
||||
export const runtime = 'edge';
|
||||
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
const id = parseInt(params.id);
|
||||
if (Number.isNaN(id)) redirect('/blog')
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import '../../../app/_css/Blog.css';
|
||||
import blogPosts from '../../../../public/blogPosts.json'
|
||||
import blogPosts from '@/blogPosts.json'
|
||||
import BlogPostCard from '../../../app/_components/BlogPostCard';
|
||||
import BlogNavBar from '../../_components/NavBar';
|
||||
import BlogRssDial from '@/app/_components/BlogRssDial';
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
import NavBar from "@/app/_components/NavBar";
|
||||
import { get } from '@vercel/edge-config';
|
||||
import Link from "next/link";
|
||||
import { redirect } from "next/navigation";
|
||||
import '../../../_css/LinkShortenerVerification.css';
|
||||
import { Metadata } from 'next';
|
||||
|
||||
export default async function Page({ params }: { params: { name: string } }) {
|
||||
const getLink = await get(params.name) as string | undefined;
|
||||
if (!getLink) {
|
||||
redirect('../notfound')
|
||||
}
|
||||
const url = new URL(getLink);
|
||||
return (
|
||||
<div>
|
||||
<NavBar title={'Link shortener'} />
|
||||
<div className="navbarMargin center">
|
||||
<h3>This link sends you to {url.hostname}</h3>
|
||||
<Link href={url.toString()}>Go there I don't care</Link>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export async function generateMetadata({ params }: { params: { name: string } }): Promise<Metadata> {
|
||||
return {
|
||||
title: `Link shortener ID ${params.name}`
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ import type { Metadata } from 'next'
|
||||
import { Inter } from 'next/font/google'
|
||||
import './globals.css'
|
||||
import { RootStyleRegistry } from './_components/ThemeRegistry/EmotionRootStyleRegistry';
|
||||
import { SpeedInsights } from "@vercel/speed-insights/next"
|
||||
|
||||
const inter = Inter({ subsets: ['latin'] })
|
||||
|
||||
@@ -18,7 +17,6 @@ export default function RootLayout({
|
||||
}) {
|
||||
return (
|
||||
<html lang="en">
|
||||
<SpeedInsights />
|
||||
<head>
|
||||
<script async src="https://analytics.srizan.dev/ua.js" data-website-id="54ccb44c-b03c-4790-8262-3e1a82241a24" />
|
||||
</head>
|
||||
|
||||
@@ -61,7 +61,7 @@ await glob('./src/blog/**/*.md').then(async (files) => {
|
||||
|
||||
data.sort((a, b) => b.id - a.id);
|
||||
|
||||
fs.writeFileSync('./public/blogPosts.json', JSON.stringify(data))
|
||||
fs.writeFileSync('./src/blogPosts.json', JSON.stringify(data))
|
||||
fs.writeFileSync('./public/blog/feed.json', feed.json1())
|
||||
fs.writeFileSync('./public/blog/rss.xml', feed.rss2())
|
||||
fs.writeFileSync('./public/blog/atom.xml', feed.atom1())
|
||||
Reference in New Issue
Block a user