feat: add tina CMS; layouts
This commit is contained in:
parent
662a461c3c
commit
6fc63fd50c
6 changed files with 79 additions and 72 deletions
|
@ -14,6 +14,11 @@
|
|||
"test": "jest --verbose --passWithNoTests",
|
||||
"lint": "next lint"
|
||||
},
|
||||
"standard": {
|
||||
"ignore": [
|
||||
"/tina/**/*"
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"@highlightjs/cdn-assets": "^11.11.1",
|
||||
"date-fns": "^4.1.0",
|
||||
|
|
|
@ -3,7 +3,7 @@ import { NextSeo } from 'next-seo'
|
|||
import Link from 'next/link'
|
||||
import React from 'react'
|
||||
|
||||
function Book({ attributes, html }) {
|
||||
function Book ({ attributes, html }) {
|
||||
return (
|
||||
<>
|
||||
<h1>{attributes.title}<br /><small>by {attributes.author}</small></h1>
|
||||
|
@ -23,7 +23,7 @@ function Book({ attributes, html }) {
|
|||
<div>
|
||||
<Link href='./'>Back...</Link>
|
||||
{attributes.pubdate && <p>{formatDate(attributes.pubdate)}</p>}
|
||||
<div data-test='content' dangerouslySetInnerHTML={{ __html: html || "<p>(no review)</p>" }} />
|
||||
<div data-test='content' dangerouslySetInnerHTML={{ __html: html || '<p>(no review)</p>' }} />
|
||||
</div>
|
||||
</article>
|
||||
</>
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
import style from './BookListItem.module.css'
|
||||
import Link from 'next/link'
|
||||
|
||||
export default function BookListItem({ href, title, author, stars, readDate, url, thumbnailUrl, tags, review }) {
|
||||
export default function BookListItem ({ href, title, author, stars, readDate, url, thumbnailUrl, tags, review }) {
|
||||
return (
|
||||
<div className={style.item}>
|
||||
<Link href={href}>
|
||||
<div className={style['thumb']} style={{
|
||||
backgroundImage: `url(${thumbnailUrl ?? '/img/book-placeholder.jpg'})`
|
||||
}}></div>
|
||||
<div
|
||||
className={style.thumb} style={{
|
||||
backgroundImage: `url(${thumbnailUrl ?? '/img/book-placeholder.jpg'})`
|
||||
}}
|
||||
/>
|
||||
</Link>
|
||||
<div>
|
||||
<h2 className={style.heading}>
|
||||
|
|
|
@ -56,7 +56,7 @@ export function getStaticEntries (contentPath) {
|
|||
const directoryItems = fs.readdirSync(contentPath, { withFileTypes: true })
|
||||
return directoryItems.map((dirent) =>
|
||||
getMarkdownEntry(`${dirent.path}/${dirent.name}`)
|
||||
);
|
||||
)
|
||||
}
|
||||
|
||||
export function getContentTags (contentPath) {
|
||||
|
|
|
@ -10,18 +10,18 @@ export const getStaticProps = () => {
|
|||
const bookEntries = getStaticEntries('./content/books')
|
||||
.sort((a, b) => {
|
||||
return b.attributes.readDate - a.attributes.readDate
|
||||
});
|
||||
})
|
||||
|
||||
return {
|
||||
props: {
|
||||
// Silliness to make sure dates don't get passed to the
|
||||
// Silliness to make sure dates don't get passed to the
|
||||
// page function below as [object Object]
|
||||
bookEntries: JSON.parse(JSON.stringify(bookEntries))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default function Library({ bookEntries }) {
|
||||
export default function Library ({ bookEntries }) {
|
||||
return (
|
||||
<DefaultLayout>
|
||||
<NextSeo
|
||||
|
@ -44,4 +44,4 @@ export default function Library({ bookEntries }) {
|
|||
</section>
|
||||
</DefaultLayout>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
122
tina/config.js
122
tina/config.js
|
@ -1,11 +1,11 @@
|
|||
import { defineConfig } from "tinacms";
|
||||
import { defineConfig } from 'tinacms'
|
||||
|
||||
// Your hosting provider likely exposes this as an environment variable
|
||||
const branch =
|
||||
process.env.GITHUB_BRANCH ||
|
||||
process.env.VERCEL_GIT_COMMIT_REF ||
|
||||
process.env.HEAD ||
|
||||
"main";
|
||||
'main'
|
||||
|
||||
export default defineConfig({
|
||||
branch,
|
||||
|
@ -16,121 +16,121 @@ export default defineConfig({
|
|||
token: process.env.TINA_TOKEN,
|
||||
|
||||
build: {
|
||||
outputFolder: "admin",
|
||||
publicFolder: "public",
|
||||
outputFolder: 'admin',
|
||||
publicFolder: 'public'
|
||||
},
|
||||
media: {
|
||||
tina: {
|
||||
mediaRoot: "",
|
||||
publicFolder: "public",
|
||||
},
|
||||
mediaRoot: '',
|
||||
publicFolder: 'public'
|
||||
}
|
||||
},
|
||||
// See docs on content modeling for more info on how to setup new content models: https://tina.io/docs/schema/
|
||||
schema: {
|
||||
collections: [
|
||||
{
|
||||
name: "books",
|
||||
label: "Library",
|
||||
name: 'books',
|
||||
label: 'Library',
|
||||
path: 'content/books',
|
||||
match: {
|
||||
include: "*"
|
||||
include: '*'
|
||||
},
|
||||
format: "md",
|
||||
format: 'md',
|
||||
fields: [
|
||||
{
|
||||
type: "string",
|
||||
name: "title",
|
||||
label: "Title",
|
||||
type: 'string',
|
||||
name: 'title',
|
||||
label: 'Title',
|
||||
isTitle: true,
|
||||
required: true,
|
||||
required: true
|
||||
},
|
||||
{
|
||||
type: 'string',
|
||||
name: "author",
|
||||
label: "Author",
|
||||
name: 'author',
|
||||
label: 'Author',
|
||||
required: true
|
||||
},
|
||||
{
|
||||
type: 'number',
|
||||
name: "stars",
|
||||
label: "Stars",
|
||||
name: 'stars',
|
||||
label: 'Stars',
|
||||
required: true
|
||||
},
|
||||
{
|
||||
type: 'datetime',
|
||||
name: "readDate",
|
||||
label: "Read date",
|
||||
name: 'readDate',
|
||||
label: 'Read date',
|
||||
required: false
|
||||
},
|
||||
{
|
||||
type: 'string',
|
||||
name: "url",
|
||||
label: "URL",
|
||||
name: 'url',
|
||||
label: 'URL',
|
||||
required: false
|
||||
},
|
||||
{
|
||||
type: 'string',
|
||||
name: "thumbnailUrl",
|
||||
label: "Thumbnail URL",
|
||||
name: 'thumbnailUrl',
|
||||
label: 'Thumbnail URL',
|
||||
required: false
|
||||
},
|
||||
{
|
||||
type: 'string',
|
||||
name: "tags",
|
||||
label: "Tags",
|
||||
name: 'tags',
|
||||
label: 'Tags',
|
||||
required: true
|
||||
},
|
||||
{
|
||||
type: "rich-text",
|
||||
name: "body",
|
||||
label: "Body",
|
||||
isBody: true,
|
||||
},
|
||||
type: 'rich-text',
|
||||
name: 'body',
|
||||
label: 'Body',
|
||||
isBody: true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "writing",
|
||||
label: "Writing",
|
||||
path: "content/writing",
|
||||
name: 'writing',
|
||||
label: 'Writing',
|
||||
path: 'content/writing',
|
||||
match: {
|
||||
include: "*"
|
||||
include: '*'
|
||||
},
|
||||
format: "md",
|
||||
format: 'md',
|
||||
fields: [
|
||||
{
|
||||
type: "string",
|
||||
name: "title",
|
||||
label: "Title",
|
||||
type: 'string',
|
||||
name: 'title',
|
||||
label: 'Title',
|
||||
isTitle: true,
|
||||
required: true,
|
||||
required: true
|
||||
},
|
||||
{
|
||||
type: "datetime",
|
||||
name: "pubdate",
|
||||
label: "Publish Date",
|
||||
type: 'datetime',
|
||||
name: 'pubdate',
|
||||
label: 'Publish Date'
|
||||
},
|
||||
{
|
||||
type: "string",
|
||||
type: 'string',
|
||||
ui: {
|
||||
component: "textarea"
|
||||
component: 'textarea'
|
||||
},
|
||||
name: "desc",
|
||||
label: "Description",
|
||||
name: 'desc',
|
||||
label: 'Description'
|
||||
},
|
||||
{
|
||||
type: "string",
|
||||
name: "tags",
|
||||
label: "Tags",
|
||||
type: 'string',
|
||||
name: 'tags',
|
||||
label: 'Tags',
|
||||
list: true
|
||||
},
|
||||
{
|
||||
type: "rich-text",
|
||||
name: "body",
|
||||
label: "Body",
|
||||
isBody: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
type: 'rich-text',
|
||||
name: 'body',
|
||||
label: 'Body',
|
||||
isBody: true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Add table
Reference in a new issue