Giter Club home page Giter Club logo

nextjs-starter-prismic-blog's Introduction

Prismic + Next.js Blog Starter

This sample blog is an excellent starting point to explore Next.js and Prismic. Get it up and running in minutes. Modify and adapt it to your liking; it's all yours!

ย 

Screenshots of the site seen on deskop and mobile browsers

ย 

๐Ÿš€ Quick Start

To start a new project using this starter, run the following commands in your terminal:

npx degit prismicio-community/nextjs-starter-prismic-blog your-project-name
cd your-project-name
npx @slicemachine/init@latest

The commands will do the following:

  1. Start a new Next.js project using this starter.
  2. Ask you to log in to Prismic or create an account.
  3. Create a new Prismic content repository with sample content.

When you're ready to start your project, run the following command:

npm run dev

Documentation

To learn how to work with your new project, see this starter's docs.

To learn more about working with Prismic, see the Prismic docs.

License

Copyright 2013-2023 Prismic <[email protected]> (https://prismic.io)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

nextjs-starter-prismic-blog's People

Contributors

a-trost avatar alexandervishnevsky avatar angeloashmore avatar dependabot[bot] avatar heyrows avatar hypervillain avatar levimykel avatar lihbr avatar pauprismic avatar phillysnow avatar pvpg avatar raulg avatar samlfair avatar srenault avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nextjs-starter-prismic-blog's Issues

Add Support for Next/Image

With Next.js 10 out, one of the biggest change is the introduction of Next/Image which does really cool things like auto serving images as webp and auto lazy loading images.

Since I started my blog I upgraded to Next.js 10 and adding was fairly simple and since mine was based off this project I'd be up for adding Next/Image to this project as well.

Update `prismicio/next` package to `0.1.0`

As of right now, going through the steps with this sample project doesn't properly set up Prismic Previews.

What needs to be done:

  1. Update prismicio/next package to 0.1.0
  2. Update the getStaticProps function on the main home page to this:
export async function getStaticProps({ previewData }) {
  const client = createClient({ previewData });

  let blogHome = null;
  try {
    blogHome = await client.getSingle('blog-home');
  } catch {
    // If we reach this line, it means a Blog Home document was not created
    // yet. We don't need to do anything here. We will render a component on
    // the page with a helpful setup message.
  }

  const posts = await client.getAllByType('post', {
    orderings: [{ field: 'my.post.date', direction: 'desc' }],
  });

  return {
    props: {
      blogHome,
      posts,
    },
  };
}

Everything should be fine from there.

I can take care of this after Wednesday if no one else can get to it before me.

Cannot run the project either way

Tried with Node v8 and v10

With node-dev:

โฏ npm run node-dev

> [email protected] node-dev /Users/emirotin/work/nextjs-blog
> nodemon server.js

[nodemon] 1.19.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node server.js`
/Users/emirotin/work/nextjs-blog/prismic-configuration.js:1
import Prismic from 'prismic-javascript'
       ^^^^^^^

SyntaxError: Unexpected identifier
    at Module._compile (internal/modules/cjs/loader.js:721:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:690:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/Users/emirotin/work/nextjs-blog/server.js:8:39)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
[nodemon] app crashed - waiting for file changes before starting...

with dev:

โฏ npm run dev

> [email protected] dev /Users/emirotin/work/nextjs-blog
> now dev

> UPDATE AVAILABLE The latest version of Now CLI is 15.8.7
> Run the `now update` command to update to the latest version
> Changelog: https://github.com/zeit/now-cli/releases/tag/15.8.7
> Now CLI 15.5.0 dev (beta) โ€” https://zeit.co/feedback/dev
> Setting up 1 Builder
[@now/next] Downloading user files...

> Error! build_utils_1.getNodeVersion is not a function
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev: `now dev`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

`previewData` is not returned by `getStaticProps` in `pages/index.tsx`

previewData is not returned by getStaticProps context in pages/index.tsx

export async function getStaticProps(context) {
  console.log(context);
  const client = createClient({ context });

  let blogHome = null;
  try {
    blogHome = await client.getSingle("blog-home");
  } catch {
    // If we reach this line, it means a Blog Home document was not created
    // yet. We don't need to do anything here. We will render a component on
    // the page with a helpful setup message.
  }

  const posts = await client.getAllByType("post", {
    orderings: [{ field: "my.post.date", direction: "desc" }],
  });

  return {
    props: {
      blogHome,
      posts,
    },
  };
}

export default Home;

404 Errors in fresh theme install

After following the Prismic + Next.js tutorial here, I found that when I opened the console there was a couple of error messages shown here:

Capture

There doesn't seem to be anything particularly wrong with the actual page, it just seems like something added quotes to the ends of the src for prismic.js. I was wondering if this is an issue on my end or if this was intentional from this template.

Tested in both Chrome and Edge on Windows.

prismic.min.js 404 not found

Encountered an issue where the address for the prismic.min.js file was generating a 404 locally and upon deployment. This results in styles not loading for index and blog single pages.

localhost/:11 GET http://localhost:3000/%22https://static.cdn.prismic.io/prismic.min.js?repo=project&new=true%22 404 (Not Found)

This is resolved by changing PrismicScript.js to remove the double quote characters from the src attribute:

src={`https://static.cdn.prismic.io/prismic.min.js?repo=${repoName}&new=true`}

CSS from reset and globals not loading

Hi.

When I run "npm run dev" everything looks good.

But when I deploy to Vercel. Some of the CSS does not load. Specifically:
image

If I run the commands locally:
npm run build
npm start
I am also missing the css from reset and globals.

Any idea how to solve this?
Also when I make a new post in Prismic. I don't see the change until I make a new deploy.

Thanks in advance.

frontClient in prismicHelpers?

I am not sure what the following line does?

if (!req && frontClient) return frontClient;

As frontClient is never assigned, am I missing something?

Update to Next.js 9.3

Would be really nice to see the new features like getStaticProps, getStaticPaths and getServerSideProps implemented in this example.

Error: An invalid API response was returned

I don't know why but anything I try on index.js (everything there regarding the client) breaks, await client.. does not work at all. I tried calling to the API myself and it worked fine, it only breaks in code. I didn't change anything from when I installed it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.