0.0.53 • Published 11 months ago

@fasterfront/cms v0.0.53

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

11 months ago

0.0.51

11 months ago

0.0.52

11 months ago

0.0.53

11 months ago

0.0.50

11 months ago

0.0.48

11 months ago

0.0.49

11 months ago

0.0.46

1 year ago

0.0.45

1 year ago

0.0.40

2 years ago

0.0.41

2 years ago

0.0.42

2 years ago

0.0.20

2 years ago

0.0.43

2 years ago

0.0.21

2 years ago

0.0.44

2 years ago

0.0.22

2 years ago

0.0.23

2 years ago

0.0.25

2 years ago

0.0.37

2 years ago

0.0.15

2 years ago

0.0.38

2 years ago

0.0.16

2 years ago

0.0.39

2 years ago

0.0.17

2 years ago

0.0.18

2 years ago

0.0.19

2 years ago

0.0.30

2 years ago

0.0.31

2 years ago

0.0.32

2 years ago

0.0.10

2 years ago

0.0.33

2 years ago

0.0.11

2 years ago

0.0.34

2 years ago

0.0.12

2 years ago

0.0.35

2 years ago

0.0.13

2 years ago

0.0.36

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.26

2 years ago

0.0.9

2 years ago

0.0.27

2 years ago

0.0.8

2 years ago

0.0.28

2 years ago

0.0.29

2 years ago

0.0.5

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.1

2 years ago