-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Feature/article content creator (#40) (#42) * Created new post src/lib/articles/content/articles/2020-7-1-An-Introduction-to-Value-Innovation}.json with TinaCMS * Fix bad name * Remove example post * Created new post src/lib/articles/content/articles/2020-08-31-test.json with TinaCMS * Created new post src/lib/articles/content/articles/2020-08-31-test-2.json with TinaCMS * Upload * Update from TinaCMS * Upload * Update from TinaCMS * Refactor to support content creation * Fix article slugs on archive * Make left aligned hero prettier * Fix vertical alignment * Update timestamp format * Update timestamp format * Add proper reading time and post date * Created new post src/lib/articles/content/articles/2020-08-31-test-3.json with TinaCMS * Fix on 0 length content: * Properly working reading time and english post time * Remove test files * Refactor data fetching to be more terse in controllers, and fix article creation oddities * Fix post time in kitchen sink * Created new post src/lib/articles/content/articles/2020-09-01-test.json with TinaCMS * Fix branching * Remove test doc * Set preview branch on creation of new file * Remove annoying mac file * Fix kitchen sink * Remove console.log * Fetch articles from remote in editing mode * Fix path * Enable incremental SSG for articles * Fix fallback behaviour * Enable dynamic paging * Enable dynamic paging * Try fixing 500? * Refactor to a packages setup * Fix SSR * Fix syntax error * Fix build * Fix build * Fix build * Fix build * Fix styling and editing * Fix build * Fix build
- Loading branch information
1 parent
3533e8a
commit 5bf9414
Showing
106 changed files
with
7,816 additions
and
477 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,4 +114,7 @@ dist | |
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* | ||
.vercel | ||
.vercel | ||
|
||
# Custom | ||
.DS_Store |
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
File renamed without changes.
File renamed without changes.
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,2 @@ | ||
export { default as articleArchiveData } from "./content/articles.json"; | ||
export * from "./models" |
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,22 @@ | ||
import { Block } from "react-tinacms-inline"; | ||
import { ArticleHeroProps } from "../../../cdm-ui/articles/components/Hero"; | ||
|
||
export interface Article { | ||
title: string; | ||
description: string; | ||
featured_image: string | undefined; | ||
created_date: string | Date; | ||
edited_date: string | Date; | ||
categories: [] | [{ | ||
title: string | ||
href: string | ||
}], | ||
author: { | ||
fullName: string, | ||
photo: string | ||
}, | ||
hero: { | ||
variant: ArticleHeroProps['variant']; | ||
} | ||
body: Block[] | ||
} |
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 @@ | ||
export * from "./article" |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,3 @@ | ||
export { default as footerData } from "./content/footer.json" | ||
export { default as homeData } from "./content/home.json" | ||
export { default as kitchenSinkData } from "./content/kitchen-sink.json" |
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,2 @@ | ||
export * from "./articles" | ||
export * from "./general" |
2 changes: 0 additions & 2 deletions
2
src/lib/articles/blocks/Figure.tsx → packages/cdm-ui/articles/blocks/Figure.tsx
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
.../articles/routes/article/article.form.tsx → .../articles/routes/article/article.form.tsx
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
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { readdirSync, readFileSync } from 'fs'; | ||
import path from "path"; | ||
import slugify from 'slugify'; | ||
import { getFiles } from 'next-tinacms-github'; | ||
import { articlesRelPath } from '../articles'; | ||
|
||
export * from "./article"; | ||
|
||
export const useArticleData = async (articleRelPath: string) => { | ||
return JSON.parse(readFileSync(path.resolve(process.cwd(), articleRelPath), { encoding: "utf-8" })) | ||
}; | ||
export const articlesRelDir = 'packages/cdm-content/articles/content/articles'; | ||
|
||
export function getArticleMetaBySlug (slug: string) { | ||
const fileName = `${slug}.json`; | ||
const articleRelPath = `${articlesRelDir}/${fileName}`; | ||
const articleAbsolutePath = path.resolve(process.cwd(), articlesRelPath); | ||
|
||
return { | ||
slug: slug, | ||
fileName, | ||
articleRelPath, | ||
articleAbsolutePath | ||
} | ||
} | ||
|
||
export async function getAllArticlePaths(isEditing?: boolean, branch?: string, accessToken?: string) { | ||
const articlesDir = path.resolve(process.cwd(), articlesRelDir); | ||
let filePaths; | ||
|
||
if (isEditing) { | ||
const repoName = process.env.REPO_FULL_NAME; | ||
const branchName = branch ?? process.env.BASE_BRANCH; | ||
const currentAccessToken = accessToken ?? process.env.GITHUB_ACCESS_TOKEN; | ||
|
||
filePaths = (await getFiles(articlesRelDir, repoName, branchName, currentAccessToken)) | ||
.map(file => file.replace(articlesRelDir + "/", "")); | ||
} | ||
else { | ||
filePaths = readdirSync(articlesDir); | ||
} | ||
|
||
return filePaths.map(fileName => { | ||
const slug = slugify( | ||
fileName | ||
.replace(/\.json$/, '') | ||
); | ||
const articleRelPath = `${articlesRelDir}/${fileName}`; | ||
const articleAbsolutePath = path.resolve(process.cwd(), articleRelPath); | ||
|
||
return { | ||
slug, | ||
fileName, | ||
articleRelPath, | ||
articleAbsolutePath | ||
} | ||
}); | ||
} |
File renamed without changes.
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,6 @@ | ||
#articles, | ||
#articles > div, | ||
#articles > div > div { | ||
min-height: 100%; | ||
height: 100%; | ||
} |
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,124 @@ | ||
import React, { Fragment, useContext, useMemo } from 'react'; | ||
import { useForm, usePlugin } from 'tinacms'; | ||
import { InlineForm } from 'react-tinacms-inline'; | ||
import { Container, Row, Col } from 'react-bootstrap'; | ||
import MainLayout from '../../../core/layouts/Main'; | ||
import { useArticlesForm } from './articles.form'; | ||
import { ReferenceCallout } from '../../../core/components/Reference/Callout'; | ||
import { ReferenceCard } from '../../../core/components/Reference/Card'; | ||
import { Heading } from '../../../core/components/Typography/Heading'; | ||
import styles from "./articles.module.css"; | ||
|
||
export interface ArticlesProps { | ||
page: any; | ||
articles?: any; | ||
footer: any; | ||
isEditing?: boolean; | ||
children?: React.ReactChild; | ||
} | ||
|
||
export function ArticlesRoute({ page, articles, footer }: ArticlesProps) { | ||
const [data, form] = useArticlesForm(page.file); | ||
const [, form2] = useForm({ | ||
id: "example", | ||
label: "example", | ||
fields: [], | ||
initialValues: { | ||
email: null | ||
}, | ||
validate: function (values) { return undefined }, | ||
onSubmit: () => undefined | ||
}) | ||
const featuredArticles = useMemo(() => articles?.filter(article => article.featured === true), [articles]); | ||
const seo = { | ||
title: data.title, | ||
description: data.description | ||
} | ||
|
||
usePlugin(form2); | ||
usePlugin(form); | ||
|
||
return ( | ||
<div id={styles.articles}> | ||
<InlineForm form={form}> | ||
<MainLayout seo={seo} page={page} footer={footer}> | ||
<Container> | ||
<Row> | ||
<Col> | ||
<ReferenceCallout | ||
title={data.title} | ||
body={data.description} | ||
image={data.image} | ||
variant="dark" | ||
className="bg-lightblue" | ||
/> | ||
</Col> | ||
</Row> | ||
{featuredArticles.length > 0 && ( | ||
<Row className="pt-4 pb-4"> | ||
<Col xs={12}> | ||
<Heading as="h5" border={true} bold={true}> | ||
Featured Stories | ||
</Heading> | ||
</Col> | ||
<Col md="6"> | ||
<ReferenceCard | ||
size="lg" | ||
reference={{ | ||
title: "Hello world", | ||
description: "I am alive", | ||
href: "#", | ||
author: { | ||
name: "Chris D. Macrae", | ||
readingTime: 1000 * 60 * 60 * 5 | ||
} | ||
}} | ||
/> | ||
</Col> | ||
<Col md="6"> | ||
{[0, 1, 2].map((n, index) => ( | ||
<ReferenceCard | ||
size="sm" | ||
reference={{ | ||
title: "Hello world", | ||
description: "I am alive", | ||
href: "#", | ||
author: { | ||
name: "Chris D. Macrae" | ||
} | ||
}} | ||
key={index} | ||
/> | ||
))} | ||
</Col> | ||
</Row> | ||
)} | ||
<Row className="pt-4 pb-4"> | ||
<Col> | ||
<Heading as="h5" border={true} bold={true}> | ||
All Stories | ||
</Heading> | ||
{articles.map((article, index) => ( | ||
<Fragment key={index}> | ||
{article.file && ( | ||
<ReferenceCard | ||
size="md" | ||
reference={{ | ||
...article.file.data, | ||
href: `/articles/${article.slug}`, | ||
image: article.file.data.featured_image | ||
}} | ||
/> | ||
)} | ||
</Fragment> | ||
))} | ||
</Col> | ||
</Row> | ||
</Container> | ||
</MainLayout> | ||
</InlineForm> | ||
</div> | ||
); | ||
} | ||
|
||
export default ArticlesRoute; |
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,5 @@ | ||
export * from "./articles"; | ||
|
||
export const useArticlesData = async () => await (await import("cdm-content")).articleArchiveData; | ||
|
||
export const articlesRelPath = 'packages/cdm-content/articles/content/articles.json'; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./EditLink"; |
File renamed without changes.
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,3 @@ | ||
export * from "./components" | ||
export * from "./providers" | ||
export * from "./utils" |
Oops, something went wrong.
5bf9414
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: