prefix
stringlengths
512
512
suffix
stringlengths
256
256
middle
stringlengths
14
229
meta
dict
orPage from "next/error"; import Container from "@/components/container"; import PostBody from "@/components/post-body"; import MoreStories from "@/components/more-stories"; import Header from "@/components/header"; import PostHeader from "@/components/post-header"; import SectionSeparator from "@/components/section-se...
>; } return ( <Layout preview={preview}> <Container> <Header /> {router.isFallback ? ( <PostTitle>Loading…</PostTitle> ) : ( <> <article> <Head> <title>
t/head"; import { CMS_NAME } from "@/lib/constants"; export default function Post({ post, morePosts, preview }) { const router = useRouter(); if (!router.isFallback && !post?._slug) { return <ErrorPage statusCode={404} /
{ "filepath": "examples/cms-prepr/pages/posts/[slug].js", "language": "javascript", "file_size": 2141, "cut_index": 563, "middle_length": 229 }
ort Avatar from "./avatar"; import Date from "./date"; import CoverImage from "./cover-image"; import Link from "next/link"; export default function HeroPost({ title, coverImage, date, excerpt, author, slug, }) { return ( <section> <div className="mb-8 md:mb-16"> <CoverImage title={titl...
<Date dateString={date} /> </div> )} </div> <div> <div className="text-lg leading-relaxed mb-4" dangerouslySetInnerHTML={{ __html: excerpt }} ></div> <Avata
t-6xl leading-tight"> <Link href={`/posts/${slug}`} className="hover:underline"> {title} </Link> </h3> {date && ( <div className="mb-4 md:mb-0 text-lg">
{ "filepath": "examples/cms-prepr/components/hero-post.js", "language": "javascript", "file_size": 1115, "cut_index": 515, "middle_length": 229 }
ext/link"; import styles from "../styles/Home.module.css"; export default function Home() { return ( <div className={styles.container}> <main className={styles.main}> <h1 className={styles.title}> Welcome to <a href="https://nextjs.org">Next.js!</a> </h1> <p className={st...
<h2>Documentation &rarr;</h2> <p>Find in-depth information about Next.js features and API.</p> </a> <a href="https://nextjs.org/learn" className={styles.card}> <h2>Learn &rarr;</h2> <p>Learn ab
"/about" className={styles.card}> <h2>About Page &rarr;</h2> <p>Cypress will test if this link is working.</p> </Link> <a href="https://nextjs.org/docs" className={styles.card}>
{ "filepath": "examples/with-cypress/app/page.tsx", "language": "tsx", "file_size": 2285, "cut_index": 563, "middle_length": 229 }
{ withPayload } = require("@payloadcms/next-payload"); const path = require("path"); /** @type {import('next').NextConfig} */ const nextConfig = withPayload( { reactStrictMode: true, rewrites: [{ source: "/admin/(.*)", destination: "/admin/index.html" }], images: { remotePatterns: [ { ...
rocess.env.NEXT_PUBLIC_S3_HOSTNAME, port: "", pathname: `/${process.env.NEXT_PUBLIC_S3_BUCKET}/**`, }, ], }, }, { configPath: path.resolve(__dirname, "./payload/payload.config.ts"), }, ); module.exports = ne
hostname: p
{ "filepath": "examples/cms-payload/next.config.js", "language": "javascript", "file_size": 797, "cut_index": 517, "middle_length": 14 }
{ buildConfig } from "payload/config"; import path from "path"; import { Users } from "./collections/Users"; import { Pages } from "./collections/Pages"; import { MainMenu } from "./globals/MainMenu"; import { cloudStorage } from "@payloadcms/plugin-cloud-storage"; import { s3Adapter } from "@payloadcms/plugin-cloud-s...
ET as string, }); export default buildConfig({ collections: [Pages, Users, Media], globals: [MainMenu], typescript: { outputFile: path.resolve(__dirname, "../payload-types.ts"), }, graphQL: { schemaOutputFile: path.resolve(__dirname, "ge
ION, forcePathStyle: true, credentials: { accessKeyId: process.env.S3_ACCESS_KEY_ID as string, secretAccessKey: process.env.S3_SECRET_ACCESS_KEY as string, }, }, bucket: process.env.NEXT_PUBLIC_S3_BUCK
{ "filepath": "examples/cms-payload/payload/payload.config.ts", "language": "typescript", "file_size": 1205, "cut_index": 518, "middle_length": 229 }
backgroundColor } from "../../fields/backgroundColor"; export const MediaBlock: Block = { slug: "mediaBlock", fields: [ { type: "row", fields: [ backgroundColor({ overrides: { name: "mediaBlockBackgroundColor" } }), { name: "position", type: "select", ...
], }, ], }, { name: "media", type: "upload", relationTo: "media", required: true, }, { name: "caption", type: "richText", admin: { elements: ["link"], }, }, ],
value: "fullscreen", },
{ "filepath": "examples/cms-payload/payload/blocks/Media/index.ts", "language": "typescript", "file_size": 870, "cut_index": 559, "middle_length": 52 }
orPage from "next/error"; import Container from "../../components/container"; import PostBody from "../../components/post-body"; import Header from "../../components/header"; import PostHeader from "../../components/post-header"; import SectionSeparator from "../../components/section-separator"; import Layout from "../...
const router = useRouter(); if (!router.isFallback && !post?.url) { return <ErrorPage statusCode={404} />; } return ( <Layout preview={preview}> <Container> <Header /> {router.isFallback ? ( <PostTitle>Loadi
om "../../lib/constants"; import Tags from "../../components/tags"; import PostType from "../../types/postType"; type Props = { post: PostType; preview: boolean; }; export default function Post({ post, preview }: Props) {
{ "filepath": "examples/cms-enterspeed/pages/posts/[slug].tsx", "language": "tsx", "file_size": 2581, "cut_index": 563, "middle_length": 229 }
/* eslint-disable */ // Disable ESLint to prevent failing linting inside the Next.js repo. // If you're using ESLint on your project, we recommend installing the ESLint Cypress plugin instead: // https://github.com/cypress-io/eslint-plugin-cypress // Cypress Component Test describe("<AboutComponent />", () => { it(...
ins("About Page"); // Validate that a link with the expected URL is present // *Following* the link is better suited to an E2E test cy.get('a[href="/"]').should("be.visible"); }); }); // Prevent TypeScript from reading file as legacy script
ntain an h1 with "About page" cy.get("h1").conta
{ "filepath": "examples/with-cypress/components/about-component.cy.tsx", "language": "tsx", "file_size": 879, "cut_index": 559, "middle_length": 52 }
BY HAND. Instead, modify your source Payload config, * and re-run `payload generate:types` to regenerate this file. */ export interface Config { collections: { pages: Page; users: User; media: Media; }; globals: { "main-menu": MainMenu; }; } export interface Page { id: string; title: stri...
id?: string; }[]; media: string | Media; }; layout: ( | { ctaBackgroundColor?: "white" | "black"; richText: { [k: string]: unknown; }[]; links: { link: { type?: "reference
newTab?: boolean; reference: { value: string | Page; relationTo: "pages"; }; url: string; label: string; appearance?: "default" | "primary" | "secondary"; };
{ "filepath": "examples/cms-payload/payload-types.ts", "language": "typescript", "file_size": 4257, "cut_index": 614, "middle_length": 229 }
rom "payload/types"; import { backgroundColor } from "../../fields/backgroundColor"; import link from "../../fields/link"; import richText from "../../fields/richText"; const columnFields: Field[] = [ richText(), { name: "enableLink", type: "checkbox", }, link({ overrides: { admin: { ...
Column", value: "oneColumn", }, { label: "Two Thirds + One Third", value: "twoThirdsOneThird", }, { label: "Half + Half", value: "halfAndH
backgroundColor({ overrides: { name: "contentBackgroundColor" } }), { name: "layout", type: "select", defaultValue: "oneColumn", options: [ { label: "One
{ "filepath": "examples/cms-payload/payload/blocks/Content/index.ts", "language": "typescript", "file_size": 1690, "cut_index": 537, "middle_length": 229 }
useEffect } from "react"; import { I18nProvider } from "@lingui/react"; import { i18n } from "@lingui/core"; import { useRouter } from "next/router"; import { en, sv } from "make-plural/plurals"; import LangSwitcher from "../components/LangSwitcher"; i18n.loadLocaleData("en", { plurals: en }); i18n.loadLocaleData("s...
i18n.load(locale, messages); i18n.activate(locale); } load(locale); }, [locale]); return ( <I18nProvider i18n={i18n}> <div> <LangSwitcher /> <Component {...pageProps} /> </div> </I18nProvider>
} = await import(`../locale/${locale}/messages.po`);
{ "filepath": "examples/with-lingui/pages/_app.js", "language": "javascript", "file_size": 836, "cut_index": 520, "middle_length": 52 }
Payload } from "payload/dist/payload"; import config from "./payload.config"; if (!process.env.MONGODB_URI) { throw new Error("MONGODB_URI environment variable is missing"); } if (!process.env.PAYLOAD_SECRET) { throw new Error("PAYLOAD_SECRET environment variable is missing"); } /** * Global is used here to mai...
{ if (cached.client) { return cached.client; } if (!cached.promise) { cached.promise = await getPayload({ // Make sure that your environment variables are filled out accordingly mongoURL: process.env.MONGODB_URI as string,
canary/examples/with-mongodb-mongoose/lib/dbConnect.ts */ let cached = (global as any).payload; if (!cached) { cached = (global as any).payload = { client: null, promise: null }; } export const getPayloadClient = async () =>
{ "filepath": "examples/cms-payload/payload/payloadClient.ts", "language": "typescript", "file_size": 1263, "cut_index": 524, "middle_length": 229 }
ent, HttpLink, InMemoryCache } from "@apollo/client"; import { concatPagination } from "@apollo/client/utilities"; import merge from "deepmerge"; import isEqual from "lodash/isEqual"; let apolloClient; function createApolloClient() { return new ApolloClient({ ssrMode: typeof window === "undefined", link: ne...
n initializeApollo(initialState = null) { const _apolloClient = apolloClient ?? createApolloClient(); // If your page has Next.js data fetching methods that use Apollo Client, the initial state // get hydrated here if (initialState) { // Get e
redentials` or `headers` }), cache: new InMemoryCache({ typePolicies: { Query: { fields: { allPosts: concatPagination(), }, }, }, }), }); } export functio
{ "filepath": "examples/with-apollo-and-redux/lib/apollo.js", "language": "javascript", "file_size": 2030, "cut_index": 563, "middle_length": 229 }
mport type { NextApiRequest, NextApiResponse } from "next"; import { client, e } from "../../../client"; // PATCH /api/post/:id async function updatePost( postId: string, data: { title?: string; content?: string }, ) { return await e .update(e.Post, (post) => ({ filter: e.op(post.id, "=", e.uuid(postId...
uery.id as string; if (req.method === "DELETE") { res.json(await deletePost(postId)); } else if (req.method === "PATCH") { res.json(await updatePost(postId, req.body)); } else { throw new Error( `The HTTP ${req.method} method is no
ait e .delete(e.Post, (post) => ({ filter: e.op(post.id, "=", e.uuid(postId)), })) .run(client); } export default async function handle( req: NextApiRequest, res: NextApiResponse, ) { const postId = req.q
{ "filepath": "examples/with-edgedb/pages/api/post/[id].ts", "language": "typescript", "file_size": 1040, "cut_index": 513, "middle_length": 229 }
ort { Field } from "payload/types"; import linkGroup from "./linkGroup"; import richText from "./richText"; import label from "./richText/label"; import largeBody from "./richText/largeBody"; export const hero: Field = { name: "hero", label: false, type: "group", fields: [ { type: "select", nam...
["h1", largeBody, label, "link"], leaves: [], }, }), linkGroup({ overrides: { maxRows: 2, }, }), { name: "media", type: "upload", relationTo: "media", required: true, admin: {
{ label: "Medium Impact", value: "mediumImpact", }, { label: "Low Impact", value: "lowImpact", }, ], }, richText({ admin: { elements:
{ "filepath": "examples/cms-payload/payload/fields/hero.ts", "language": "typescript", "file_size": 1123, "cut_index": 515, "middle_length": 229 }
lectionConfig } from "payload/types"; import { publishedOnly } from "../access/publishedOnly"; import { CallToAction } from "../blocks/CallToAction"; import { Content } from "../blocks/Content"; import { MediaBlock } from "../blocks/Media"; import { hero } from "../fields/hero"; import { slugField } from "../fields/slu...
nly, }, hooks: { afterChange: [regenerateStaticPage], }, fields: [ { name: "title", type: "text", required: true, }, { type: "tabs", tabs: [ { label: "Hero", fields: [hero],
["title", "slug", "updatedAt"], preview: (doc, { locale }) => { if (doc?.slug) { return `/${doc.slug}${locale ? `?locale=${locale}` : ""}`; } return ""; }, }, access: { read: publishedO
{ "filepath": "examples/cms-payload/payload/collections/Pages.ts", "language": "typescript", "file_size": 1321, "cut_index": 524, "middle_length": 229 }
ppearanceOptions = { primary: { label: "Primary Button", value: "primary", }, secondary: { label: "Secondary Button", value: "secondary", }, default: { label: "Default", value: "default", }, }; export type LinkAppearances = "primary" | "secondary" | "default"; type LinkType = (opti...
ame: "type", type: "radio", options: [ { label: "Internal link", value: "reference", }, { label: "Custom URL", value: "custom"
e, overrides = {}, } = {}) => { let linkResult: Field = { name: "link", type: "group", admin: { hideGutter: true, }, fields: [ { type: "row", fields: [ { n
{ "filepath": "examples/cms-payload/payload/fields/link.ts", "language": "typescript", "file_size": 3223, "cut_index": 614, "middle_length": 229 }
React, { ElementType, Fragment, Ref } from "react"; import { Video } from "./Video"; import { Image } from "./Image"; import { StaticImageData } from "next/image"; import { Media as MediaType } from "../../payload-types"; export type Props = { src?: StaticImageData; // for static media alt?: string; resource?: ...
{ const { className, resource, htmlElement = "div" } = props; const isVideo = typeof resource !== "string" && resource?.mimeType?.includes("video"); const Tag = (htmlElement as ElementType) || Fragment; return ( <Tag {...(htmlEleme
: string; videoClassName?: string; htmlElement?: ElementType | null; onClick?: () => void; onLoad?: () => void; ref?: Ref<null | HTMLImageElement | HTMLVideoElement>; }; export const Media: React.FC<Props> = (props) =>
{ "filepath": "examples/cms-payload/components/Media/index.tsx", "language": "tsx", "file_size": 1223, "cut_index": 518, "middle_length": 229 }
imple object check. * @param item * @returns {boolean} */ export function isObject(item: unknown): boolean { return Boolean(item && typeof item === "object" && !Array.isArray(item)); } /** * Deep merge two objects. * @param target * @param ...sources */ export default function deepMerge<T extends object, R ex...
in target)) { Object.assign(output, { [key]: source[key] }); } else { output[key] = deepMerge(target[key], source[key]); } } else { Object.assign(output, { [key]: source[key] }); } }); } retu
ce[key])) { // @ts-ignore if (!(key
{ "filepath": "examples/cms-payload/payload/utilities/deepMerge.ts", "language": "typescript", "file_size": 841, "cut_index": 520, "middle_length": 52 }
lient"; import React, { useState } from "react"; import { PayloadMeUser, PayloadAdminBarProps, PayloadAdminBar, } from "payload-admin-bar"; import { Gutter } from "../Gutter"; import classes from "./index.module.scss"; const Title: React.FC = () => <span>Payload + Vercel</span>; export const AdminBar: React.FC...
LIC_APP_URL} onAuthChange={setUser} className={classes.payloadAdminBar} classNames={{ user: classes.user, logo: classes.logo, controls: classes.controls, }} logo={<Title
ses.adminBar, user && classes.show] .filter(Boolean) .join(" ")} > <Gutter className={classes.blockContainer}> <PayloadAdminBar {...adminBarProps} cmsURL={process.env.NEXT_PUB
{ "filepath": "examples/cms-payload/components/AdminBar/index.tsx", "language": "tsx", "file_size": 1216, "cut_index": 518, "middle_length": 229 }
" height="29" viewBox="0 0 123 29" fill="none" xmlns="http://www.w3.org/2000/svg" > <path d="M34.7441 22.9997H37.2741V16.3297H41.5981C44.7031 16.3297 46.9801 14.9037 46.9801 11.4537C46.9801 8.00369 44.7031 6.55469 41.5981 6.55469H34.7441V22.9997ZM37.2741 14.1447V8.73969H41.4831...
982 20.3317V14.9497C57.5982 11.9137 55.6662 10.9017 53.2512 10.9017C49.6632 10.9017 48.1912 12.6727 48.0762 14.9267H50.3762C50.4912 13.3627 51.1122 12.7187 53.1592 12.7187C54.8842 12.7187 55.3902 13.4317 55.3902 14.2827C55.3902 15.4327 54.2632 15.6627 52.4
54.6082 22.5627 55.3672 21.3437H55.4132C55.5512 22.6777 56.1492 23.1147 57.2762 23.1147C57.6442 23.1147 58.0352 23.0687 58.4262 22.9767V21.5967C58.2882 21.6197 58.2192 21.6197 58.1502 21.6197C57.7132 21.6197 57.5982 21.1827 57.5
{ "filepath": "examples/cms-payload/components/Logo/index.tsx", "language": "tsx", "file_size": 4887, "cut_index": 614, "middle_length": 229 }
RichTextElement, RichTextField, RichTextLeaf, } from "payload/dist/fields/config/types"; import deepMerge from "../../utilities/deepMerge"; import elements from "./elements"; import leaves from "./leaves"; type RichText = ( overrides?: Partial<RichTextField>, additions?: { elements?: RichTextElement[]; ...
{ name: "richText", type: "richText", required: true, admin: { elements: [...elements, ...(additions.elements || [])], leaves: [...leaves, ...(additions.leaves || [])], }, }, overrides || {}, );
chTextField>>(
{ "filepath": "examples/cms-payload/payload/fields/richText/index.ts", "language": "typescript", "file_size": 818, "cut_index": 522, "middle_length": 14 }
import React, { useEffect, useRef } from "react"; import classes from "./index.module.scss"; import { Props } from ".."; export const Video: React.FC<Props> = (props) => { const { videoClassName, resource, onClick } = props; const videoRef = useRef<HTMLVideoElement>(null); useEffect(() => { const { current...
} className={[classes.video, videoClassName].filter(Boolean).join(" ")} onClick={onClick} ref={videoRef} > <source src={`${process.env.NEXT_PUBLIC_API_URL}/media/${filename}`} /> </video> ); } return nul
') }); } }, []); if (resource && typeof resource !== "string") { const { filename } = resource; return ( <video playsInline autoPlay muted loop controls={false
{ "filepath": "examples/cms-payload/components/Media/Video/index.tsx", "language": "tsx", "file_size": 1003, "cut_index": 512, "middle_length": 229 }
apeHTML from "escape-html"; import { Text } from "slate"; import { Label } from "../Label"; import { LargeBody } from "../LargeBody"; // eslint-disable-next-line no-use-before-define type Children = Leaf[]; type Leaf = { type: string; value?: { url: string; alt: string; }; children: Children; url?: ...
if (node.italic) { text = <em key={i}>{text}</em>; } if (node.underline) { text = ( <span style={{ textDecoration: "underline" }} key={i}> {text} </span> ); } if (node.s
angerouslySetInnerHTML={{ __html: escapeHTML(node.text) }} /> ); if (node.bold) { text = <strong key={i}>{text}</strong>; } if (node.code) { text = <code key={i}>{text}</code>; }
{ "filepath": "examples/cms-payload/components/RichText/serialize.tsx", "language": "tsx", "file_size": 2581, "cut_index": 563, "middle_length": 229 }
lient"; import React, { useContext, createContext } from "react"; import { VerticalPadding, VerticalPaddingOptions } from "../VerticalPadding"; import classes from "./index.module.scss"; type BackgroundColorField = "white" | "black"; export const BackgroundColorContext = createContext<BackgroundColorField>("white"...
ngTop, paddingBottom, color = "white", } = props; return ( <div id={id} className={[classes[color], className].filter(Boolean).join(" ")} > <BackgroundColorContext.Provider value={color}> <VerticalPadding top=
paddingBottom?: VerticalPaddingOptions; className?: string; children?: React.ReactNode; id?: string; }; export const BackgroundColor: React.FC<Props> = (props) => { const { id, className, children, paddi
{ "filepath": "examples/cms-payload/components/BackgroundColor/index.tsx", "language": "tsx", "file_size": 1148, "cut_index": 518, "middle_length": 229 }
ct"; import { Page } from "../../payload-types"; import { toKebabCase } from "../../utilities/toKebabCase"; import { BackgroundColor } from "../BackgroundColor"; import { VerticalPaddingOptions } from "../VerticalPadding"; import { CallToActionBlock } from "./CallToAction"; import { ContentBlock } from "./Content"; imp...
onst { blockName, blockType } = block; if (blockType && blockType in blockComponents) { const Block = blockComponents[blockType]; const backgroundColor = block[`${blockType}BackgroundColor`]; const prevBlock =
out"]; }> = (props) => { const { blocks } = props; const hasBlocks = blocks && Array.isArray(blocks) && blocks.length > 0; if (hasBlocks) { return ( <Fragment> {blocks.map((block, index) => { c
{ "filepath": "examples/cms-payload/components/Blocks/index.tsx", "language": "tsx", "file_size": 2293, "cut_index": 563, "middle_length": 229 }
om "@faceless-ui/css-grid"; import { Page } from "../../../payload-types"; import RichText from "../../RichText"; import { Gutter } from "../../Gutter"; import { CMSLink } from "../../Link"; import classes from "./index.module.scss"; type Props = Extract<Page["layout"][0], { blockType: "content" }>; const Columns: Re...
hird": { let col1Cols = 6; let col2Cols = 6; if (layout === "twoThirdsOneThird") { col1Cols = 8; col2Cols = 4; } return ( <React.Fragment> <Cell cols={col1Cols} colsM={4}> <RichT
ontent={columnOne.richText} /> {columnOne.enableLink && ( <CMSLink className={classes.link} {...columnOne.link} /> )} </Cell> ); } case "halfAndHalf": case "twoThirdsOneT
{ "filepath": "examples/cms-payload/components/Blocks/Content/index.tsx", "language": "tsx", "file_size": 2565, "cut_index": 563, "middle_length": 229 }
mport { Cell, Grid } from "@faceless-ui/css-grid"; import React from "react"; import { Page } from "../../../payload-types"; import { Gutter } from "../../Gutter"; import { CMSLink } from "../../Link"; import { Media } from "../../Media"; import RichText from "../../RichText"; import classes from "./index.module.scss"...
ap(({ link }, i) => { return ( <li key={i}> <CMSLink {...link} /> </li> ); })} </ul> )} {typeof media === "object" && <Media resource={media
}> <RichText content={richText} /> </Cell> </Grid> <div className={classes.media}> {Array.isArray(links) && links.length > 0 && ( <ul className={classes.links}> {links.m
{ "filepath": "examples/cms-payload/components/Hero/HighImpact/index.tsx", "language": "tsx", "file_size": 1039, "cut_index": 513, "middle_length": 229 }
from "next/link"; import React, { ElementType } from "react"; import { useBackgroundColor } from "../BackgroundColor"; import { Chevron } from "../icons/Chevron"; import classes from "./index.module.scss"; export type Props = { label?: string; appearance?: "default" | "primary" | "secondary"; el?: "button" | "li...
rops, classes[`appearance--${appearance}`], classes[`${appearance}--${backgroundColor}`], classes.button, ] .filter(Boolean) .join(" "); const content = ( <div className={classes.content}> <Chevron /> <span classNam
ance, className: classNameFromProps, }) => { const backgroundColor = useBackgroundColor(); const newTabProps = newTab ? { target: "_blank", rel: "noopener noreferrer" } : {}; const className = [ classNameFromP
{ "filepath": "examples/cms-payload/components/Button/index.tsx", "language": "tsx", "file_size": 1360, "cut_index": 524, "middle_length": 229 }
piResponse } from "next"; const regenerate = async (req: NextApiRequest, res: NextApiResponse) => { if (req.query.secret !== process.env.NEXT_PRIVATE_REGENERATION_SECRET) { console.error("Error regenerating: Invalid Token."); return res .status(401) .json({ message: "Error regenerating: Invalid ...
return res.json({ regenerated: true }); } catch (err) { console.error("Error regenerating: Cannot parse url."); return res.status(500).send("Error regenerating: Cannot parse url."); } } return res.status(400).send("No path to r
rl; await res.revalidate(pathToRegenerate);
{ "filepath": "examples/cms-payload/pages/api/regenerate.ts", "language": "typescript", "file_size": 899, "cut_index": 547, "middle_length": 52 }
; import NextImage, { StaticImageData } from "next/image"; import classes from "./index.module.scss"; import cssVariables from "../../../cssVariables"; import { Props } from ".."; const { breakpoints } = cssVariables; export const Image: React.FC<Props> = (props) => { const { imgClassName, onClick, onLo...
h, height: fullHeight, filename: fullFilename, alt: altFromResource, } = resource; width = fullWidth; height = fullHeight; alt = altFromResource; let filename = fullFilename; src = `https://${process.env.NEXT_PU
umber | undefined; let height: number | undefined; let alt = altFromProps; let src: StaticImageData | string = srcFromProps || ""; if (!src && resource && typeof resource !== "string") { const { width: fullWidt
{ "filepath": "examples/cms-payload/components/Media/Image/index.tsx", "language": "tsx", "file_size": 1849, "cut_index": 537, "middle_length": 229 }
/Media"; import { Media as MediaType } from "../../../payload-types"; import RichText from "../../RichText"; import classes from "./index.module.scss"; export const MediaBlock: React.FC<{ media?: MediaType; caption?: string; position?: "default" | "fullscreen"; mediaBackgroundColor?: string; }> = (props) => { ...
"default" && ( <Gutter> <div> <Media resource={media} /> </div> </Gutter> )} {caption && ( <Gutter className={classes.caption}> <RichText content={caption} /> </Gutter>
dia} /> </div> )} {position ===
{ "filepath": "examples/cms-payload/components/Blocks/MediaBlock/index.tsx", "language": "tsx", "file_size": 941, "cut_index": 606, "middle_length": 52 }
from "next/link"; import React from "react"; import { Page } from "../../payload-types"; import { Button } from "../Button"; type CMSLinkType = { type?: "custom" | "reference"; url?: string; newTab?: boolean; reference?: { value: string | Page; relationTo: "pages"; }; label?: string; appearance?:...
const newTabProps = newTab ? { target: "_blank", rel: "noopener noreferrer" } : {}; if (type === "custom") { return ( <a href={url} {...newTabProps} className={className}> {label && label} {children && c
appearance, children, className, }) => { const href = type === "reference" && typeof reference?.value === "object" && reference.value.slug ? `/${reference.value.slug}` : url; if (!appearance) {
{ "filepath": "examples/cms-payload/components/Link/index.tsx", "language": "tsx", "file_size": 1392, "cut_index": 524, "middle_length": 229 }
{ Cell, Grid } from "@faceless-ui/css-grid"; import React from "react"; import { Page } from "../../../payload-types"; import { Gutter } from "../../Gutter"; import { CMSLink } from "../../Link"; import { Media } from "../../Media"; import RichText from "../../RichText"; import classes from "./index.module.scss"; ex...
turn ( <li key={i}> <CMSLink className={classes.link} {...link} /> </li> ); })} </ul> )} </Cell> <Cell cols={7} colsM={4}>
={5} colsM={4}> <RichText className={classes.richText} content={richText} /> {Array.isArray(links) && ( <ul className={classes.links}> {links.map(({ link }, i) => { re
{ "filepath": "examples/cms-payload/components/Hero/MediumImpact/index.tsx", "language": "tsx", "file_size": 1166, "cut_index": 518, "middle_length": 229 }
lient"; import { GridProvider } from "@faceless-ui/css-grid"; import { ModalContainer, ModalProvider } from "@faceless-ui/modal"; import React from "react"; import { Header } from "../Header"; import { MainMenu } from "../../payload-types"; import cssVariables from "../../cssVariables"; import "../../css/app.scss"; t...
: "48px", xl: "72px", }} cols={{ s: 4, m: 4, l: 12, xl: 12, }} > <ModalProvider transTime={0} zIndex="var(--modal-z-index)"> <Header mainMenu={mainMenu} />
breakpoints={{ s: cssVariables.breakpoints.s, m: cssVariables.breakpoints.m, l: cssVariables.breakpoints.l, }} colGap={{ s: "24px", m: "48px", l
{ "filepath": "examples/cms-payload/components/Layout/index.tsx", "language": "tsx", "file_size": 1152, "cut_index": 518, "middle_length": 229 }
alToggler } from "@faceless-ui/modal"; import Link from "next/link"; import React from "react"; import { MainMenu } from "../../payload-types"; import { Gutter } from "../Gutter"; import { MenuIcon } from "../icons/Menu"; import { CMSLink } from "../Link"; import { Logo } from "../Logo"; import { MobileMenuModal, slug ...
slug={menuModalSlug} className={classes.mobileMenuToggler} > <MenuIcon /> </ModalToggler> </Gutter> </header> ); }; export const Header: React.FC<{ mainMenu: MainMenu }> = ({ mainMenu }) => { const navItem
ps> = ({ children }) => { return ( <header className={classes.header}> <Gutter className={classes.wrap}> <Link href="/"> <Logo /> </Link> {children} <ModalToggler
{ "filepath": "examples/cms-payload/components/Header/index.tsx", "language": "tsx", "file_size": 1318, "cut_index": 524, "middle_length": 229 }
{ notFound } from "next/navigation"; import { getPayloadClient } from "../../../payload/payloadClient"; import Blocks from "../../../components/Blocks"; import { Hero } from "../../../components/Hero"; import { AdminBar } from "../../../components/AdminBar"; import { Metadata } from "next"; export async function gene...
dminBar adminBarProps={{ collection: "pages", id: page.id }} /> <Hero {...page.hero} /> <Blocks blocks={page.layout} /> </> ); }; export async function generateStaticParams() { const payload = await getPayloadClient(); const pages =
st pages = await payload.find({ collection: "pages", where: { slug: { equals: slug || "home", }, }, }); const page = pages.docs[0]; if (!page) return notFound(); return ( <> <A
{ "filepath": "examples/cms-payload/app/(site)/[slug]/page.tsx", "language": "tsx", "file_size": 1146, "cut_index": 518, "middle_length": 229 }
hallowEqual } from "react-redux"; const useClock = () => { return useSelector( (state) => ({ lastUpdate: state.lastUpdate, light: state.light, }), shallowEqual, ); }; const formatTime = (time) => { // cut off except hh:mm:ss return new Date(time).toJSON().slice(11, 19); }; const Clock...
lor: #82fa58; font: 50px menlo, monaco, monospace; background-color: #000; } .light { background-color: #999; } `}</style> </div> ); }; export default Cl
15px; display: inline-block; co
{ "filepath": "examples/with-apollo-and-redux/components/Clock.js", "language": "javascript", "file_size": 848, "cut_index": 535, "middle_length": 52 }
Nav from "./Nav"; import PropTypes from "prop-types"; const Layout = ({ children }) => ( <main> <Nav /> {children} <style jsx global>{` * { font-family: Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", ...
ay: inline-flex; padding: 5px 7px; margin-right: 1px; } button:active { background-color: #1b9db7; transition: background-color 0.3s; } button:focus { outline: none; } hr {
height: 24px; } article { margin: 0 auto; max-width: 650px; } button { align-items: center; background-color: #22bad9; border: 0; color: white; displ
{ "filepath": "examples/with-apollo-and-redux/components/Layout.js", "language": "javascript", "file_size": 1217, "cut_index": 518, "middle_length": 229 }
lo/client"; import ErrorMessage from "./ErrorMessage"; import PostUpvoter from "./PostUpvoter"; export const ALL_POSTS_QUERY = gql` query allPosts($first: Int!, $skip: Int!) { allPosts(orderBy: { createdAt: desc }, first: $first, skip: $skip) { id title votes url createdAt } ...
etching // more data notifyOnNetworkStatusChange: true, }, ); const loadingMorePosts = networkStatus === NetworkStatus.fetchMore; const { allPosts, _allPostsMeta } = data; const loadMorePosts = () => { fetchMore({ varia
Status } = useQuery( ALL_POSTS_QUERY, { variables: allPostsQueryVars, // Setting this value to true will make the component rerender when // the "networkStatus" changes, so we are able to know if it is f
{ "filepath": "examples/with-apollo-and-redux/components/PostList.js", "language": "javascript", "file_size": 2713, "cut_index": 563, "middle_length": 229 }
} from "@apollo/client"; const CREATE_POST_MUTATION = gql` mutation createPost($title: String!, $url: String!) { createPost(title: $title, url: $url) { id title votes url createdAt } } `; const Submit = () => { const [createPost, { loading }] = useMutation(CREATE_POST_MUTA...
ngPosts = []) { const newPostRef = cache.writeFragment({ data: createPost, fragment: gql` fragment NewPost on allPosts { id type }
const url = formData.get("url"); form.reset(); createPost({ variables: { title, url }, update: (cache, { data: { createPost } }) => { cache.modify({ fields: { allPosts(existi
{ "filepath": "examples/with-apollo-and-redux/components/Submit.js", "language": "javascript", "file_size": 1756, "cut_index": 537, "middle_length": 229 }
redux"; import { initializeStore } from "../lib/redux"; import useInterval from "../lib/useInterval"; import Layout from "../components/Layout"; import Clock from "../components/Clock"; import Counter from "../components/Counter"; const ReduxPage = () => { // Tick the time every second const dispatch = useDispatch...
Props() { const reduxStore = initializeStore(); const { dispatch } = reduxStore; dispatch({ type: "TICK", light: true, lastUpdate: Date.now(), }); return { props: { initialReduxState: reduxStore.getState(), }, reva
</Layout> ); }; export async function getStatic
{ "filepath": "examples/with-apollo-and-redux/pages/redux.js", "language": "javascript", "file_size": 900, "cut_index": 547, "middle_length": 52 }
eturn ( <nav> <div className="left"> <Link href="/">Blog</Link> <Link href="/drafts">Drafts</Link> </div> <div className="right"> <Link href="/create">+ New draft</Link> </div> <style jsx>{` nav { display: flex; padding: 2rem; ...
em; } .right { margin-left: auto; } .right a { border: 2px solid black; padding: 0.5rem 1rem; border-radius: 3px; } `}</style> </nav> ); }; export default Header
} a + a { margin-left: 1r
{ "filepath": "examples/with-edgedb/components/Header.tsx", "language": "tsx", "file_size": 916, "cut_index": 606, "middle_length": 52 }
import React, { ReactNode } from "react"; import Header from "./Header"; type Props = { children: ReactNode; }; const Layout: React.FC<Props> = (props) => ( <div style={{ paddingBottom: "30px" }}> <Header /> <div className="layout">{props.children}</div> <style jsx global>{` html { box-s...
} input, textarea, button { font-size: 16px; } button { cursor: pointer; } `}</style> <style jsx>{` .layout { padding: 0 2rem; } `}</style> </div> ); export default L
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; background: rgba(0, 0, 0, 0);
{ "filepath": "examples/with-edgedb/components/Layout.tsx", "language": "tsx", "file_size": 1004, "cut_index": 512, "middle_length": 229 }
out from "../components/Layout"; import Router from "next/router"; import Link from "next/link"; const Draft: React.FC = () => { const [title, setTitle] = useState(""); const [content, setContent] = useState(""); const [authorName, setAuthorName] = useState(""); const submitData = async (e: React.SyntheticEve...
<div> <form onSubmit={submitData}> <h1>Create draft</h1> <input autoFocus onChange={(e) => setTitle(e.target.value)} placeholder="Title" type="text" value={title}
t-Type": "application/json" }, body: JSON.stringify(body), }); await result.json(); await Router.push("/drafts"); } catch (error) { console.error(error); } }; return ( <Layout>
{ "filepath": "examples/with-edgedb/pages/create.tsx", "language": "tsx", "file_size": 2459, "cut_index": 563, "middle_length": 229 }
from "react"; import "../styles/global.css"; import { GetServerSideProps } from "next"; import Layout from "../components/Layout"; import Post from "../components/Post"; import { PostProps } from "./blog/[id]"; import { client, e } from "../client"; type Props = { feed: PostProps[]; }; const Blog: React.FC<Props> ...
jsx>{` .post { transition: box-shadow 0s ease-in; border: 2px solid #eee; border-radius: 8px; } .post:hover { box-shadow: 0px 2px 8px #ccc; border: 2px solid #727272; }
<div key={post.id} className="post"> <Post post={post} /> </div> )) ) : ( <p>No blog posts yet.</p> )} </main> </div> <style
{ "filepath": "examples/with-edgedb/pages/index.tsx", "language": "tsx", "file_size": 1472, "cut_index": 524, "middle_length": 229 }
pe } from "next"; import { Streamdown } from "streamdown"; import Layout from "../../components/Layout"; import Router from "next/router"; import { client, e } from "../../client"; async function update( id: string, data: { title?: string; content?: string }, ): Promise<void> { await fetch(`/api/post/${id}`, { ...
r.push("/"); } const Post: React.FC<PostProps> = (props) => { const [patch, setPatch] = useState<{ title?: string; content?: string; }>({ title: props.title, content: props.content || undefined, }); if (props.publishedISO) { r
await fetch(`/api/publish/${id}`, { method: "PUT", }); await Router.push(`/blog/${id}`); } async function destroy(id: string): Promise<void> { await fetch(`/api/post/${id}`, { method: "DELETE", }); await Route
{ "filepath": "examples/with-edgedb/pages/blog/[id].tsx", "language": "tsx", "file_size": 4159, "cut_index": 614, "middle_length": 229 }
react"; import { createStore, applyMiddleware } from "redux"; import { composeWithDevTools } from "redux-devtools-extension"; let store; const initialState = { lastUpdate: 0, light: false, count: 0, }; const reducer = (state = initialState, action) => { switch (action.type) { case "TICK": return { ...
}; function initStore(preloadedState = initialState) { return createStore( reducer, preloadedState, composeWithDevTools(applyMiddleware()), ); } export const initializeStore = (preloadedState) => { let _store = store ?? initStore(preloa
case "DECREMENT": return { ...state, count: state.count - 1, }; case "RESET": return { ...state, count: initialState.count, }; default: return state; }
{ "filepath": "examples/with-apollo-and-redux/lib/redux.js", "language": "javascript", "file_size": 1683, "cut_index": 537, "middle_length": 229 }
mport { useSelector, useDispatch } from "react-redux"; const useCounter = () => { const count = useSelector((state) => state.count); const dispatch = useDispatch(); const increment = () => dispatch({ type: "INCREMENT", }); const decrement = () => dispatch({ type: "DECREMENT", }); ...
return ( <div> <h1> Count: <span>{count}</span> </h1> <button onClick={increment}>+1</button> <button onClick={decrement}>-1</button> <button onClick={reset}>Reset</button> </div> ); }; export default Counte
eCounter();
{ "filepath": "examples/with-apollo-and-redux/components/Counter.js", "language": "javascript", "file_size": 786, "cut_index": 513, "middle_length": 14 }
, useMutation } from "@apollo/client"; import PropTypes from "prop-types"; const VOTE_POST = gql` mutation votePost($id: String!) { votePost(id: $id) { __typename id votes } } `; const PostUpvoter = ({ votes, id }) => { const [votePost] = useMutation(VOTE_POST); const upvotePost = (...
d #e4e4e4; color: #000; } button:active { background-color: transparent; } button:before { align-self: center; border-color: transparent transparent #000000 transparent; bord
votes: votes + 1, }, }, }); }; return ( <button onClick={() => upvotePost()}> {votes} <style jsx>{` button { background-color: transparent; border: 1px soli
{ "filepath": "examples/with-apollo-and-redux/components/PostUpvoter.js", "language": "javascript", "file_size": 1339, "cut_index": 524, "middle_length": 229 }
{ client, e } from "./client"; const posts = [ { title: "Join the EdgeDB Discord", content: "Just follow [this link](https://edgedb.com/p/discord).", published: true, authorName: "Bobby", }, { title: "Follow EdgeDB on Twitter", content: "We're [@edgedatabase](https://www.twitter.com/edge...
shed: false, authorName: "Polly", }, ]; async function main() { console.log(`Start seeding...`); for (const post of posts) { const newPost = await e .insert(e.Post, { ...post, published: post.published ? e.std.datetime
edb/edgedb).", published: true, authorName: "Polly", }, { title: "Try the EdgeDB query builder for TypeScript", content: "The docs are [here](https://www.edgedb.com/docs/clients/01_js/index).", publi
{ "filepath": "examples/with-edgedb/seed.ts", "language": "typescript", "file_size": 1207, "cut_index": 518, "middle_length": 229 }
k"; import { PostProps } from "../pages/blog/[id]"; const Post: React.FC<{ post: PostProps }> = ({ post }) => { return ( <Link href={`/blog/${post.id}`}> <div> <h2>{post.title}</h2> <small>By {post.authorName}</small> <br /> <br /> <Streamdown mode="static" className...
padding-bottom: 4px; } small { color: #888; } .streamdown, .streamdown > p { margin: 0px; } `}</style> </div> </Link> ); }; export default Po
} h2 { margin: 0px;
{ "filepath": "examples/with-edgedb/components/Post.tsx", "language": "tsx", "file_size": 918, "cut_index": 606, "middle_length": 52 }
; import { Cell, Grid } from "@faceless-ui/css-grid"; import { Page } from "../../../payload-types"; import { BackgroundColor } from "../../BackgroundColor"; import { Gutter } from "../../Gutter"; import { CMSLink } from "../../Link"; import RichText from "../../RichText"; import classes from "./index.module.scss"; t...
lToActionBlock: React.FC<Props> = ({ ctaBackgroundColor, links, richText, }) => { const oppositeBackgroundColor = ctaBackgroundColor === "white" ? "black" : "white"; return ( <Gutter> <BackgroundColor color={oppositeBackgroundColor
reference: { value: string | Page; relationTo: "pages"; }; url: string; label: string; }; id?: string; }[]; id?: string; blockName?: string; blockType: "cta"; }; export const Cal
{ "filepath": "examples/cms-payload/components/Blocks/CallToAction/index.tsx", "language": "tsx", "file_size": 1757, "cut_index": 537, "middle_length": 229 }
t Link from "next/link"; import { useRouter } from "next/router"; export default function Nav() { const { pathname } = useRouter(); return ( <header> <Link href="/" className={pathname === "/" ? "is-active" : ""}> Home </Link> <Link href="/apollo" className={pathname ...
header { margin-bottom: 25px; } a { font-size: 14px; margin-right: 15px; text-decoration: none; } .is-active { text-decoration: underline; } `}</style> </h
jsx>{`
{ "filepath": "examples/with-apollo-and-redux/components/Nav.js", "language": "javascript", "file_size": 801, "cut_index": 517, "middle_length": 14 }
from "react"; import { GetServerSideProps } from "next"; import Layout from "../components/Layout"; import Post from "../components/Post"; import { PostProps } from "./blog/[id]"; import { client, e } from "../client"; type Props = { drafts: PostProps[]; }; const Drafts: React.FC<Props> = (props) => { return ( ...
se-in; border: 2px solid #eee; border-radius: 8px; } .post:hover { box-shadow: 0px 2px 8px #ccc; border: 2px solid #727272; } .post + .post { margin-top: 1rem; }
ssName="post"> <Post post={post} /> </div> )) : "No drafts yet."} </main> </div> <style jsx>{` .post { transition: box-shadow 0s ea
{ "filepath": "examples/with-edgedb/pages/drafts.tsx", "language": "tsx", "file_size": 1404, "cut_index": 524, "middle_length": 229 }
Dispatch } from "react-redux"; import { initializeStore } from "../lib/redux"; import { initializeApollo } from "../lib/apollo"; import useInterval from "../lib/useInterval"; import Layout from "../components/Layout"; import Clock from "../components/Clock"; import Counter from "../components/Counter"; import Submit fr...
<hr /> {/* Apollo */} <Submit /> <PostList /> </Layout> ); }; export async function getStaticProps() { const reduxStore = initializeStore(); const apolloClient = initializeApollo(); const { dispatch } = reduxStore; disp
ch = useDispatch(); useInterval(() => { dispatch({ type: "TICK", light: true, lastUpdate: Date.now(), }); }, 1000); return ( <Layout> {/* Redux */} <Clock /> <Counter />
{ "filepath": "examples/with-apollo-and-redux/pages/index.js", "language": "javascript", "file_size": 1372, "cut_index": 524, "middle_length": 229 }
"react"; import Bridge from "../components/Icons/Bridge"; import Logo from "../components/Icons/Logo"; import Modal from "../components/Modal"; import getResults from "../utils/cachedImages"; import type { ImageProps } from "../utils/types"; import { useLastViewedPhoto } from "../utils/useLastViewedPhoto"; const Home...
wedPhoto && !photoId) { lastViewedPhotoRef.current.scrollIntoView({ block: "center" }); setLastViewedPhoto(null); } }, [photoId, lastViewedPhoto, setLastViewedPhoto]); return ( <> <Head> <title>Next.js Conf 2022 Photo
const lastViewedPhotoRef = useRef<HTMLAnchorElement>(null); useEffect(() => { // This effect keeps track of the last viewed photo in the modal to keep the index page in sync when the user navigates back if (lastVie
{ "filepath": "examples/with-vercel-blob/pages/index.tsx", "language": "tsx", "file_size": 5556, "cut_index": 716, "middle_length": 229 }
_TOOL_URL } from "../lib/constants"; export default function Intro() { return ( <section className="flex-col md:flex-row flex items-center md:justify-between mt-16 mb-16 md:mb-12"> <h1 className="text-6xl md:text-8xl font-bold tracking-tighter leading-tight md:pr-8"> Blog. </h1> <h4 cla...
> Next.js </a>{" "} and{" "} <a href={EXAMPLE_TOOL_URL} className="underline hover:text-success duration-200 transition-colors" > {EXAMPLE_TOOL_NAME} </a> .
ver:text-success duration-200 transition-colors"
{ "filepath": "examples/cms-umbraco/components/intro.tsx", "language": "tsx", "file_size": 883, "cut_index": 547, "middle_length": 52 }
Head from "next/head"; import { EXAMPLE_TOOL_NAME } from "../lib/constants"; export default function Meta() { return ( <Head> <link rel="apple-touch-icon" sizes="180x180" href="/favicon/apple-touch-icon.png" /> <link rel="icon" type="image/png" s...
icon.ico" /> <meta name="msapplication-TileColor" content="#000000" /> <meta name="msapplication-config" content="/favicon/browserconfig.xml" /> <meta name="theme-color" content="#000" /> <link rel="alternate" type="application/rss+
<link rel="manifest" href="/favicon/site.webmanifest" /> <link rel="mask-icon" href="/favicon/safari-pinned-tab.svg" color="#000000" /> <link rel="shortcut icon" href="/favicon/fav
{ "filepath": "examples/cms-umbraco/components/meta.tsx", "language": "tsx", "file_size": 1191, "cut_index": 518, "middle_length": 229 }
from "next/head"; import Container from "../components/container"; import MoreStories from "../components/more-stories"; import HeroPost from "../components/hero-post"; import Intro from "../components/intro"; import Layout from "../components/layout"; import { EXAMPLE_TOOL_NAME } from "../lib/constants"; import Post f...
er> <Intro /> {heroPost && ( <HeroPost title={heroPost.title} coverImage={heroPost.coverImage} date={heroPost.date} author={heroPost.author} slug={heroPos
t heroPost = posts[0]; const morePosts = posts.slice(1); return ( <> <Layout preview={preview}> <Head> <title>Next.js Blog Example with {EXAMPLE_TOOL_NAME}</title> </Head> <Contain
{ "filepath": "examples/cms-umbraco/pages/index.tsx", "language": "tsx", "file_size": 1425, "cut_index": 524, "middle_length": 229 }
orPage from "next/error"; import Container from "../../components/container"; import MoreStories from "../../components/more-stories"; import PostBody from "../../components/post-body"; import Header from "../../components/header"; import PostHeader from "../../components/post-header"; import SectionSeparator from "../...
preview: boolean; }; export default function PostDetails({ post, morePosts, preview }: Props) { const router = useRouter(); if (!router.isFallback && !post?.slug) { return <ErrorPage statusCode={404} />; } return ( <Layout preview={prev
st-title"; import Head from "next/head"; import { EXAMPLE_TOOL_NAME } from "../../lib/constants"; import Tags from "../../components/tags"; import Post from "../../types/post"; type Props = { post: Post; morePosts: Post[];
{ "filepath": "examples/cms-umbraco/pages/posts/[slug].tsx", "language": "tsx", "file_size": 2641, "cut_index": 563, "middle_length": 229 }
ponents/Link"; import { MUX_HOME_PAGE_URL } from "../constants"; export default function Layout({ children, }: Readonly<{ children: React.ReactNode }>) { return ( <> <header className="mb-8"> <h1 className="font-bold text-4xl lg:text-5xl mb-2"> Welcome to Mux + Next.js </h1> ...
ist-disc pl-8 mb-4"> <li>A video on demand service like Youtube or Netflix</li> <li> A platform that supports user uploaded videos like TikTok or Instagram </li> <li>Video into your custom CMS</li> </ul>
rel="noopener noreferrer" > Mux </Link>{" "} provides APIs for developers working with video. <br /> This example is useful if you want to build: </p> <ul className="l
{ "filepath": "examples/with-mux-video/app/(upload)/layout.tsx", "language": "tsx", "file_size": 1702, "cut_index": 537, "middle_length": 229 }
seEffect, useState } from "react"; import { Status } from "./types"; import Link from "@/app/_components/Link"; const Oops = () => ( <p> This is awkward. Let's <Link href="/">refresh</Link> and try again. </p> ); type Props = { initialStatus: Status; checkAssetStatus: () => Promise<Status>; }; export def...
className="animate-pulse">Asset is preparing...</p>; case "errored": return ( <div> <p className="mb-4">Asset encountered an error.</p> {Array.isArray(errors) && ( <ul className="mb-4"> {erro
poll = async () => setStatus(await checkAssetStatus()); const interval = setInterval(poll, 1000); return () => clearInterval(interval); }, [checkAssetStatus]); switch (status) { case "preparing": return <p
{ "filepath": "examples/with-mux-video/app/(upload)/asset/[assetId]/AssetStatusPoll.tsx", "language": "tsx", "file_size": 1658, "cut_index": 537, "middle_length": 229 }
e: "light", colors: { text: "#191924", background: "#fff", primary: "#06f", border: "#ebece9", modes: { dark: { text: "#ededee", background: "#1a202c", primary: "#06f", border: "#2a2a3c", }, }, }, breakpoints: ["640px", "768px", "1024px", "1280px...
old: 700, }, space: { 0: "0", 1: "0.25rem", 2: "0.5rem", 3: "0.75rem", 4: "1rem", 5: "1.25rem", 6: "1.5rem", 7: "1.75rem", 8: "2rem", 9: "2.25rem", 10: "2.5rem", }, sizes: { 0: "0", 1: "0.25rem",
i-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace", }, fontSizes: { sm: "0.875rem", md: "1rem", lg: "3rem", }, fontWeights: { normal: 400, medium: 500, b
{ "filepath": "examples/with-reflexjs/src/theme.ts", "language": "typescript", "file_size": 3885, "cut_index": 614, "middle_length": 229 }
sel from "react-multi-carousel"; import { ResponsiveType } from "react-multi-carousel/lib/types"; import "react-multi-carousel/lib/styles.css"; import Image from "next/image"; const BreakpointSlides: ResponsiveType = { desktop: { breakpoint: { max: 3000, min: 1024 }, items: 3, }, tablet: { breakpoint...
height={475} /> <Image alt="Musgo" src="/cameronsmith.jpg" priority layout="responsive" width={700} height={475} /> <Image alt="Valley" src="/ganapathykumar.jpg"
e={BreakpointSlides} ssr infinite itemClass="carousel-item" autoPlay > <Image alt="Gundam" src="/brucetang.jpg" priority layout="responsive" width={700}
{ "filepath": "examples/with-react-multi-carousel/pages/index.tsx", "language": "tsx", "file_size": 1409, "cut_index": 524, "middle_length": 229 }
_URL } from "@/app/constants"; import Script from "next/script"; type Params = { playbackId: string; }; const title = "View this video created with Mux + Next.js"; export const generateMetadata = async (props: { params: Promise<Params> }) => { const params = await props.params; return { title, descript...
h=1200&height=600&fit_mode=pad`, width: 1200, height: 600, }, ], }, }; }; const Code = ({ children }: { children: React.ReactNode }) => ( <code className="text-mono text-sm bg-red-500/10 px-1 py-0.5 rounded-sm">
width: 1200, height: 630, }, ], }, twitter: { title, card: "summary_large_image", images: [ { url: `https://image.mux.com/${params.playbackId}/thumbnail.png?widt
{ "filepath": "examples/with-mux-video/app/v/[playbackId]/page.tsx", "language": "tsx", "file_size": 3478, "cut_index": 614, "middle_length": 229 }
Container from "./container"; import cn from "classnames"; import { EXAMPLE_PATH } from "../lib/constants"; type Props = { preview?: boolean; }; export default function Alert({ preview }: Props) { return ( <div className={cn("border-b", { "bg-accent-7 border-accent-7 text-white": preview, ...
to exit preview mode. </> ) : ( <> The source code for this blog is{" "} <a href={`https://github.com/vercel/next.js/tree/canary/examples/${EXAMPLE_PATH}`}
age preview.{" "} <a href="/api/exit-preview" className="underline hover:text-cyan duration-200 transition-colors" > Click here </a>{" "}
{ "filepath": "examples/cms-umbraco/components/alert.tsx", "language": "tsx", "file_size": 1250, "cut_index": 518, "middle_length": 229 }
Container from "./container"; import { EXAMPLE_PATH } from "../lib/constants"; export default function Footer() { return ( <footer className="bg-accent-1 border-t border-accent-2"> <Container> <div className="py-28 flex flex-col lg:flex-row items-center"> <h3 className="text-4xl lg:text-...
er border-black text-white font-bold py-3 px-12 lg:px-8 duration-200 transition-colors mb-6 lg:mb-0" > Read Documentation </a> <a href={`https://github.com/vercel/next.js/tree/canary/examples/
flex flex-col lg:flex-row justify-center items-center lg:pl-4 lg:w-1/2"> <a href="https://nextjs.org/docs/basic-features/pages" className="mx-3 bg-black hover:bg-white hover:text-black bord
{ "filepath": "examples/cms-umbraco/components/footer.tsx", "language": "tsx", "file_size": 1210, "cut_index": 518, "middle_length": 229 }
e"; import PostTitle from "./post-title"; import Author from "../types/author"; import Picture from "../types/picture"; type Props = { title: string; coverImage: Picture; date: string; author: Author; }; export default function PostHeader({ title, coverImage, date, author }: Props) { return ( <> <...
v> <div className="max-w-2xl mx-auto"> <div className="block md:hidden mb-6"> <Avatar author={author} /> </div> <div className="mb-6 text-lg"> <Date dateString={date} /> </div> </div> </>
title={title} coverImage={coverImage} /> </di
{ "filepath": "examples/cms-umbraco/components/post-header.tsx", "language": "tsx", "file_size": 921, "cut_index": 606, "middle_length": 52 }
mport Avatar from "./avatar"; import Date from "./date"; import CoverImage from "./cover-image"; import Link from "next/link"; import Author from "../types/author"; import Picture from "../types/picture"; type Props = { title: string; coverImage: Picture; date: string; excerpt: string; author: Author; slug...
{title} </Link> </h3> <div className="text-lg mb-4"> <Date dateString={date} /> </div> <div className="text-lg leading-relaxed mb-4" dangerouslySetInnerHTML={{ __html: excerpt }} /> <Av
e && ( <CoverImage title={title} coverImage={coverImage} slug={slug} /> )} </div> <h3 className="text-3xl mb-3 leading-snug"> <Link href={`/posts${slug}`} className="hover:underline">
{ "filepath": "examples/cms-umbraco/components/post-preview.tsx", "language": "tsx", "file_size": 1040, "cut_index": 513, "middle_length": 229 }
from "next"; import { DM_Sans, JetBrains_Mono } from "next/font/google"; import Image from "next/image"; import { MUX_HOME_PAGE_URL } from "./constants"; import MuxLogo from "./mux.svg"; import "./globals.css"; const dmSans = DM_Sans({ subsets: ["latin"], variable: "--sans" }); const jetBrainsMono = JetBrains_Mono({...
{ title, description, card: "summary_large_image", }, }; export default function RootLayout({ children, }: Readonly<{ children: React.ReactNode; }>) { return ( <html lang="en"> <body className={`min-h-screen flex flex
ataBase: process.env.VERCEL_URL ? new URL(`https://${process.env.VERCEL_URL}`) : new URL(`http://localhost:${process.env.PORT || 3000}`), title, description, openGraph: { title, description, }, twitter:
{ "filepath": "examples/with-mux-video/app/layout.tsx", "language": "tsx", "file_size": 1551, "cut_index": 537, "middle_length": 229 }
-node"; import MuxUploader from "./MuxUploader"; import { redirect } from "next/navigation"; // reads MUX_TOKEN_ID and MUX_TOKEN_SECRET from your environment const mux = new Mux(); const createUpload = async () => { const upload = await mux.video.uploads.create({ new_asset_settings: { playback_policy: ["p...
adId); if (upload.asset_id) { redirect(`/asset/${upload.asset_id}`); } else { // while onSuccess is a strong indicator that Mux has received the file // and created the asset, this isn't a guarantee. // In production, you mi
Seconds = () => new Promise((resolve) => setTimeout(resolve, 3000)); const redirectToAsset = async (uploadId: string) => { let attempts = 0; while (attempts <= 10) { const upload = await mux.video.uploads.retrieve(uplo
{ "filepath": "examples/with-mux-video/app/(upload)/page.tsx", "language": "tsx", "file_size": 1729, "cut_index": 537, "middle_length": 229 }
../types/postAndMorePosts"; const UMBRACO_SERVER_URL = process.env.UMBRACO_SERVER_URL; const UMBRACO_DELIVERY_API_KEY = process.env.UMBRACO_DELIVERY_API_KEY; const UMBRACO_API_URL = `${UMBRACO_SERVER_URL}/umbraco/delivery/api/v2/content`; const performFetch = async (url: string, options: RequestInit) => { const res...
": startItem, "Api-Key": UMBRACO_DELIVERY_API_KEY, Preview: preview ? "true" : "false", }, }); const fetchMultiple = async ( query: string, startItem: string, preview: boolean, ) => await performFetch(`${UMBRACO_API_URL}/?${query
} return await response.json(); }; const fetchSingle = async (slug: string, startItem: string, preview: boolean) => await performFetch(`${UMBRACO_API_URL}/item/${slug}`, { method: "GET", headers: { "Start-Item
{ "filepath": "examples/cms-umbraco/lib/api.ts", "language": "typescript", "file_size": 3303, "cut_index": 614, "middle_length": 229 }
r from "./avatar"; import Date from "./date"; import CoverImage from "./cover-image"; import Link from "next/link"; import Author from "../types/author"; import Picture from "../types/picture"; type Props = { title: string; coverImage: Picture; date: string; excerpt: string; author: Author; slug: string; }...
mb-4 text-4xl lg:text-6xl leading-tight"> <Link href={`/posts${slug}`} className="hover:underline" dangerouslySetInnerHTML={{ __html: title }} ></Link> </h3> <div classNa
&& ( <CoverImage title={title} coverImage={coverImage} slug={slug} /> )} </div> <div className="md:grid md:grid-cols-2 md:gap-x-16 lg:gap-x-8 mb-20 md:mb-28"> <div> <h3 className="
{ "filepath": "examples/cms-umbraco/components/hero-post.tsx", "language": "tsx", "file_size": 1347, "cut_index": 524, "middle_length": 229 }
unction Form() { const [message, setMessage] = useState(""); const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); analytics.track("Form Submitted", { message, }); setMessage(""); }; return ( <> <form onSubmit={handleSubmit}> <label> <span>Message...
{ display: block; margin-bottom: 12px; } textarea { min-width: 300px; min-height: 120px; } button { margin-top: 12px; display: block; } `}</style>
</form> <style jsx>{` label span
{ "filepath": "examples/with-segment-analytics-pages-router/components/form.tsx", "language": "tsx", "file_size": 928, "cut_index": 606, "middle_length": 52 }
lient"; import { useState } from "react"; import { createEditor, Descendant } from "slate"; import { Slate, Editable, withReact } from "slate-react"; const initialValue: Descendant[] = [ { children: [ { text: "This is editable plain text, just like a <textarea>!" }, ], }, ]; async function saveEdit...
ange = editor.operations.some( (op) => "set_selection" !== op.type, ); if (isAstChange) { // You might want to debounce the following call! const responseData = await saveEditorState(value); console.l
default function IndexPage() { const [editor] = useState(() => withReact(createEditor())); return ( <Slate editor={editor} initialValue={initialValue} onChange={async (value) => { const isAstCh
{ "filepath": "examples/with-slate/app/page.tsx", "language": "tsx", "file_size": 1159, "cut_index": 518, "middle_length": 229 }
-node"; import { redirect } from "next/navigation"; import { Status } from "./types"; import AssetStatusPoll from "./AssetStatusPoll"; // reads MUX_TOKEN_ID and MUX_TOKEN_SECRET from your environment const mux = new Mux(); const checkAssetStatus = async (assetId: string): Promise<Status> => { const asset = await mu...
rect(`/v/${playbackId.id}`); } } } return { status: asset.status, errors: asset.errors, }; }; // For better performance, we could cache and use a Mux webhook to invalidate the cache. // https://docs.mux.com/guides/listen-for-webho
e if (asset.status === "ready") { const playbackIds = asset.playback_ids; if (Array.isArray(playbackIds)) { const playbackId = playbackIds.find((id) => id.policy === "public"); if (playbackId) { redi
{ "filepath": "examples/with-mux-video/app/(upload)/asset/[assetId]/page.tsx", "language": "tsx", "file_size": 1570, "cut_index": 537, "middle_length": 229 }
ow, Card, Button } from "react-bootstrap"; export default function Home() { return ( <Container className="md-container"> <Head> <title>ReactJS with react-bootstrap</title> <link rel="icon" href="/favicon-32x32.png" /> </Head> <Container> <h1> Welcome to <a hre...
tures and API. </Card.Text> <Button variant="primary" href="https://nextjs.org/docs"> More &rarr; </Button> </Card.Body> </Card> <Card className="sml-ca
ntent-md-between"> <Card className="sml-card"> <Card.Body> <Card.Title>Documentation</Card.Title> <Card.Text> Find in-depth information about Next.js fea
{ "filepath": "examples/with-react-bootstrap/pages/index.jsx", "language": "jsx", "file_size": 3031, "cut_index": 563, "middle_length": 229 }
{ useEffect } from "react"; import { useFrame } from "@react-three/fiber"; import { useAnimations, useGLTF } from "@react-three/drei"; export default function Bird({ speed, factor, url, ...props }) { const { nodes, animations } = useGLTF(url); const { ref, mixer } = useAnimations(animations); useEffect( ()...
odes.Object_0.morphTargetDictionary} morphTargetInfluences={nodes.Object_0.morphTargetInfluences} rotation={[1.5707964611537577, 0, 0]} > <bufferGeometry attach="geometry" {...nodes.Object_0.geometry} /> <mes
2) * Math.cos((delta * factor) / 2) * 1.5; mixer.update(delta * speed); }); return ( <group ref={ref}> <scene name="Scene" {...props}> <mesh name="Object_0" morphTargetDictionary={n
{ "filepath": "examples/with-three-js/app/_components/Bird.js", "language": "javascript", "file_size": 1194, "cut_index": 518, "middle_length": 229 }
; import { Suspense, useMemo } from "react"; import { Canvas } from "@react-three/fiber"; import { OrbitControls } from "@react-three/drei"; import Bird from "../_components/Bird"; export default function BirdsPage() { const birds = useMemo( () => new Array(10).fill(undefined).map((_, index) => { ...
+ Math.random() : bird === "flamingo" ? 0.25 + Math.random() : 1 + Math.random() - 0.5; return { key: index, position: [x, y, z], rotation: [0, x > 0 ? Math.PI : 0, 0],
= ["stork", "parrot", "flamingo"][ Math.round(Math.random() * 2) ]; const speed = bird === "stork" ? 0.5 : bird === "flamingo" ? 2 : 5; const factor = bird === "stork" ? 0.5
{ "filepath": "examples/with-three-js/app/birds/page.tsx", "language": "tsx", "file_size": 1433, "cut_index": 524, "middle_length": 229 }
from "next/headers"; /** * Especially important if using Fluid compute: Don't put this client in a * global variable. Always create a new client within each function when using * it. */ export async function createClient() { const cookieStore = await cookies(); return createServerClient( process.env.NEXT...
rEach(({ name, value, options }) => cookieStore.set(name, value, options), ); } catch { // The `setAll` method was called from a Server Component. // This can be ignored if you have proxy refreshi
ToSet) { try { cookiesToSet.fo
{ "filepath": "examples/with-supabase/lib/supabase/server.ts", "language": "typescript", "file_size": 969, "cut_index": 582, "middle_length": 52 }
"; import { BUILDER_CONFIG } from "./constants"; builder.init(BUILDER_CONFIG.apiKey); Builder.isStatic = true; export function getAllPostsWithSlug() { return builder.getAll(BUILDER_CONFIG.postsModel, { options: { noTargeting: true }, apiKey: BUILDER_CONFIG.apiKey, }); } export function getDraftPost(id) {...
ncludeRefs: true, preview: BUILDER_CONFIG.postsModel, staleCacheSeconds: preview ? 1 : 200, apiKey: BUILDER_CONFIG.apiKey, ...(preview && { includeUnpublished: true }), options: { noTargeting: true, }, query, }); if (
hen((res) => res.json()) .then((res) => res || null); } export async function searchPosts(query, preview, limit = 20, offset = 0) { let posts = await builder.getAll(BUILDER_CONFIG.postsModel, { limit, offset, i
{ "filepath": "examples/cms-builder-io/lib/api.js", "language": "javascript", "file_size": 2304, "cut_index": 563, "middle_length": 229 }
js", "./pages/**/*.js"], theme: { extend: { fontFamily: { sans: '-apple-system, "Helvetica Neue", "Segoe UI", Roboto, Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"', }, colors: { "accent-1": "#FAFAFA", "accent...
: 1.2, }, fontSize: { "5xl": "2.5rem", "6xl": "2.75rem", "7xl": "4.5rem", "8xl": "6.25rem", }, boxShadow: { small: "0 5px 10px rgba(0, 0, 0, 0.12)", medium: "0 8px 30px rgba(0, 0, 0, 0
"-.04em", }, lineHeight: { tight
{ "filepath": "examples/cms-builder-io/tailwind.config.js", "language": "javascript", "file_size": 945, "cut_index": 606, "middle_length": 52 }
Container from "./container"; import { EXAMPLE_PATH } from "../lib/constants"; export default function Footer() { return ( <footer className="bg-accent-1 border-t border-accent-2"> <Container> <div className="py-28 flex flex-col lg:flex-row items-center"> <h3 className="text-4xl lg:text-...
er border-black text-white font-bold py-3 px-12 lg:px-8 duration-200 transition-colors mb-6 lg:mb-0" > Read Documentation </a> <a href={`https://github.com/vercel/next.js/tree/canary/examples/
flex flex-col lg:flex-row justify-center items-center lg:pl-4 lg:w-1/2"> <a href="https://nextjs.org/docs/basic-features/pages" className="mx-3 bg-black hover:bg-white hover:text-black bord
{ "filepath": "examples/cms-builder-io/components/footer.js", "language": "javascript", "file_size": 1210, "cut_index": 518, "middle_length": 229 }
URL } from "../lib/constants"; export default function Intro() { return ( <section className="flex-col md:flex-row flex items-center md:justify-between mt-16 mb-16 md:mb-12"> <h1 className="text-6xl md:text-8xl font-bold tracking-tighter leading-tight md:pr-8"> Blog. </h1> <h4 className...
Next.js </a>{" "} and{" "} <a href={CMS_URL} className="underline hover:text-success duration-200 transition-colors" > {CMS_NAME} </a> . </h4> </section> )
xt-success duration-200 transition-colors" >
{ "filepath": "examples/cms-builder-io/components/intro.js", "language": "javascript", "file_size": 847, "cut_index": 535, "middle_length": 52 }
from "next/head"; import { CMS_NAME, HOME_OG_IMAGE_URL } from "../lib/constants"; export default function Meta() { return ( <Head> <link rel="apple-touch-icon" sizes="180x180" href="/favicon/apple-touch-icon.png" /> <link rel="icon" type="image/png" ...
/favicon.ico" /> <meta name="msapplication-TileColor" content="#000000" /> <meta name="msapplication-config" content="/favicon/browserconfig.xml" /> <meta name="theme-color" content="#000" /> <link rel="alternate" type="application/
/> <link rel="manifest" href="/favicon/site.webmanifest" /> <link rel="mask-icon" href="/favicon/safari-pinned-tab.svg" color="#000000" /> <link rel="shortcut icon" href="/favicon
{ "filepath": "examples/cms-builder-io/components/meta.js", "language": "javascript", "file_size": 1255, "cut_index": 524, "middle_length": 229 }
iner from "@/components/container"; import MoreStories from "@/components/more-stories"; import HeroPost from "@/components/hero-post"; import Intro from "@/components/intro"; import Layout from "@/components/layout"; import { getAllPostsForHome } from "@/lib/api"; import Head from "next/head"; import { CMS_NAME } from...
le} coverImage={heroPost.data.image} date={heroPost.lastUpdated} author={heroPost.data.author.value?.data} slug={heroPost.data.slug} excerpt={heroPost.data.intro} />
iew}> <Head> <title>{`Next.js Blog Example with ${CMS_NAME}`}</title> </Head> <Container> <Intro /> {heroPost && ( <HeroPost title={heroPost.data.tit
{ "filepath": "examples/cms-builder-io/pages/index.js", "language": "javascript", "file_size": 1330, "cut_index": 524, "middle_length": 229 }
orPage from "next/error"; import Container from "@/components/container"; import PostBody from "@/components/post-body"; import MoreStories from "@/components/more-stories"; import Header from "@/components/header"; import PostHeader from "@/components/post-header"; import SectionSeparator from "@/components/section-se...
e; export default function Post({ post, morePosts, preview }) { const router = useRouter(); const isLive = !Builder.isEditing && !Builder.isPreviewing && !preview; if (!router.isFallback && !post && isLive) { return <ErrorPage statusCode={404} /
t/head"; import { CMS_NAME, BUILDER_CONFIG } from "@/lib/constants"; import { Builder, builder, BuilderContent } from "@builder.io/react"; import "@builder.io/widgets"; builder.init(BUILDER_CONFIG.apiKey); Builder.isStatic = tru
{ "filepath": "examples/cms-builder-io/pages/posts/[slug].js", "language": "javascript", "file_size": 2994, "cut_index": 563, "middle_length": 229 }
userbase from "userbase-js"; function LoginModal({ toggle, modalType, setUser }) { const [username, setUsername] = useState(""); const [password, setPassword] = useState(""); const [loading, setLoading] = useState(); const [error, setError] = useState(); useEffect(() => { setError(""); }, [modalType]...
setLoading(true); try { const user = await userbase.signIn({ username, password, rememberMe: "none", }); setUser(user); setLoading(false); toggle(false); } catch (e) { setLoading(false);
: "none", }); setUser(user); setLoading(false); toggle(false); } catch (e) { setLoading(false); setError(e.message); } } async function handleLogIn(e) { e.preventDefault();
{ "filepath": "examples/with-userbase/components/modal/index.js", "language": "javascript", "file_size": 3002, "cut_index": 563, "middle_length": 229 }
from "next/image"; import { useRouter } from "next/router"; import useKeypress from "react-use-keypress"; import type { ImageProps } from "../utils/types"; import { useLastViewedPhoto } from "../utils/useLastViewedPhoto"; import SharedModal from "./SharedModal"; export default function Carousel({ index, currentPh...
me="fixed inset-0 flex items-center justify-center"> <button className="absolute inset-0 z-30 cursor-default bg-black backdrop-blur-2xl" onClick={closeModal} > <Image src={currentPhoto.blurDataUrl} cl
to(currentPhoto.id); router.push("/", undefined, { shallow: true }); } function changePhotoId(newVal: number) { return newVal; } useKeypress("Escape", () => { closeModal(); }); return ( <div classNa
{ "filepath": "examples/with-vercel-blob/components/Carousel.tsx", "language": "tsx", "file_size": 1357, "cut_index": 524, "middle_length": 229 }
MotionConfig } from "framer-motion"; import Image from "next/image"; import { useState } from "react"; import { useSwipeable } from "react-swipeable"; import { variants } from "../utils/animationVariants"; import downloadPhoto from "../utils/downloadPhoto"; import { range } from "../utils/range"; import type { ImagePr...
s = useSwipeable({ onSwipedLeft: () => { if (index < images?.length - 1) { changePhotoId(index + 1); } }, onSwipedRight: () => { if (index > 0) { changePhotoId(index - 1); } }, trackMouse: true,
urrentPhoto, direction, }: SharedModalProps) { const [loaded, setLoaded] = useState(false); let filteredImages = images?.filter((img: ImageProps) => range(index - 15, index + 15).includes(img.id), ); const handler
{ "filepath": "examples/with-vercel-blob/components/SharedModal.tsx", "language": "tsx", "file_size": 8240, "cut_index": 716, "middle_length": 229 }
xmlns="http://www.w3.org/2000/svg" > <title id="conf-logo-title-header"> Next.js Conf logo using a newly designed Next.js logo. </title> <path d="M108.262 25.9669C108.032 25.9669 107.836 25.8884 107.672 25.7313C107.508 25.5742 107.427 25.3841 107.43 25.1588C107.427 24.9397 107.508 ...
114.907 24.5552 114.699 24.9045C114.488 25.2538 114.196 25.5205 113.822 25.7086C113.449 25.8946 113.013 25.9897 112.517 25.9897C112.064 25.9897 111.657 25.9091 111.295 25.752C110.933 25.5949 110.646 25.3593 110.435 25.0492C110.222 24.7392 110.118 24.3527
.444 108.975 25.566C108.896 25.69 108.796 25.7871 108.671 25.8574C108.547 25.9297 108.411 25.9669 108.262 25.9669Z" fill="currentColor" ></path> <path d="M113.624 18.3689H115.016V23.654C115.014 24.1398
{ "filepath": "examples/with-vercel-blob/components/Icons/Logo.tsx", "language": "tsx", "file_size": 7397, "cut_index": 716, "middle_length": 229 }
Container from "./container"; import cn from "classnames"; import { EXAMPLE_PATH } from "../lib/constants"; export default function Alert({ preview }) { return ( <div className={cn("border-b", { "bg-accent-7 border-accent-7 text-white": preview, "bg-accent-1 border-accent-2": !preview, ...
</> ) : ( <> The source code for this blog is{" "} <a href={`https://github.com/vercel/next.js/tree/canary/examples/${EXAMPLE_PATH}`} className="underline hover:text-succe
href="/api/exit-preview" className="underline hover:text-cyan duration-200 transition-colors" > Click here </a>{" "} to exit preview mode.
{ "filepath": "examples/cms-builder-io/components/alert.js", "language": "javascript", "file_size": 1206, "cut_index": 518, "middle_length": 229 }
mport Link from "next/link"; import Avatar from "../components/avatar"; import DateComponent from "../components/date"; import CoverImage from "../components/cover-image"; export default function HeroPost({ title, coverImage, date, excerpt, author, slug, }) { return ( <section> <div className="...
md:mb-0 text-lg"> <DateComponent dateString={date} /> </div> </div> <div> <p className="text-lg leading-relaxed mb-4">{excerpt}</p> {author && <Avatar name={author.name} picture={author.image} />}
> <h3 className="mb-4 text-4xl lg:text-6xl leading-tight"> <Link href={`/posts/${slug}`} className="hover:underline"> {title} </Link> </h3> <div className="mb-4
{ "filepath": "examples/cms-builder-io/components/hero-post.js", "language": "javascript", "file_size": 1047, "cut_index": 513, "middle_length": 229 }
mport Link from "next/link"; import Avatar from "../components/avatar"; import DateComponent from "../components/date"; import CoverImage from "./cover-image"; export default function PostPreview({ title, coverImage, date, excerpt, author, slug, }) { return ( <div className="mx-3"> <div classNa...
</h3> <div className="text-lg mb-4"> <DateComponent dateString={date} /> </div> <p className="text-lg leading-relaxed mb-4">{excerpt}</p> {author && <Avatar name={author.name} picture={author.image} />} </div> ); }
er:underline"> {title} </Link>
{ "filepath": "examples/cms-builder-io/components/post-preview.js", "language": "javascript", "file_size": 821, "cut_index": 513, "middle_length": 52 }
, done, toggleComplete, deleteTodo }) { return ( <li className="my-4"> <div className="flex items-center"> <span className={done ? "text-gray-500" : ""}>{name}</span> <button type="button" className="mx-4 p-1 rounded bg-purple-400 text-white font-bold" onClick={...
li> ); } function TodoForm() { const [newTodo, setNewTodo] = useState(""); const [todos, setTodos] = useState([]); const [disabled, setDisabled] = useState(); useEffect(() => { async function openDatabase() { try { console.log
onClick={(e) => { e.preventDefault(); deleteTodo(); }} className=" p-1 bg-red-500 text-white rounded font-bold" > delete </button> </div> </
{ "filepath": "examples/with-userbase/components/todo-form/index.js", "language": "javascript", "file_size": 3315, "cut_index": 614, "middle_length": 229 }
headlessui/react"; import { motion } from "framer-motion"; import { useRouter } from "next/router"; import { useRef, useState } from "react"; import useKeypress from "react-use-keypress"; import type { ImageProps } from "../utils/types"; import SharedModal from "./SharedModal"; export default function Modal({ images...
Id(newVal: number) { if (newVal > index) { setDirection(1); } else { setDirection(-1); } setCurIndex(newVal); router.push( { query: { photoId: newVal }, }, `/p/${newVal}`, { shallow: true },
oId); const [direction, setDirection] = useState(0); const [curIndex, setCurIndex] = useState(index); function handleClose() { router.push("/", undefined, { shallow: true }); onClose(); } function changePhoto
{ "filepath": "examples/with-vercel-blob/components/Modal.tsx", "language": "tsx", "file_size": 1905, "cut_index": 537, "middle_length": 229 }
ns="http://www.w3.org/2000/svg" > <title id="conf-city-title"> Line drawing of the Golden Gate Bridge in San Francisco. </title> <path d="M372.5 299.5L616.5 335" stroke="currentColor" /> <path d="M370 16.5C429.833 101.833 562.9 284 616.5 330" stroke="currentColor" ...
tColor" /> <path d="M332 234L329 240L328 241V245H327V251H326.5V261.5L325.5 262V289.5" stroke="currentColor" /> <path d="M-0.5 158.5L27 171.5L43.5 190L48.5 202L85 218.5L95.5 246.5C98.1667 254.333 103.7 270.6 104.5 2
4 33.3333 355 33.5L356.5 34.5L358 36L358.5 38L358 70L357.5 70.5L354 72L350.5 73.5H330L322.5 73M329.5 34.5L324.5 38L323.5 40.5L322.5 43.5V73" stroke="currentColor" /> <path d="M321 315V397H356.5" stroke="curren
{ "filepath": "examples/with-vercel-blob/components/Icons/Bridge.tsx", "language": "tsx", "file_size": 6792, "cut_index": 716, "middle_length": 229 }
rt DateComponent from "../components/date"; import CoverImage from "../components/cover-image"; import PostTitle from "../components/post-title"; export default function PostHeader({ title, coverImage, date, author }) { return ( <> <PostTitle>{title}</PostTitle> <div className="hidden md:block md:mb-...
> <div className="block md:hidden mb-6"> {author && <Avatar name={author.name} picture={author.image} />} </div> <div className="mb-6 text-lg"> <DateComponent dateString={date} /> </div> </div>
</div> <div className="max-w-2xl mx-auto"
{ "filepath": "examples/cms-builder-io/components/post-header.js", "language": "javascript", "file_size": 878, "cut_index": 559, "middle_length": 52 }
State } from "react"; import LoginModal from "../modal"; import userbase from "userbase-js"; export default function Nav({ user, setUser }) { const [open, setOpen] = useState(); const [modalType, setModalType] = useState(); function openModal(type) { setOpen(true); setModalType(type); } async func...
> Log In </button> </li> <li> <button className="btn-yellow mx-2" onClick={() => openModal("signUp")} > Sign Up
<ul className="flex justify-end items-center p-8"> {!user ? ( <> <li> <button className="font-bold mx-2" onClick={() => openModal("logIn")}
{ "filepath": "examples/with-userbase/components/nav/index.js", "language": "javascript", "file_size": 1465, "cut_index": 524, "middle_length": 229 }