Coder Social home page Coder Social logo

morrisonak / remix-blog-mongodb Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kiliman/remix-blog-mongodb

0.0 0.0 0.0 182 KB

Remix example that updates the blog tutorial to use MongoDB and Quill

License: MIT License

Shell 0.38% JavaScript 91.58% TypeScript 6.48% CSS 1.56%

remix-blog-mongodb's Introduction

Remix Blog Example with Mongoose and Quill

This example updates the Remix Blog tutorial to use Mongoose for connecting to the MongoDB database and Quill.js for a rich text editor.

๐Ÿ›  Setup

Copy the .env file from .env.example and set the MONGODB_URL to the location of your MongoDB database.

๐Ÿฆก Mongoose

The mongoose connection is initialized in app/services/db.server.js. Since the connection is a singleton, we connect in module scope and store the reference to ensure we only connect once.

All access to posts are done throught the app/services/post.server.js file. This file defines the schema and initializes the mongoose model for Post.

It also includes function to get all posts, find a post by slug, and create a new post or update an existing one.

By defining these filenames with the *.server.js suffix, it ensures that Remix will not include any of the code in the client bundle.

๐Ÿ–‹ Quill

Quill is a client only component, so we export that from app/components/quill.client.js. It has the *.client.js suffix so it will not be included in the server bundle. We also use the <ClientOnly/> component to ensure this component does not render on the server. Instead it displays the fallback component.

There are two props that should be passed in. One is the name of the input. This is used to create the <input type="hidden"> component used for the form POST.

It also includes defaultValue which is used to set the initial editor contents which are used when editing the post.

There is a 'text-change' handler that synchronizes the content of the editor with the hidden input.

remix-blog-mongodb's People

Contributors

kiliman avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.