0.0.46 • Published 3 months ago

@fasterfront/cms v0.0.46

Weekly downloads
-
License
MIT
Repository
-
Last release
3 months ago

Faster Front CMS

Type-safe Remix loader for pages built in Faster Front's CMS.

Installation

pnpm add @fasterfront/cms

Usage

For generating the types according to the latest version of your DB:

pnpm ff

You can also add this directly to your dev script on package.json eg:

{
  "scripts": {
    "dev": "ff && remix dev"
  }
}

Let's suppose you have a /team route on your Remix application that looks like this:

{
  "en-US": {
    "meta": {
      "title": "Team",
      "description": "Learn more about Faster Front team!"
    },
    "team": {
      "type": "list",
      "value": {
        "entity": "member",
        "fields": ["id", "fullName", "avatar", "bio"],
        "sortOrder": {
          "property": "fullName",
          "direction": "asc"
        }
      }
    }
  }
}

The member entity looks like this:

type Member = {
  // CMS: Primary key (could be used for creating a /team/:id route)
  id: string
  // CMS Type: Text
  fullName: string
  // CMS Type: Image
  avatar: {
    alt: string
    src: string
    srcSet: string
    sizes: string
  }
  // CMS Type: RichText
  bio: string
}

On routes/_layout/team/index.tsx, you can just use usePageData for getting the data (fully typed!):

import { usePageData } from '@fasterfront/cms'
import Image from '@fasterfront/image'

export { pageMeta as meta } from '@fasterfront/cms'
export { pageLoader as loader } from '@fasterfront/cms/loaders.server'

type Path = '/team'

export default function Team() {
  const { meta, team } = usePageData<Path>()

  return (
    <section>
      <h1>{meta.title}</h1>
      <p>{meta.description}</p>
      <ul>
        {team.map((member) => (
          <li key={member.id}>
            <div>
              <Image data={member.avatar} />
              <span>{member.fullName}</span>
            </div>
            <div dangerouslySetInnerHTML={{ __html: member.bio }} />
          </li>
        ))}
      </ul>
    </section>
  )
}

That's it! Simple and fun!

0.0.46

3 months ago

0.0.45

3 months ago

0.0.40

6 months ago

0.0.41

6 months ago

0.0.42

6 months ago

0.0.20

1 year ago

0.0.43

6 months ago

0.0.21

1 year ago

0.0.44

6 months ago

0.0.22

1 year ago

0.0.23

1 year ago

0.0.25

1 year ago

0.0.37

6 months ago

0.0.15

1 year ago

0.0.38

6 months ago

0.0.16

1 year ago

0.0.39

6 months ago

0.0.17

1 year ago

0.0.18

1 year ago

0.0.19

1 year ago

0.0.30

1 year ago

0.0.31

1 year ago

0.0.32

1 year ago

0.0.10

1 year ago

0.0.33

7 months ago

0.0.11

1 year ago

0.0.34

6 months ago

0.0.12

1 year ago

0.0.35

6 months ago

0.0.13

1 year ago

0.0.36

6 months ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.26

1 year ago

0.0.9

1 year ago

0.0.27

1 year ago

0.0.8

1 year ago

0.0.28

1 year ago

0.0.29

1 year ago

0.0.5

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.1

1 year ago