Skip to content

Commit

Permalink
Fix: Migrate back to pages router :/
Browse files Browse the repository at this point in the history
  • Loading branch information
adil192 committed Dec 14, 2024
1 parent 0fcc41f commit c87f2fe
Show file tree
Hide file tree
Showing 12 changed files with 103 additions and 71 deletions.
2 changes: 1 addition & 1 deletion next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
// see https://nextjs.org/docs/pages/api-reference/config/typescript for more information.
File renamed without changes.
1 change: 0 additions & 1 deletion public/next.svg

This file was deleted.

1 change: 0 additions & 1 deletion public/vercel.svg

This file was deleted.

32 changes: 0 additions & 32 deletions src/app/layout.tsx

This file was deleted.

30 changes: 0 additions & 30 deletions src/app/privacy_policy/page.tsx

This file was deleted.

6 changes: 6 additions & 0 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import "./styles/globals.css";
import type { AppProps } from "next/app";

export default function App({ Component, pageProps }: AppProps) {
return <Component {...pageProps} />;
}
13 changes: 13 additions & 0 deletions src/pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Html, Head, Main, NextScript } from "next/document";

export default function Document() {
return (
<Html lang="en">
<Head />
<body>
<Main />
<NextScript />
</body>
</Html>
);
}
36 changes: 30 additions & 6 deletions src/app/page.tsx → src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
'use client';

import Image from 'next/image'
import styles from './page.module.css'
import styles from "./styles/Home.module.css";
import { useEffect } from 'react';
import { annotate, annotationGroup } from 'rough-notation';
import assert from 'assert';
import { Neucha } from 'next/font/google'
import Head from "next/head";
import Link from 'next/link';

const neucha = Neucha({
weight: "400",
preload: true,
fallback: [
"Neucha", "Dekko",
// fallbacks from https://github.com/system-fonts/modern-font-stacks#handwritten
'Segoe Print', 'Bradley Hand', 'Chilanka', 'TSCu_Comic',
'casual', 'cursive',
],
subsets: ["latin"],
})

/**
* This function gets the latest version of Saber from GitHub,
Expand All @@ -20,12 +35,13 @@ async function getVersionName(): Promise<string> {
return versionWithoutV;
}

export default async function () {
export async function getStaticProps() {
const versionName = await getVersionName();
return <Home versionName={versionName} />;

return { props: { versionName } };
}

function Home({ versionName }: { versionName: string }) {
export default function Home({ versionName }: { versionName: string }) {
useEffect(() => {
const highlightColor = "var(--highlight-color)";

Expand Down Expand Up @@ -77,7 +93,14 @@ function Home({ versionName }: { versionName: string }) {
}, []);

return (
<main className={styles.main}>
<>
<Head>
<title>Saber</title>
<meta name="description" content="The notes app built for handwriting" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" href="/favicon.ico" />
</Head>
<main className={`${styles.main} ${neucha.className}`}>
<div className={styles.header}>
<h1 className={styles.title}>
Saber
Expand Down Expand Up @@ -165,7 +188,7 @@ function Home({ versionName }: { versionName: string }) {
</p>
<p>
You can also read the{' '}
<a href="/privacy_policy">privacy policy</a>.
<Link href="/privacy_policy">privacy policy</Link>.
</p>
</div>

Expand Down Expand Up @@ -233,5 +256,6 @@ function Home({ versionName }: { versionName: string }) {
</p>
</div>
</main>
</>
)
}
53 changes: 53 additions & 0 deletions src/pages/privacy_policy/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
'use client';

import { Neucha } from 'next/font/google';
import Head from 'next/head';
import ReactMarkdown from 'react-markdown'

const neucha = Neucha({
weight: "400",
preload: true,
fallback: [
"Neucha", "Dekko",
// fallbacks from https://github.com/system-fonts/modern-font-stacks#handwritten
'Segoe Print', 'Bradley Hand', 'Chilanka', 'TSCu_Comic',
'casual', 'cursive',
],
subsets: ["latin"],
})

async function getPrivacyPolicyMarkdown(): Promise<string> {
const res = await fetch('https://raw.githubusercontent.com/saber-notes/saber/main/privacy_policy.md');
const text = await res.text();
return text;
}

export async function getStaticProps() {
const markdown = await getPrivacyPolicyMarkdown();

return { props: { markdown } };
}

export default function PrivacyPolicy({ markdown }: { markdown: string }) {
return (
<>
<Head>
<title>Saber: Privacy Policy</title>
<meta name="description" content="The notes app built for handwriting" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" href="/favicon.ico" />
</Head>
<main className={neucha.className}>
<ReactMarkdown>{markdown}</ReactMarkdown>

<br />
<p>
See this page on{' '}
<a href="https://github.com/saber-notes/saber/blob/main/privacy_policy.md">
GitHub
</a>
</p>
</main>
</>
);
}
File renamed without changes.
File renamed without changes.

0 comments on commit c87f2fe

Please sign in to comment.