Skip to content

Commit

Permalink
bump versions add timer
Browse files Browse the repository at this point in the history
  • Loading branch information
jj committed Dec 13, 2021
1 parent 8797a38 commit 3fbbbeb
Show file tree
Hide file tree
Showing 9 changed files with 713 additions and 853 deletions.
1 change: 1 addition & 0 deletions appConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,6 @@ export const customNavigation: NavItem[] = [{ label: 'Contact', url: '/contact'

// Incremental Static Regenerations (ISR)
export const isr: boolean = true
export const revalidate: number = 10
export const maxNumberOfPosts: number = 20
export const maxNumberOfPages: number = 20
2 changes: 2 additions & 0 deletions lib/processEnv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export interface ProcessEnvProps {
customNavigation: NavItem[]
isr: {
enable: boolean
revalidate: number
maxNumberOfPosts: number
maxNumberOfPages: number
}
Expand Down Expand Up @@ -101,6 +102,7 @@ export const processEnv: ProcessEnvProps = {
customNavigation: reolveJSON(process.env.JAMIFY_CUSTOM_NAVIGATION, appConfig.customNavigation),
isr: {
enable: resolveBool(process.env.JAMIFY_NEXT_ISR, appConfig.isr),
revalidate: resolveNumber(process.env.JAMIFY_NEXT_ISR_REVALIDATE, appConfig.revalidate),
maxNumberOfPosts: resolveNumber(process.env.JAMIFY_NEXT_ISR_MAX_NUMBER_POSTS, appConfig.maxNumberOfPosts),
maxNumberOfPages: resolveNumber(process.env.JAMIFY_NEXT_ISR_MAX_NUMBER_PAGES, appConfig.maxNumberOfPages),
},
Expand Down
1 change: 0 additions & 1 deletion next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/// <reference types="next" />
/// <reference types="next/types/global" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
Expand Down
52 changes: 26 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,56 +39,56 @@
"postbuild": "next-sitemap"
},
"dependencies": {
"@tryghost/content-api": "^1.5.13",
"@tryghost/content-api": "^1.5.16",
"cheerio": "^1.0.0-rc.10",
"crypto-hash": "^2.0.0",
"crypto-hash": "^2.0.1",
"dayjs": "^1.10.7",
"disqus-react": "^1.1.2",
"email-validator": "^2.0.4",
"fs": "^0.0.1-security",
"lodash.throttle": "^4.1.1",
"next": "^12.0.1",
"nodemailer": "^6.7.0",
"probe-image-size": "^7.2.1",
"next": "^12.0.7",
"nodemailer": "^6.7.2",
"probe-image-size": "^7.2.2",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-is": "^17.0.2",
"refractor": "^3.3.1",
"rehype": "^11.0.0",
"rehype-react": "^6.2.1",
"rss": "^1.2.2",
"sanitize-html": "^2.5.2",
"sharp": "^0.29.2",
"sanitize-html": "^2.6.1",
"sharp": "^0.29.3",
"unist-util-visit": "^2.0.3"
},
"devDependencies": {
"@next/bundle-analyzer": "^12.0.1",
"@next/bundle-analyzer": "^12.0.7",
"@types/cheerio": "^0.22.30",
"@types/lodash": "^4.14.176",
"@types/node": "^16.11.6",
"@types/lodash": "^4.14.178",
"@types/node": "^16.11.12",
"@types/nodemailer": "^6.4.4",
"@types/react": "^17.0.33",
"@types/react": "^17.0.37",
"@types/refractor": "^3.0.2",
"@types/rss": "^0.0.29",
"@types/sanitize-html": "^2.5.0",
"@types/styled-components": "^5.1.15",
"@types/sanitize-html": "^2.6.0",
"@types/styled-components": "^5.1.17",
"@types/testing-library__react": "^10.2.0",
"@types/tryghost__content-api": "^1.3.7",
"@typescript-eslint/eslint-plugin": "^5.2.0",
"@typescript-eslint/parser": "^5.2.0",
"autoprefixer": "^10.3.7",
"critters": "^0.0.14",
"@types/tryghost__content-api": "^1.3.8",
"@typescript-eslint/eslint-plugin": "^5.6.0",
"@typescript-eslint/parser": "^5.6.0",
"autoprefixer": "^10.4.0",
"critters": "^0.0.15",
"eslint": "<8.0.0",
"eslint-config-next": "^12.0.1",
"eslint-config-next": "^12.0.7",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-react": "^7.26.1",
"eslint-plugin-react-hooks": "^4.2.0",
"next-sitemap": "^1.6.192",
"postcss": "^8.3.11",
"eslint-plugin-react": "^7.27.1",
"eslint-plugin-react-hooks": "^4.3.0",
"next-sitemap": "^1.6.203",
"postcss": "^8.4.5",
"postcss-color-mod-function": "^3.0.3",
"postcss-easy-import": "^3.0.0",
"postcss-preset-env": "^6.7.0",
"prettier": "^2.4.1",
"typescript": "^4.4.4"
"postcss-preset-env": "^7.0.1",
"prettier": "^2.5.1",
"typescript": "^4.5.3"
}
}
6 changes: 5 additions & 1 deletion pages/[...slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ export const getStaticProps: GetStaticProps = async ({ params }) => {
if (!(params && params.slug && Array.isArray(params.slug))) throw Error('getStaticProps: wrong parameters.')
const [slug] = params.slug.reverse()

console.time('Post - getStaticProps')

const settings = await getAllSettings()

let post: GhostPostOrPage | null = null
Expand Down Expand Up @@ -125,6 +127,8 @@ export const getStaticProps: GetStaticProps = async ({ params }) => {

const tags = (contactPage && contactPage.tags) || (page && page.tags) || undefined

console.timeEnd('Post - getStaticProps')

return {
props: {
cmsData: {
Expand All @@ -140,7 +144,7 @@ export const getStaticProps: GetStaticProps = async ({ params }) => {
bodyClass: BodyClass({ isPost, page: contactPage || page || undefined, tags }),
},
},
...(processEnv.isr.enable && { revalidate: 1 }), // re-generate at most once every second
...(processEnv.isr.enable && { revalidate: processEnv.isr.revalidate }), // re-generate at most once every revalidate second
}
}

Expand Down
2 changes: 1 addition & 1 deletion pages/author/[...slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const getStaticProps: GetStaticProps = async ({ params }) => {
bodyClass: BodyClass({ author }),
},
},
...(processEnv.isr.enable && { revalidate: 1 }), // re-generate at most once every second
...(processEnv.isr.enable && { revalidate: processEnv.isr.revalidate }), // re-generate at most once every revalidate second
}
}

Expand Down
6 changes: 5 additions & 1 deletion pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ export const getStaticProps: GetStaticProps = async () => {
let settings
let posts: GhostPostsOrPages | []

console.time('Index - getStaticProps')

try {
settings = await getAllSettings()
posts = await getAllPosts()
Expand All @@ -74,10 +76,12 @@ export const getStaticProps: GetStaticProps = async () => {
bodyClass: BodyClass({ isHome: true }),
}

console.timeEnd('Index - getStaticProps')

return {
props: {
cmsData,
},
...(processEnv.isr.enable && { revalidate: 1 }), // re-generate at most once every second
...(processEnv.isr.enable && { revalidate: processEnv.isr.revalidate }), // re-generate at most once every revalidate second
}
}
2 changes: 1 addition & 1 deletion pages/tag/[...slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const getStaticProps: GetStaticProps = async ({ params }) => {
bodyClass: BodyClass({ tags: [tag] }),
},
},
...(processEnv.isr.enable && { revalidate: 1 }), // re-generate at most once every second
...(processEnv.isr.enable && { revalidate: processEnv.isr.revalidate }), // re-generate at most once every revalidate second
}
}

Expand Down
Loading

1 comment on commit 3fbbbeb

@vercel
Copy link

@vercel vercel bot commented on 3fbbbeb Dec 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.