Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Od/pcc 1536/article blog #296

Merged
merged 10 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"plugins": ["@ianvs/prettier-plugin-sort-imports"],
"plugins": [
"@ianvs/prettier-plugin-sort-imports",
"prettier-plugin-tailwindcss"
],
"semi": true,
"singleQuote": false,
"useTabs": false,
Expand Down
3 changes: 3 additions & 0 deletions configs/eslint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"prettier": "3.2.5"
},
"devDependencies": {
"prettier-plugin-tailwindcss": "^0.6.6"
}
}
1,245 changes: 1,167 additions & 78 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ import { ClientsideArticleView } from "./clientside-articleview";
export const ArticleView = async ({ params, searchParams }) => {
const { article, grant } = await getServersideArticle(params, searchParams);

return (
<>
<ClientsideArticleView article={article} grant={grant} />
<Tags tags={article?.tags} />
</>
);
return <ClientsideArticleView article={article} grant={grant} />;
};

export async function getServersideArticle(params, searchParams) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ArticleView, getServersideArticle } from "./article-view";
export default async function ArticlePage({ params, searchParams }) {
return (
<Layout>
<div className="max-w-screen-lg mx-auto mt-16 prose">
<div className="prose mx-4 mt-16 text-black sm:mx-6 lg:mx-auto">
<Suspense fallback={<SkeletonArticleView />}>
<ArticleView params={params} searchParams={searchParams} />
</Suspense>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,16 @@ export default function ArticleView({
return (
<>
<div>
<h1 className="text-3xl font-bold md:text-4xl">{title}</h1>
<h1 className="text-5xl font-bold">{title}</h1>
{article.updatedAt ? (
<p className="py-2">
Last Updated:{" "}
{new Date(article.updatedAt).toLocaleDateString("en-US", {
year: "numeric",
month: "long",
day: "numeric",
})}
</p>
) : null}

<hr className="mt-6 mb-8" />
</div>
<ArticleRenderer
article={hydratedArticle}
Expand Down
39 changes: 38 additions & 1 deletion starters/nextjs-starter-approuter-ts/tailwind.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,44 @@ module.exports = {
"./app/**/*.{js,jsx,ts,tsx}",
],
theme: {
extend: {},
extend: {
typography: () => ({
DEFAULT: {
css: {
maxWidth: "80ch",
img: {
borderRadius: "1rem",
maxWidth: "none !important",
maxHeight: "none !important",
aspectRatio: "3/2",
marginTop: "4rem !important",
marginBottom: "4rem !important",
},
a: {
color: "rgb(17, 85, 204)", // "dark cornflower blue 2" in Google Docs
},
h1: {
fontSize: "3rem",
},
h2: {
fontSize: "2.25rem",
},
h3: {
fontSize: "1.875rem",
},
h4: {
fontSize: "1.5rem",
},
h5: {
fontSize: "1.25rem",
},
h6: {
fontSize: "1rem",
},
},
},
}),
},
},
plugins: [require("@tailwindcss/typography"), require("tailwindcss-animate")],
};
5 changes: 1 addition & 4 deletions starters/nextjs-starter-ts/components/article-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,17 @@ export function StaticArticleView({ article, onlyContent }: ArticleViewProps) {
return (
<>
<div>
<div className="text-3xl font-bold md:text-4xl">{articleTitle}</div>
<div className="text-5xl font-bold">{articleTitle}</div>

{article.updatedAt ? (
<p className="py-2">
Last Updated:{" "}
{new Date(article.updatedAt).toLocaleDateString("en-US", {
year: "numeric",
month: "long",
day: "numeric",
})}
</p>
) : null}

<hr className="mt-6 mb-8" />
</div>
<ArticleRenderer
article={article}
Expand Down
18 changes: 3 additions & 15 deletions starters/nextjs-starter-ts/pages/articles/[...uri].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,15 @@ import {
import { NextSeo } from "next-seo";
import queryString from "query-string";
import ArticleView from "../../components/article-view";
import { PageGrid } from "../../components/grid";
import Layout from "../../components/layout";
import { Tags } from "../../components/tags";
import { pantheonAPIOptions } from "../api/pantheoncloud/[...command]";

interface ArticlePageProps {
article: Article;
grant: string;
recommendedArticles: Article[];
}

export default function ArticlePage({
article,
grant,
recommendedArticles,
}: ArticlePageProps) {
export default function ArticlePage({ article, grant }: ArticlePageProps) {
const seoMetadata = getSeoMetadata(article);

return (
Expand Down Expand Up @@ -50,13 +43,8 @@ export default function ArticlePage({
}}
/>

<div className="max-w-screen-lg mx-auto mt-16 prose text-black">
<ArticleView article={article} />
<Tags tags={article?.tags} />
<section>
<h3>Recommended Articles</h3>
<PageGrid data={recommendedArticles} />
</section>
<div className="prose mx-4 mt-16 text-black sm:mx-6 lg:mx-auto">
<ArticleView article={article} onlyContent />
</div>
</Layout>
</PantheonProvider>
Expand Down
27 changes: 27 additions & 0 deletions starters/nextjs-starter-ts/tailwind.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,36 @@ module.exports = {
typography: () => ({
DEFAULT: {
css: {
maxWidth: "80ch",
img: {
borderRadius: "1rem",
maxWidth: "none !important",
maxHeight: "none !important",
aspectRatio: "3/2",
marginTop: "4rem !important",
marginBottom: "4rem !important",
},
a: {
color: "rgb(17, 85, 204)", // "dark cornflower blue 2" in Google Docs
},
h1: {
fontSize: "3rem",
},
h2: {
fontSize: "2.25rem",
},
h3: {
fontSize: "1.875rem",
},
h4: {
fontSize: "1.5rem",
},
h5: {
fontSize: "1.25rem",
},
h6: {
fontSize: "1rem",
},
},
},
}),
Expand Down
18 changes: 10 additions & 8 deletions starters/nextjs-starter/components/article-view.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
import { useMemo } from "react";
import { clientSmartComponentMap } from "./smart-components";

export default function ArticleView({ article }) {
export default function ArticleView({ article, onlyContent }) {
const { data } = useArticle(
article.id,
{
Expand All @@ -23,34 +23,36 @@ export default function ArticleView({ article }) {
[data, article],
);

return <StaticArticleView article={hydratedArticle} />;
return (
<StaticArticleView article={hydratedArticle} onlyContent={onlyContent} />
);
}

export function StaticArticleView({ article }) {
export function StaticArticleView({ article, onlyContent }) {
const articleTitle = useArticleTitle(article);

return (
<>
<div>
<div className="text-3xl font-bold md:text-4xl">{articleTitle}</div>
<div className="text-5xl font-bold">{articleTitle}</div>

{article.updatedAt ? (
<p className="py-2">
Last Updated:{" "}
{new Date(article.updatedAt).toLocaleDateString("en-US", {
year: "numeric",
month: "long",
day: "numeric",
})}
</p>
) : null}

<hr className="mt-6 mb-8" />
</div>
<ArticleRenderer
article={article}
smartComponentMap={clientSmartComponentMap}
__experimentalFlags={{ useUnintrusiveTitleRendering: true }}
__experimentalFlags={{
useUnintrusiveTitleRendering: true,
disableAllStyles: !!onlyContent,
}}
/>
</>
);
Expand Down
13 changes: 3 additions & 10 deletions starters/nextjs-starter/pages/articles/[...uri].jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ import {
import { NextSeo } from "next-seo";
import queryString from "query-string";
import ArticleView from "../../components/article-view";
import { PageGrid } from "../../components/grid";
import Layout from "../../components/layout";
import { Tags } from "../../components/tags";
import { pantheonAPIOptions } from "../api/pantheoncloud/[...command]";

export default function ArticlePage({ article, grant, recommendedArticles }) {
export default function ArticlePage({ article, grant }) {
const seoMetadata = getSeoMetadata(article);

return (
Expand Down Expand Up @@ -39,13 +37,8 @@ export default function ArticlePage({ article, grant, recommendedArticles }) {
}}
/>

<div className="max-w-screen-lg mx-auto mt-16 prose text-black">
<ArticleView article={article} />
<Tags tags={article?.tags} />
<section>
<h3>Recommended Articles</h3>
<PageGrid data={recommendedArticles} />
</section>
<div className="prose mx-4 mt-16 text-black sm:mx-6 lg:mx-auto">
<ArticleView article={article} onlyContent />
</div>
</Layout>
</PantheonProvider>
Expand Down
27 changes: 27 additions & 0 deletions starters/nextjs-starter/tailwind.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,36 @@ module.exports = {
typography: () => ({
DEFAULT: {
css: {
maxWidth: "80ch",
img: {
borderRadius: "1rem",
maxWidth: "none !important",
maxHeight: "none !important",
aspectRatio: "3/2",
marginTop: "4rem !important",
marginBottom: "4rem !important",
},
a: {
color: "rgb(17, 85, 204)", // "dark cornflower blue 2" in Google Docs
},
h1: {
fontSize: "3rem",
},
h2: {
fontSize: "2.25rem",
},
h3: {
fontSize: "1.875rem",
},
h4: {
fontSize: "1.5rem",
},
h5: {
fontSize: "1.25rem",
},
h6: {
fontSize: "1rem",
},
},
},
}),
Expand Down