Skip to content

Instantly share code, notes, and snippets.

View ComfortablyCoding's full-sized avatar
💻

daedalus ComfortablyCoding

💻
View GitHub Profile
@ComfortablyCoding
ComfortablyCoding / strapi-plugin-docs-v4.md
Created June 7, 2022 06:27
Unofficial docs for Strapi plugins, to be used as a quick reference and not a docs replacement

Create a plugin

  1. Navigate to the root of the strapi project
  2. Run strapi generate
  3. Select plugin
  4. Add the requested data

The Admin is the frontend part of your plugin. All of its code will be locate in the admin/ folder located within the plugin.

Lifecycle Functions

@ComfortablyCoding
ComfortablyCoding / findOne-by-slug-strapi-v4.md
Last active May 2, 2022 22:07
A sample implementaion of replacing a CT findOne controller to work with a slug instead of an id for Strapi v4

Implementing findOne by slug

Create the content type

For this example we will be using the article collection content type defined below for the implementation

path: /strapi-project/src/api/article/content-types/article/schema.json
@ComfortablyCoding
ComfortablyCoding / strapi-get-attribute.js
Created March 22, 2022 05:25
Helper function for obtaining a data attribute without the need to go through additional context
"use strict";
/**
* Get the value following the `path` for the provided object.
* Returns undefined if not found unless a default value is provided
*
* @param {Object} object The object to check
* @param {Array|String} path The path to the object attribute
* @param {any} defaultValue The value to return instead of undefined.
* @returns {any} The resolved value
@ComfortablyCoding
ComfortablyCoding / strapi-upgrade-best-practice.md
Created March 22, 2022 05:23
Strapi v4 upgrade best practice

Best Practices for updating Strapi

  • the official strapi plugins and the strapi version should match.
  • before install delete the lock file.
  • after install do a clean rebuild of the admin (remove the .cache and build folders)
@ComfortablyCoding
ComfortablyCoding / strapi-plugin-troubleshooting.md
Created March 22, 2022 04:49
Strapi v4 Plugin Troubleshooting

Plugin Troubleshooting

Below are common solutions regarding issues with plugins

Settings are not being applied

The "path" argument must be of type string. Received undefined

@ComfortablyCoding
ComfortablyCoding / strapi-ct-troubleshooting.md
Last active July 11, 2022 15:21
Strapi v4 Content Type Troubleshooting

Content Type Troubleshooting

Below are common issues regarding content types and their possible solutions.

I have created a content type but receiving a 404 Not Found response

Ensure you are using the correct endpoint tense

  • Collection endpoints use their plural name. e.g. /api/posts
  • Single types use the singular name. e.g. /api/homepage

Ensure single content type is published

For single content types if draftAndPublish is enabled the response will return a 404 Not Found if the entity is not published.