This repository has been archived by the owner on Dec 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #82 from brown-ccv/static-cms-custom-views
feat: Static cms custom views for people and news
- Loading branch information
Showing
5 changed files
with
87 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,24 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<link rel="stylesheet" href="https://unpkg.com/@staticcms/app@^4.0.0/dist/main.css" /> | ||
<title>Content Manager</title> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<link rel="stylesheet" href="https://unpkg.com/@staticcms/app@^4.0.0/dist/main.css" /> | ||
<title>Content Manager</title> | ||
</head> | ||
<body> | ||
<!-- Include the script that builds the page and powers Static CMS --> | ||
<script src="https://unpkg.com/@staticcms/app@^4.0.0/dist/static-cms-app.js"></script> | ||
<script> | ||
window.CMS.init(); | ||
<script type="module"> | ||
import { PeoplePreview } from "./previews/PeoplePreview.js" | ||
import { NewsPreview } from "./previews/NewsPreview.js" | ||
|
||
window.CMS.init() | ||
window.CMS.registerPreviewStyle("../src/styles/global.css") | ||
|
||
window.CMS.registerPreviewTemplate("people", PeoplePreview) | ||
window.CMS.registerPreviewTemplate("news", NewsPreview) | ||
|
||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
export const NewsPreview = ({ widgetFor, entry, collection, fields }) => { | ||
const imageField = useMemo(() => fields.find((field) => field.name === "heroImage"), [fields]) | ||
const imageUrl = useMediaAsset(entry.data.heroImage, collection, imageField, entry) | ||
|
||
return h( | ||
"div", | ||
{}, | ||
h("div", { className: "space-y-3 pb-6" }, h("h1", {}, entry.data.title)), | ||
h("hr", { className: "border-none h-0.5 bg-neutral-900 mb-16" }), | ||
h( | ||
"div", | ||
{}, | ||
h( | ||
"div", | ||
{}, | ||
|
||
h("img", { src: imageUrl, className: "w-full" }) | ||
), | ||
h("time", {}, entry.data.pubDate), | ||
h("div", { className: "text" }, widgetFor("body")) | ||
) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
export const PeoplePreview = ({ entry, collection, fields }) => { | ||
const imageField = useMemo(() => fields.find((field) => field.name === "avatar"), [fields]) | ||
const imageUrl = useMediaAsset(entry.data.avatar, collection, imageField, entry) | ||
|
||
return h( | ||
"div", | ||
{ className: "flex flex-col mt-4 md:flex-row gap-4 md:gap-8" }, | ||
h( | ||
"div", | ||
{ className: "flex-none" }, | ||
|
||
h("img", { src: imageUrl, className: "object-cover rounded-full w-40 h-40 md:w-64 md:h-64" }) | ||
), | ||
h( | ||
"div", | ||
{ className: "space-y-4" }, | ||
h( | ||
"div", | ||
{}, | ||
|
||
h("p", { className: "text-xl font-semibold underline text-neutral-900" }, entry.data.name), | ||
h("p", { className: "text-neutral-700 italic" }, entry.data.title), | ||
h("p", { className: "small" }, entry.data.org) | ||
), | ||
|
||
h("p", {}, entry.data.bio) | ||
) | ||
) | ||
} |