Skip to content

Commit

Permalink
1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
pookmish authored Oct 8, 2024
1 parent e2cceaa commit ff4bfb8
Show file tree
Hide file tree
Showing 26 changed files with 531 additions and 558 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# .github/workflows/release.yml
name: Release

on:
pull_request:
types: [closed]

jobs:
build:
runs-on: ubuntu-latest
permissions: write-all
if: github.event.pull_request.merged
steps:
- name: Get Next Release
id: tag
uses: K-Phoen/semver-release-action@master
with:
release_strategy: none
release_branch: main
tag_format: "%major%.%minor%.%patch%"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: echo 'Creating new release for ' ${{ steps.tag.outputs.tag }}
- name: Create Release
if: ${{ steps.tag.outputs.tag }}
uses: ncipollo/release-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: ${{ steps.tag.outputs.tag }}
tag: ${{ steps.tag.outputs.tag }}
commit: ${{ github.sha }}
generateReleaseNotes: true
makeLatest: true

4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
1.0.0 2024-10-08
--------------------------------------------------

- Initial release.
5 changes: 2 additions & 3 deletions app/[...slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ export const maxDuration = 60
const Page = async ({params}: PageProps) => {
const {path, page} = getBookPageRequested(getPathFromContext({params}))

const {redirect: redirectPath, entity, error} = await getEntityFromPath<NodeUnion>(path)
const {redirect: redirectPath, entity} = await getEntityFromPath<NodeUnion>(path)

if (error) throw new Error(error)
if (redirectPath?.url) redirect(redirectPath.url)
if (!entity) notFound()
if (redirectPath) redirect(redirectPath)

if (entity.__typename === "NodeSupBook") {
if (page === "excerpt") return <SupBookExcerptPage node={entity} />
Expand Down
8 changes: 8 additions & 0 deletions app/api/book-paths/route.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import {NextResponse} from "next/server"
import {getLegacyBookPaths} from "@lib/utils/getLegacyBookPaths"

export const revalidate = 86400

export const GET = async () => {
return NextResponse.json(await getLegacyBookPaths())
}
4 changes: 2 additions & 2 deletions app/api/revalidate/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const GET = async (request: NextRequest) => {
let path = request.nextUrl.searchParams.get("slug")
if (!path || path.startsWith("/node/")) return NextResponse.json({message: "Invalid slug"}, {status: 400})

const tagsInvalidated = ["paths", `paths:${path}`]
const tagsInvalidated = path.startsWith("/tags/") ? [] : [`paths:${path}`]
if (path.startsWith("/tags/"))
path
.substring(6)
Expand All @@ -30,7 +30,7 @@ export const GET = async (request: NextRequest) => {

// When the home page is saved, it's url slug might be like `/home`. If the home page matches the slug, invalidate
// the home page path.
if ((await getHomePagePath()) === path) tagsInvalidated.push("paths:/")
if (!path.startsWith("/tags/") && (await getHomePagePath()) === path) tagsInvalidated.push("paths:/")

// Invalidate the book path if the path is an excerpt page.
if (path.includes("/excerpt/")) tagsInvalidated.push(`excerpts:${path.substring(0, path.indexOf("/excerpt"))}`)
Expand Down
7 changes: 0 additions & 7 deletions app/books/awards/page.tsx

This file was deleted.

12 changes: 0 additions & 12 deletions app/books/comp/page.tsx

This file was deleted.

12 changes: 0 additions & 12 deletions app/books/extra/page.tsx

This file was deleted.

21 changes: 0 additions & 21 deletions app/books/getBookPathFromWorkId.tsx

This file was deleted.

22 changes: 22 additions & 0 deletions app/books/legacy/[id]/comp/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import {notFound, redirect} from "next/navigation"
import {getLegacyBookPaths} from "@lib/utils/getLegacyBookPaths"

export const revalidate = false
export const dynamic = "force-static"
export const dynamicParams = false

const LegacyBookPage = async ({params}: {params: {id: string}}) => {
const legacyPaths = await getLegacyBookPaths()
const legacyBook = legacyPaths.find(book => book.id === parseInt(params.id))
if (legacyBook) redirect(legacyBook.path + "/desk-examination-copy-requests")

notFound()
}

export const generateStaticParams = async (): Promise<Array<{id: string}>> => {
if (process.env.VERCEL_ENV === "preview") return []
const params = await getLegacyBookPaths()
return params.map(item => ({id: item.id.toString()}))
}

export default LegacyBookPage
22 changes: 22 additions & 0 deletions app/books/legacy/[id]/extra/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import {notFound, redirect} from "next/navigation"
import {getLegacyBookPaths} from "@lib/utils/getLegacyBookPaths"

export const revalidate = false
export const dynamic = "force-static"
export const dynamicParams = false

const LegacyBookPage = async ({params}: {params: {id: string}}) => {
const legacyPaths = await getLegacyBookPaths()
const legacyBook = legacyPaths.find(book => book.id === parseInt(params.id))
if (legacyBook) redirect(legacyBook.path + "/excerpts")

notFound()
}

export const generateStaticParams = async (): Promise<Array<{id: string}>> => {
if (process.env.VERCEL_ENV === "preview") return []
const params = await getLegacyBookPaths()
return params.map(item => ({id: item.id.toString()}))
}

export default LegacyBookPage
22 changes: 22 additions & 0 deletions app/books/legacy/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import {notFound, redirect} from "next/navigation"
import {getLegacyBookPaths} from "@lib/utils/getLegacyBookPaths"

export const revalidate = false
export const dynamic = "force-static"
export const dynamicParams = false

const LegacyBookPage = async ({params}: {params: {id: string}}) => {
const legacyPaths = await getLegacyBookPaths()
const legacyBook = legacyPaths.find(book => book.id === parseInt(params.id))
if (legacyBook) redirect(legacyBook.path)

notFound()
}

export const generateStaticParams = async (): Promise<Array<{id: string}>> => {
if (process.env.VERCEL_ENV === "preview") return []
const params = await getLegacyBookPaths()
return params.map(item => ({id: item.id.toString()}))
}

export default LegacyBookPage
7 changes: 0 additions & 7 deletions app/books/precart/page.tsx

This file was deleted.

12 changes: 0 additions & 12 deletions app/books/title/page.tsx

This file was deleted.

3 changes: 1 addition & 2 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ export const revalidate = false
export const dynamic = "force-static"

const Home = async () => {
const {entity, error} = await getEntityFromPath<NodeStanfordPage>("/", isPreviewMode())
const {entity} = await getEntityFromPath<NodeStanfordPage>("/", isPreviewMode())

if (error) throw new Error(error)
if (!entity) notFound()

return (
Expand Down
3 changes: 1 addition & 2 deletions app/preview/[...slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ import {isPreviewMode} from "@lib/drupal/is-preview-mode"

const PreviewPage = async ({params}: PageProps) => {
if (!isPreviewMode()) notFound()
const {entity, error} = await getEntityFromPath<NodeUnion>(getPathFromContext({params}), true)
const {entity} = await getEntityFromPath<NodeUnion>(getPathFromContext({params}), true)

if (error) throw new Error(error)
if (!entity) notFound()

return (
Expand Down
7 changes: 4 additions & 3 deletions app/sitemap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {MetadataRoute} from "next"
import {getAllNodes} from "@lib/gql/gql-queries"

// https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config
export const revalidate = false
export const revalidate = 604800
export const dynamic = "force-static"

const Sitemap = async (): Promise<MetadataRoute.Sitemap> => {
Expand All @@ -11,8 +11,9 @@ const Sitemap = async (): Promise<MetadataRoute.Sitemap> => {
const sitemap: MetadataRoute.Sitemap = []

nodes.map(node => {
const path = node.path === "/home" ? "/" : node.path
sitemap.push({
url: `https://sup.org${node.path}`,
url: `https://www.sup.org${path}`,
lastModified: new Date(node.changed.time),
priority: node.__typename === "NodeStanfordPage" ? 1 : 0.8,
changeFrequency: node.__typename === "NodeStanfordPage" ? "weekly" : "monthly",
Expand All @@ -21,7 +22,7 @@ const Sitemap = async (): Promise<MetadataRoute.Sitemap> => {
// Add excerpts page for each book as appropriate.
if (node.__typename === "NodeSupBook" && node.supBookExcerpts) {
sitemap.push({
url: `https://sup.org${node.path}/excerpts`,
url: `https://www.sup.org${node.path}/excerpts`,
lastModified: new Date(node.changed.time),
priority: 0.8,
changeFrequency: "monthly",
Expand Down
33 changes: 33 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,39 @@ const nextConfig = {
async rewrites() {
return {
beforeFiles: [
{
source: "/books/(title|awards|precart)",
destination: "/books/legacy/:workId",
has: [
{
type: "query",
key: "id",
value: "(?<workId>.*)"
}
]
},
{
source: "/books/comp",
destination: "/books/legacy/:workId/comp",
has: [
{
type: "query",
key: "id",
value: "(?<workId>.*)"
}
]
},
{
source: "/books/extra",
destination: "/books/legacy/:workId/extra",
has: [
{
type: "query",
key: "id",
value: "(?<workId>.*)"
}
]
},
{
source: '/img/:path*',
destination: '/not-found',
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
"@mui/base": "5.0.0-beta.58",
"@next/third-parties": "^14.2.14",
"@tailwindcss/container-queries": "^0.1.1",
"@types/node": "^22.7.4",
"@types/node": "^22.7.5",
"@types/react": "^18.3.11",
"@types/react-dom": "^18.3.0",
"algoliasearch": "5.7.0",
"algoliasearch": "5.8.0",
"autoprefixer": "^10.4.20",
"clsx": "^2.1.1",
"decanter": "^7.3.0",
Expand All @@ -31,7 +31,7 @@
"graphql-request": "^7.1.0",
"graphql-tag": "^2.12.6",
"html-entities": "^2.5.2",
"html-react-parser": "^5.1.17",
"html-react-parser": "^5.1.18",
"next": "^14.2.14",
"plaiceholder": "^3.0.0",
"postcss": "^8.4.47",
Expand All @@ -51,10 +51,10 @@
},
"devDependencies": {
"@graphql-codegen/add": "^5.0.3",
"@graphql-codegen/cli": "^5.0.2",
"@graphql-codegen/cli": "^5.0.3",
"@graphql-codegen/import-types-preset": "^3.0.0",
"@graphql-codegen/typescript-graphql-request": "^6.2.0",
"@graphql-codegen/typescript-operations": "^4.2.3",
"@graphql-codegen/typescript-operations": "^4.3.0",
"@next/bundle-analyzer": "^14.2.14",
"@storybook/addon-essentials": "^8.3.5",
"@storybook/addon-interactions": "^8.3.5",
Expand All @@ -67,7 +67,7 @@
"@types/react-slick": "^0.23.13",
"concurrently": "^9.0.1",
"encoding": "^0.1.13",
"eslint": "^9.11.1",
"eslint": "^8.57.1",
"eslint-config-next": "^14.2.14",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-deprecation": "^3.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const Slide = async ({slideParagraph, isTopHero}: {slideParagraph: ParagraphSupC

<div
className={twMerge(
"relative mx-auto flex w-full max-w-1000 flex-col items-center justify-center py-32",
"relative mx-auto flex w-full max-w-1000 flex-col items-center py-32 lg:justify-center",
clsx({
"gap-20 lg:flex-row": leftImage,
})
Expand Down
Loading

0 comments on commit ff4bfb8

Please sign in to comment.