Skip to content

Commit

Permalink
#13 Added the rest of the config + some comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
krckyboy committed Mar 18, 2024
1 parent 39a7bc2 commit 59096c4
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 52 deletions.
9 changes: 9 additions & 0 deletions cms-ts/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions cms-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
"build": "strapi build",
"strapi": "strapi"
},
"devDependencies": {},
"dependencies": {
"@strapi/strapi": "4.20.5",
"@strapi/plugin-users-permissions": "4.20.5",
"@strapi/plugin-i18n": "4.20.5",
"@strapi/plugin-cloud": "4.20.5",
"@strapi/plugin-i18n": "4.20.5",
"@strapi/plugin-users-permissions": "4.20.5",
"@strapi/strapi": "4.20.5",
"pg": "8.8.0",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-router-dom": "5.3.4",
"slugify": "^1.6.6",
"styled-components": "5.3.3"
},
"author": {
Expand Down
18 changes: 18 additions & 0 deletions cms-ts/src/api/post/content-types/post/lifecycles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const slugify = require('slugify');

module.exports = {
beforeCreate(event) {
const { data } = event.params;

if (data.title) {
data.slug = slugify(data.title, { lower: true });
}
},
beforeUpdate(event) {
const { data } = event.params;

if (data.title) {
data.slug = slugify(data.title, { lower: true });
}
}
};
96 changes: 48 additions & 48 deletions cms-ts/types/generated/contentTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,53 @@ export interface PluginContentReleasesReleaseAction
};
}

export interface PluginI18NLocale extends Schema.CollectionType {
collectionName: 'i18n_locale';
info: {
singularName: 'locale';
pluralName: 'locales';
collectionName: 'locales';
displayName: 'Locale';
description: '';
};
options: {
draftAndPublish: false;
};
pluginOptions: {
'content-manager': {
visible: false;
};
'content-type-builder': {
visible: false;
};
};
attributes: {
name: Attribute.String &
Attribute.SetMinMax<
{
min: 1;
max: 50;
},
number
>;
code: Attribute.String & Attribute.Unique;
createdAt: Attribute.DateTime;
updatedAt: Attribute.DateTime;
createdBy: Attribute.Relation<
'plugin::i18n.locale',
'oneToOne',
'admin::user'
> &
Attribute.Private;
updatedBy: Attribute.Relation<
'plugin::i18n.locale',
'oneToOne',
'admin::user'
> &
Attribute.Private;
};
}

export interface PluginUsersPermissionsPermission
extends Schema.CollectionType {
collectionName: 'up_permissions';
Expand Down Expand Up @@ -741,53 +788,6 @@ export interface PluginUsersPermissionsUser extends Schema.CollectionType {
};
}

export interface PluginI18NLocale extends Schema.CollectionType {
collectionName: 'i18n_locale';
info: {
singularName: 'locale';
pluralName: 'locales';
collectionName: 'locales';
displayName: 'Locale';
description: '';
};
options: {
draftAndPublish: false;
};
pluginOptions: {
'content-manager': {
visible: false;
};
'content-type-builder': {
visible: false;
};
};
attributes: {
name: Attribute.String &
Attribute.SetMinMax<
{
min: 1;
max: 50;
},
number
>;
code: Attribute.String & Attribute.Unique;
createdAt: Attribute.DateTime;
updatedAt: Attribute.DateTime;
createdBy: Attribute.Relation<
'plugin::i18n.locale',
'oneToOne',
'admin::user'
> &
Attribute.Private;
updatedBy: Attribute.Relation<
'plugin::i18n.locale',
'oneToOne',
'admin::user'
> &
Attribute.Private;
};
}

export interface ApiCategoryCategory extends Schema.CollectionType {
collectionName: 'categories';
info: {
Expand Down Expand Up @@ -889,10 +889,10 @@ declare module '@strapi/types' {
'plugin::upload.folder': PluginUploadFolder;
'plugin::content-releases.release': PluginContentReleasesRelease;
'plugin::content-releases.release-action': PluginContentReleasesReleaseAction;
'plugin::i18n.locale': PluginI18NLocale;
'plugin::users-permissions.permission': PluginUsersPermissionsPermission;
'plugin::users-permissions.role': PluginUsersPermissionsRole;
'plugin::users-permissions.user': PluginUsersPermissionsUser;
'plugin::i18n.locale': PluginI18NLocale;
'api::category.category': ApiCategoryCategory;
'api::post.post': ApiPostPost;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ interface Props {
markdown: string;
}

// Note: You can add a title to a part of code in MD like this: ```tsx:index.ts and this way you cover both the extension and file name.
const BlogContent: FunctionComponent<Props> = async ({ markdown }) => {
return (
<section className={`blog-content ${gStyles.text} ${sharedStyles.shared}`}>
Expand Down

0 comments on commit 59096c4

Please sign in to comment.