Skip to content

Commit

Permalink
Add post collection
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinDelille committed May 1, 2023
1 parent 1df6343 commit 09b9aa5
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 4 deletions.
66 changes: 63 additions & 3 deletions tina/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { defineConfig } from "tinacms";
import { postFields } from "./templates";
import moment from 'moment';

const BRANCH = process.env.HEAD || process.env.VERCEL_GIT_COMMIT_REF || "main";
const CLIENT_ID = String(process.env.TINA_CLIENT_ID ?? '');
Expand All @@ -22,14 +23,73 @@ export default defineConfig({
},
schema: {
collections: [
{
format: "md",
label: "Articles",
name: "posts",
path: "_posts",
ui: {
defaultItem: {
date: moment(new Date()).format('YYYY-MM-DD'),
author: "La rédaction",
layout: "post",
},
filename: {
readOnly: true,
slugify: values => {
return `${values?.date?.substring(0, 10) ||
'xxxx'}-${values?.title?.toLowerCase().replace(/ /g, '-').normalize('NFD').replace(/[\u0300-\u036f]/g, "")}`
},
},
},
fields: [
{
label: 'Titre',
name: 'title',
type: 'string',
isTitle: true,
required: true,
},
{
label: "Date",
name: "date",
type: "datetime",
required: true,
},
{
label: "Image d'en-tête",
name: 'image',
type: 'image',
required: true,
},
{
label: 'Auteur',
name: 'author',
type: 'string',
required: true,
},
{
label: "Corps du document",
name: "body",
type: "rich-text",
description: "This is the markdown body",
isBody: true,
required: true,
},
{
label: 'Layout',
name: 'layout',
type: 'string',
required: true,
ui: { component: 'hidden' },
},
],
},
{
format: "md",
label: "Formules",
name: "formules",
path: "_formulas",
match: {
include: "**/*",
},
fields: [
{
type: "rich-text",
Expand Down
Loading

0 comments on commit 09b9aa5

Please sign in to comment.