Skip to content

Commit

Permalink
Add link to live assessments on PrairieLearn (#13)
Browse files Browse the repository at this point in the history
* Pull in latest pl-demo-course

* Add PrairieLearn link to assessments
  • Loading branch information
nwalters512 committed May 14, 2021
1 parent dc1cc75 commit c956f53
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/lib/gallery/assessments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export const ASSESSMENTS_ROOT = path.join(
"assessments"
);

export interface Assessment extends MarkdownPage {}
export interface Assessment extends MarkdownPage {
prairielearnUrl: string | null;
}

let cachedAssessments: Assessment[];

Expand All @@ -38,7 +40,11 @@ export const getAssessments = async (): Promise<Assessment[]> => {
const docsMarkdown = await fs.readFile(docsMarkdownPath, "utf-8");
const {
content,
data: { title = "NO TITLE", summary = "NO SUMMARY" },
data: {
title = "NO TITLE",
summary = "NO SUMMARY",
prairielearn_url: prairielearnUrl = null,
},
} = matter(docsMarkdown);

return {
Expand All @@ -47,6 +53,7 @@ export const getAssessments = async (): Promise<Assessment[]> => {
summary: summary,
markdownContent: content,
markdownPath: docsMarkdownPath,
prairielearnUrl,
};
})
)
Expand Down
8 changes: 8 additions & 0 deletions src/pages/gallery/[...slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ interface GalleryPageProps {
source: string;
summary: string;
title: string;
prairielearnUrl?: string | null;
}

const GalleryPage: React.FC<GalleryPageProps> = ({
summary,
source,
title,
prairielearnUrl,
}) => {
const content = hydrate(source);
return (
Expand All @@ -36,6 +38,11 @@ const GalleryPage: React.FC<GalleryPageProps> = ({
<div className="my-5">
<h1 className="display-3">{title}</h1>
{summary && <p className="lead">{summary}</p>}
{prairielearnUrl && (
<a href={prairielearnUrl} className="btn btn-primary mt-2">
View on PrairieLearn
</a>
)}
</div>
<MDXProvider components={mdxComponents}>{content}</MDXProvider>
</div>
Expand Down Expand Up @@ -106,6 +113,7 @@ export const getStaticProps: GetStaticProps<
source: mdxSource,
summary: assessment.summary,
title: assessment.title,
prairielearnUrl: assessment.prairielearnUrl,
},
};
}
Expand Down

1 comment on commit c956f53

@vercel
Copy link

@vercel vercel bot commented on c956f53 May 14, 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.