Skip to content

Commit

Permalink
Fix: broken TypeScript in WordPress example. (#39402)
Browse files Browse the repository at this point in the history
* chore: add typescript and update deps

* style: add tsconfig

* chore: add g.avatar.com domain

* fix: images domain api url to match with hostname

* style: convert files to typescript

* refactor(Avatar): const name for readable purpose

* refactor: change regex to extract www from url

* Update next-image domains.

* Update a few types.

* Update readme.

* typo

Co-authored-by: Chaiwat Trisuwan <chaiwattsw@gmail.com>
Co-authored-by: Lee Robinson <me@leerob.io>
Co-authored-by: Anthony Shew <anthony@inthezone.dev>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
  • Loading branch information
5 people committed Aug 8, 2022
1 parent 1cc6e47 commit 60c8e5c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions examples/cms-wordpress/README.md
@@ -1,6 +1,6 @@
# A statically generated blog example using Next.js and WordPress
# An Incremental Static Regeneration Blog Example Using Next.js and WordPress

This example showcases Next.js's [Static Generation](https://nextjs.org/docs/basic-features/pages) feature using [WordPress](https://wordpress.org) as the data source.
This example showcases Next.js's [Incremental Static Regeneration](https://nextjs.org/docs/basic-features/data-fetching/incremental-static-regeneration) feature using [WordPress](https://wordpress.org) as the data source.

## Demo

Expand Down
12 changes: 11 additions & 1 deletion examples/cms-wordpress/components/cover-image.tsx
Expand Up @@ -2,7 +2,17 @@ import cn from 'classnames'
import Image from 'next/image'
import Link from 'next/link'

export default function CoverImage({ title, coverImage, slug }) {
interface Props {
title: string
coverImage: {
node: {
sourceUrl: string
}
}
slug?: string
}

export default function CoverImage({ title, coverImage, slug }: Props) {
const image = (
<Image
width={2000}
Expand Down
2 changes: 1 addition & 1 deletion examples/cms-wordpress/lib/api.ts
@@ -1,6 +1,6 @@
const API_URL = process.env.WORDPRESS_API_URL

async function fetchAPI(query = '', { variables } = {}) {
async function fetchAPI(query = '', { variables }: Record<string, any> = {}) {
const headers = { 'Content-Type': 'application/json' }

if (process.env.WORDPRESS_AUTH_REFRESH_TOKEN) {
Expand Down
1 change: 1 addition & 0 deletions examples/cms-wordpress/next.config.js
Expand Up @@ -9,6 +9,7 @@ module.exports = {
images: {
domains: [
process.env.WORDPRESS_API_URL.match(/(?!(w+)\.)\w*(?:\w+\.)+\w+/)[0], // Valid WP Image domain.
'0.gravatar.com',
'1.gravatar.com',
'2.gravatar.com',
'secure.gravatar.com',
Expand Down

0 comments on commit 60c8e5c

Please sign in to comment.