mirror of
https://github.com/vercel/next.js.git
synced 2026-09-20 02:25:18 +08:00
d45fc5ad95
## Summary Fix typos in code, styles, and documentation across multiple example projects Chores: - Correct variable name typo in the with-slate example (edtorState→editorState) - Fix CSS/SASS class name misspellings (populer→popular, Serach→Search, serachSelector→searchSelector) - Update example documentation and comments to fix English typos (Data SOUCE→SOURCE, accessiblity→accessibility, exchanges, doesn't, deploying, validates, quickly) ### Adding or Updating Examples - [x] The "examples guidelines" are followed from our contributing doc https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md - [x] Make sure the linting passes by running `pnpm build && pnpm lint`. See https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
79 lines
2.5 KiB
JavaScript
79 lines
2.5 KiB
JavaScript
import Head from "next/head";
|
|
import styles from "../styles/Home.module.css";
|
|
import { connectToDatabase } from "../util/couchbase";
|
|
|
|
export default function Home({ isConnected }) {
|
|
return (
|
|
<div className={styles.container}>
|
|
<Head>
|
|
<title>Create Next App</title>
|
|
<link rel="icon" href="/favicon.ico" />
|
|
</Head>
|
|
|
|
<main className={styles.main}>
|
|
<h1 className={styles.title}>
|
|
Welcome to <a href="https://nextjs.org">Next.js with Couchbase!</a>
|
|
</h1>
|
|
|
|
{isConnected ? (
|
|
<h2 className={`${styles.subtitle} ${styles.green}`}>
|
|
You are connected to Couchbase
|
|
</h2>
|
|
) : (
|
|
<>
|
|
<h2 className={`${styles.subtitle} ${styles.red}`}>
|
|
You are NOT connected to Couchbase. Try refreshing the page, and
|
|
if this error persists check the <code>README.md</code> for
|
|
instructions.
|
|
</h2>
|
|
<em className={styles.center}>
|
|
Note: if the database was recently started, you might have to
|
|
re-start the app (in dev mode) or re-deploy to your serverless
|
|
environment for changes to take effect.
|
|
</em>
|
|
</>
|
|
)}
|
|
|
|
<p className={styles.description}>
|
|
Get started by editing{" "}
|
|
<code className={styles.code}>pages/index.js</code>
|
|
</p>
|
|
</main>
|
|
|
|
<footer className={styles.footer}>
|
|
<a
|
|
href="https://vercel.com?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
|
|
target="_blank"
|
|
rel="noopener noreferrer"
|
|
>
|
|
Powered by{" "}
|
|
<img src="/vercel.svg" alt="Vercel Logo" className={styles.logo} />
|
|
</a>
|
|
</footer>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export async function getServerSideProps(context) {
|
|
let connection = await connectToDatabase();
|
|
|
|
const { collection } = connection;
|
|
|
|
// Check connection with a KV GET operation for a key that doesn't exist
|
|
let isConnected = false;
|
|
try {
|
|
await collection.get("testingConnectionKey");
|
|
} catch (err) {
|
|
// error message will return 'document not found' if and only if we are connected
|
|
// (but this document is not present, we're only trying to test the connection here)
|
|
if (err.message === "document not found") {
|
|
isConnected = true;
|
|
}
|
|
// if the error message is anything OTHER THAN 'document not found', the connection is broken
|
|
}
|
|
|
|
return {
|
|
props: { isConnected },
|
|
};
|
|
}
|