From 2bef73262870758ef19959f91e56548713f8d860 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Batuhan=20Y=2E=20Y=C4=B1lmaz?= <70820809+B4tuhanY1lmaz@users.noreply.github.com> Date: Sat, 3 Feb 2024 18:56:56 +0300 Subject: [PATCH] Add Markdown based pages --- app/[page]/page.jsx | 54 +++++++++++++++++++++++++++++++++++++++++ app/about/page.jsx | 43 -------------------------------- libs/getPageMetadata.js | 17 +++++++++++++ public/pages/about.md | 38 +++++++++++++++++------------ 4 files changed, 93 insertions(+), 59 deletions(-) create mode 100644 app/[page]/page.jsx delete mode 100644 app/about/page.jsx create mode 100644 libs/getPageMetadata.js diff --git a/app/[page]/page.jsx b/app/[page]/page.jsx new file mode 100644 index 0000000..52f86fa --- /dev/null +++ b/app/[page]/page.jsx @@ -0,0 +1,54 @@ +import fs from "fs" +import Markdown from "markdown-to-jsx" +import matter from "gray-matter" +import { getPageMetadata } from "@/libs/getPageMetadata" + +import HeroSection from "@/components/hero-section" +const getPageContent = (page) => { + const folder = "public/pages/" + const file = `${folder}${page}.md` + const content = fs.readFileSync(file, "utf8") + const matterResult = matter(content) + return matterResult +} + +export async function generateStaticParams() { + const pages = await getPageMetadata() + return pages.map((page) => ({ + page: page.page + })) +} + +export function generateMetadata(props) { + const page = props.params.page + const content = getPageContent(page) + + return { + title: content.data.title + } +} + +function MarkdownPages(props) { + const page = props.params.page + const content = getPageContent(page) + + return ( +
+
+ +
+
+
+ + {content.content} + +
+
+
+ ) +} + +export default MarkdownPages \ No newline at end of file diff --git a/app/about/page.jsx b/app/about/page.jsx deleted file mode 100644 index d8b1596..0000000 --- a/app/about/page.jsx +++ /dev/null @@ -1,43 +0,0 @@ -import fs from "fs"; -import Markdown from "markdown-to-jsx"; -import matter from "gray-matter"; -import localFont from "next/font/local"; - -const myFont = localFont({ - src: "../photos/Minecraft.woff2", - display: 'swap', -}); - -export const metadata = { - title: "About The Batuhan's Network SMP", - description: "Rules and much more." -} - -function AboutPage() { - const getPageContent = () => { - const file = "public/pages/about.md" - const content = fs.readFileSync(file, "utf-8") - const MatterResult = matter(content) - return MatterResult - } - const content = getPageContent() - - return ( -
-
-

About

-
-
-
- - {content.content} - -
-
-
- ) -} - -export default AboutPage; - - diff --git a/libs/getPageMetadata.js b/libs/getPageMetadata.js new file mode 100644 index 0000000..8bb5f23 --- /dev/null +++ b/libs/getPageMetadata.js @@ -0,0 +1,17 @@ +import fs from "fs"; +import matter from "gray-matter"; + +export const getPageMetadata = () => { + const folder = "public/pages/"; + const files = fs.readdirSync(folder); + const markdownPosts = files.filter((file) => file.endsWith(".md")); + const pages = markdownPosts.map((filename) => { + const fileContents = fs.readFileSync(`${folder}${filename}`, "utf8"); + const matterResult = matter(fileContents); + return { + title: matterResult.data.title, + page: filename.replace(".md", ""), + }; + }); + return pages; +} \ No newline at end of file diff --git a/public/pages/about.md b/public/pages/about.md index 8451724..72e437f 100644 --- a/public/pages/about.md +++ b/public/pages/about.md @@ -1,22 +1,28 @@ -## The Batuhan's Network SMP -- A cracked SMP server with some tweaks over Vanilla Minecraft. -- Near zero rule experience! -- *And much more!* +--- +title: About Us +url: about +--- +# Caesium +Caesium is a simple Markdown based website written using NextJS. -### What's this server? -The Batuhan's Network SMP (shortly tbnmc) is a simple SMP (Survival Multi Player) server that aims to give you a great experience of playing on a survival world with other people. +## Features: +- 📝 Markdown based +- 💾 Staticly rendered +- 🔎 SEO Optimized -In our world generation we used [Terralith](https://www.curseforge.com/minecraft/mc-mods/terralith) and [Structory](https://www.curseforge.com/minecraft/mc-mods/structory) mods to add more places and landscapes to explore with your friends! +## Getting Started -### Rules -To keep our server a nice and secure place we have some tiny rules that easy to follow. +- Edit the siteconfig.json over at ```config/siteconfig.json``` +- Edit the about page over at ```public/pages/about.md``` +- Place your images to ```public/photos``` +- Place your posts to ```public/posts``` -- No Griefing or stealing from other people! -- You can't move into other peoples base without permission. -- No chat spamming! +### Deploying -### Contact -If something goes wrong and you need help, we're always open to help you out. You can reach us from either our Discord Server or send our admin an e-mail. +#### Vercel +- Fork this repo and edit your content according to ```Getting Started section``` +- Go to [vercel.com](https://vercel.com) and create a new project from your forked repo. +- Enjoy! -- [Discord Server](https://discord.gg/8dAHkxbKPf) -- [E-mail](mailto://batuhan@thebatuhansnetwork.xyz) +### SelfHosting +- You can read my blogpost for more information. [How I deploy my NextJS projects with Nginx and Cloudflare Tunnel.](https://www.thebatuhansnetwork.xyz/blog/2023-09-05-how-i-deploy-my-nextjs).