File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,6 +2,9 @@ import { getSideNav } from "@/services/docs/getSideNav";
22import { Config } from "@/util/config" ;
33import { getBlogListing } from "@/services/blog/getBlogListing" ;
44import { getDevResources } from "@/services/learning/getDevResources" ;
5+
6+ /** Aggregates many GraphQL calls; never freeze this into a static build artifact. */
7+ export const dynamic = "force-dynamic" ;
58const extractHrefs = ( obj ) => {
69 const baseURL = `${ Config . CDNHost } /docs/` ;
710 let hrefs = [ ] ;
Original file line number Diff line number Diff line change 11import type { Metadata } from "next" ;
22import { PersonaLandingPage } from "@/components/persona-landing/PersonaLandingPage" ;
33
4+ /** CMS nav is fetched at request time so a slow or unavailable GraphQL during `next build` does not fail the deploy. */
5+ export const dynamic = "force-dynamic" ;
6+
47const hostname = "https://dev.dotcms.com" ;
58
69export const metadata : Metadata = {
Original file line number Diff line number Diff line change 11import type { Metadata } from "next" ;
22import { PersonaLandingPage } from "@/components/persona-landing/PersonaLandingPage" ;
33
4+ /** CMS nav is fetched at request time so a slow or unavailable GraphQL during `next build` does not fail the deploy. */
5+ export const dynamic = "force-dynamic" ;
6+
47const hostname = "https://dev.dotcms.com" ;
58
69export const metadata : Metadata = {
Original file line number Diff line number Diff line change 11import type { Metadata } from "next" ;
22import { PersonaLandingPage } from "@/components/persona-landing/PersonaLandingPage" ;
33
4+ /** CMS nav is fetched at request time so a slow or unavailable GraphQL during `next build` does not fail the deploy. */
5+ export const dynamic = "force-dynamic" ;
6+
47const hostname = "https://dev.dotcms.com" ;
58
69export const metadata : Metadata = {
Original file line number Diff line number Diff line change 1- import { getCourseDetail } from "@/services/courses/getCourse" ;
1+ import { courseTitleForMetadata , getCourseDetail } from "@/services/courses/getCourse" ;
22import MarkdownContent from "@/components/MarkdownContent" ;
33import { notFound } from "next/navigation" ;
44import ChapterFooter from "../ChapterFooter" ;
55
6+ export async function generateMetadata ( { params } ) {
7+ const { slug, chapter } = await params ;
8+ const { course } = await getCourseDetail ( { slug } ) ;
9+ if ( ! course ) {
10+ return { title : "Course not found" } ;
11+ }
12+
13+ const match = chapter . match ( / ^ c h a p t e r - ( \d + ) $ / ) ;
14+ if ( ! match ) {
15+ return { title : "Chapter not found" } ;
16+ }
17+
18+ const index = parseInt ( match [ 1 ] , 10 ) - 1 ;
19+ const chapterData = course . chapters [ index ] ;
20+ if ( ! chapterData ) {
21+ return { title : "Chapter not found" } ;
22+ }
23+
24+ const total = course . chapters ?. length ?? 0 ;
25+ const n = index + 1 ;
26+ const label = courseTitleForMetadata ( course ) ;
27+ return { title : `${ label } · Ch. ${ n } /${ total } — ${ chapterData . title } ` } ;
28+ }
29+
630export default async function ChapterPage ( { params } ) {
731 const { slug, chapter } = await params ;
832 const { course } = await getCourseDetail ( { slug } ) ;
Original file line number Diff line number Diff line change 1- import { getCourseDetail } from "@/services/courses/getCourse" ;
1+ import { courseTitleForMetadata , getCourseDetail } from "@/services/courses/getCourse" ;
22import ChapterFooter from "./ChapterFooter" ;
33import CourseIntroduction from "./CourseIntroduction" ;
44import { notFound } from "next/navigation" ;
55
6+ export async function generateMetadata ( { params } ) {
7+ const { slug } = await params ;
8+ const { course } = await getCourseDetail ( { slug } ) ;
9+ if ( ! course ) {
10+ return { title : "Course not found" } ;
11+ }
12+ return { title : courseTitleForMetadata ( course ) } ;
13+ }
14+
615export default async function CoursePage ( { params } ) {
716 const { slug } = await params ;
817 const { course } = await getCourseDetail ( { slug } ) ;
You can’t perform that action at this time.
0 commit comments