Skip to content

Commit

Permalink
Contentful Envs (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanwiemer authored Dec 8, 2023
1 parent 1f87151 commit 55ebaa1
Show file tree
Hide file tree
Showing 8 changed files with 155 additions and 149 deletions.
6 changes: 4 additions & 2 deletions .env.local.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
SITE_URL=
CONTENTFUL_SPACE_ID=
CONTENTFUL_PREVIEW_SECRET=
CONTENTFUL_REVALIDATE_SECRET=
CONTENTFUL_ACCESS_TOKEN=
CONTENTFUL_PREVIEW_ACCESS_TOKEN=
CONTENTFUL_PREVIEW_SECRET=
CONTENTFUL_REVALIDATE_SECRET=
CONTENTFUL_ENVIRONMENT=
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
},
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
Expand Down
3 changes: 1 addition & 2 deletions app/api/revalidate/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export async function POST(request: NextRequest) {
}

// Revalidate the cache for all of the data pulled from Contentful in lib/api.ts
revalidateTag('posts')

revalidateTag('contentfulData')
return NextResponse.json({ revalidated: true, now: Date.now() })
}
2 changes: 2 additions & 0 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import './globals.css'
import { Inter } from 'next/font/google'
import { Analytics } from '@vercel/analytics/react'
import { SpeedInsights } from '@vercel/speed-insights/next'
import Footer from '../components/footer'
import Menu from '../components/menu'
import { ThemeProvider } from '@/components/theme-provider'
Expand Down Expand Up @@ -43,6 +44,7 @@ export default async function RootLayout({
<Footer />
</ThemeProvider>
<Analytics />
<SpeedInsights />
</body>
</html>
)
Expand Down
4 changes: 2 additions & 2 deletions lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const PAGE_GRAPHQL_FIELDS = `

async function fetchGraphQL(query: string, preview = false): Promise<any> {
return fetch(
`https://graphql.contentful.com/content/v1/spaces/${process.env.CONTENTFUL_SPACE_ID}`,
`https://graphql.contentful.com/content/v1/spaces/${process.env.CONTENTFUL_SPACE_ID}/environments/${process.env.CONTENTFUL_ENVIRONMENT}`,
{
method: 'POST',
headers: {
Expand All @@ -88,7 +88,7 @@ async function fetchGraphQL(query: string, preview = false): Promise<any> {
}`,
},
body: JSON.stringify({ query }),
next: { tags: ['posts'] },
next: { tags: ['contentfulData'] },
}
).then((response) => response.json())
}
Expand Down
6 changes: 5 additions & 1 deletion next-sitemap.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ module.exports = {
generateIndexSitemap: false,
generateRobotsTxt: true,
robotsTxtOptions: {
policies: process.env.STAGE === 'true' ? stagePolicies : prodPolicies,
policies:
process.env.CONTENTFUL_ENVIRONMENT === 'stage' ||
process.env.CONTENTFUL_ENVIRONMENT === 'dev'
? stagePolicies
: prodPolicies,
},
}
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "rw",
"description": "Ryan Wiemer's online portfolio",
"license": "UNLICENSED",
"version": "3.0.1",
"version": "3.0.2",
"author": "Ryan Wiemer <[email protected]>",
"keywords": [
"rw"
Expand All @@ -28,13 +28,14 @@
"@types/react-dom": "^18.2.17",
"@uidotdev/usehooks": "^2.4.1",
"@vercel/analytics": "^1.1.1",
"@vercel/speed-insights": "^1.0.0",
"autoprefixer": "10.4.16",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"date-fns": "2.30.0",
"framer-motion": "^10.16.12",
"framer-motion": "^10.16.15",
"lucide-react": "^0.294.0",
"next": "13.5.6",
"next": "14.0.4",
"next-sitemap": "^4.2.3",
"next-themes": "^0.2.1",
"plaiceholder": "^3.0.0",
Expand All @@ -48,12 +49,12 @@
"tailwindcss": "^3.3.6",
"tailwindcss-animate": "^1.0.7",
"tailwindcss-inner-border": "^0.2.0",
"typescript": "^5.1.6"
"typescript": "^5.3.3"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^6.13.2",
"eslint": "^8.55.0",
"eslint-config-next": "^14.0.3",
"eslint-config-next": "^14.0.4",
"eslint-config-prettier": "^9.1.0",
"prettier": "^3.1.0"
}
Expand Down
Loading

0 comments on commit 55ebaa1

Please sign in to comment.