0.0.53 • Published 1 year ago

@fasterfront/cms v0.0.53

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year 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.47

1 year ago

0.0.51

1 year ago

0.0.52

1 year ago

0.0.53

1 year ago

0.0.50

1 year ago

0.0.48

1 year ago

0.0.49

1 year ago

0.0.46

2 years ago

0.0.45

2 years ago

0.0.40

2 years ago

0.0.41

2 years ago

0.0.42

2 years ago

0.0.20

3 years ago

0.0.43

2 years ago

0.0.21

3 years ago

0.0.44

2 years ago

0.0.22

3 years ago

0.0.23

3 years ago

0.0.25

3 years ago

0.0.37

2 years ago

0.0.15

3 years ago

0.0.38

2 years ago

0.0.16

3 years ago

0.0.39

2 years ago

0.0.17

3 years ago

0.0.18

3 years ago

0.0.19

3 years ago

0.0.30

3 years ago

0.0.31

3 years ago

0.0.32

3 years ago

0.0.10

3 years ago

0.0.33

2 years ago

0.0.11

3 years ago

0.0.34

2 years ago

0.0.12

3 years ago

0.0.35

2 years ago

0.0.13

3 years ago

0.0.36

2 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.26

3 years ago

0.0.9

3 years ago

0.0.27

3 years ago

0.0.8

3 years ago

0.0.28

3 years ago

0.0.29

3 years ago

0.0.5

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.1

3 years ago