mattmilburn / strapi-plugin-permalinks Goto Github PK
View Code? Open in Web Editor NEWA plugin for Strapi CMS to enable a URL path field for content types with nested relationships.
License: MIT License
A plugin for Strapi CMS to enable a URL path field for content types with nested relationships.
License: MIT License
I was wondering if it is possible to store the already formatted permalink in the database? For example page-1/page-2
instead of page-1~page-2
?
This will allow GraphQL users to access the formatted permalink in their queries, but also the use of the permalink value outside the API, for example in other custom fields.
Are there any limitations to this change and what is your opinion on this?
I would expect to able to set the same name for the link for other locales.
Current behavior:
slug
- "contact". with default EN locale.slug
to - "contact" - error - unavailable.Hey there,
The permalink field doesn't update with the value of the targetField
nor the targetRelation
, it remains empty even when pressing the refresh button.
I have exactly the same configuration as provided in the documentation, and the problem occurs on Strapi 4.6.0 and 4.7.1 when --watch-admin
mode is not enabled.
I'm receiving this error when I try to save a content.
TypeError: Cannot destructure property 'name' of '(intermediate value)' as it is null.
at Object.validateConnection (/home/alexander/Documents/zeus/cns-strapi/node_modules/strapi-plugin-permalinks/server/services/validation.js:53:19)
here's my schema.json
{
"kind": "collectionType",
"collectionName": "sub_hubs",
"info": {
"singularName": "sub-hub",
"pluralName": "sub-hubs",
"displayName": "Sub Hubs",
"description": ""
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"title": {
"type": "string",
"required": true,
"unique": true
},
"parentHub": {
"type": "relation",
"relation": "oneToOne",
"target": "api::hub.hub"
},
"slug": {
"type": "customField",
"required": true,
"customField": "plugin::permalinks.permalink",
"pluginOptions": {
"permalinks": {
"targetField": "title",
"targetRelation": "parentHub"
}
}
}
}
}
Plugin Configuration
permalinks: {
config: {
contentTypes: [
{
uids: ["api::sub-hub.sub-hub"],
url: `${env("SITE_DOMAIN")}/compare/{slug}`,
},
],
},
},
Strapi version: 4.12.7
Strapi Permalink plugin version: 2.0.1
Am I missing something?
Hi @mattmilburn :)
I've found a bug with your plugin and Internationalization. After I change the language in edit mode, the slug does not change.
How to reproduce:
I think you do not have a dependency that takes the language switch into account. Check your dependency arrays in useEffect etc.
I hope we can fix this ASAP :)
BTW. if you don't mind, hit me up on email: [email protected]
Would love to have a small conversation :)
Thanks for the plugin!
Hello!!
I have installed the plugin but I do not see the custom field on the custom field tab!
Is some else I should to in order to use it.
I am new to strapi so maybe something i miss.
Thank you!
@mattmilburn I would expect to get parent-page/child-page instead of parent-page~child-page, is there a quick fix for this?
Hi there,
Firstly, I want to say thank you for creating such a useful plugin. It has been incredibly helpful for me and I appreciate the time and effort that went into its creation.
I did have a question though - do you have any plans to add GraphQL support to the plugin in the future? I think it would be a great addition.
Thank you for your time and consideration, and again, thank you for creating such a valuable plugin.
When requesting pages with localizations (e.g. /api/pages?populate=localizations
), I get the following error:
error: data.localizations.map is not a function
TypeError: data.localizations.map is not a function
at transform (/node_modules/strapi-plugin-permalinks/server/middlewares/transform-api-response.js:48:47)
at transform (/node_modules/strapi-plugin-permalinks/server/middlewares/transform-api-response.js:33:14)
at /node_modules/strapi-plugin-permalinks/server/middlewares/transform-api-response.js:41:34
at Array.map (<anonymous>)
at transform (/node_modules/strapi-plugin-permalinks/server/middlewares/transform-api-response.js:41:21)
at /node_modules/strapi-plugin-permalinks/server/middlewares/transform-api-response.js:90:21
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async /node_modules/@strapi/strapi/lib/middlewares/body.js:58:9
at async /node_modules/@strapi/strapi/lib/middlewares/logger.js:9:5
at async /node_modules/@strapi/strapi/lib/middlewares/powered-by.js:16:5
This should fix the issue:
if ( has( data, 'localizations' ) ) {
data.localizations.data = data.localizations.data.map( entry => transform( entry, uid, config ) );
}
Strapi-Version: 4.8.2
Plugin-Version: 1.0.3
The plugin middleware removes the entity ids from the response:
Expected:
{
"data": [
{
"id": 1,
"attributes": {
"title": "Title",
"createdAt": "2021-01-17T12:24:43.962Z",
"updatedAt": "2021-01-30T21:04:57.263Z",
"publishedAt": "2021-01-17T12:31:12.569Z",
"locale": "de",
"permalink": "title"
}
},
{
"id": 2,
"attributes": {
"title": "Title 2",
"createdAt": "2021-01-17T12:24:43.962Z",
"updatedAt": "2021-01-30T21:04:57.263Z",
"publishedAt": "2021-01-17T12:31:12.569Z",
"locale": "de",
"permalink": "title-2"
}
},
],
"meta": {
"pagination": {
"page": 1,
"pageSize": 25,
"pageCount": 1,
"total": 2
}
}
}
How it gets transformed by the plugin:
{
"data": [
{
"attributes": {
"title": "Title",
"createdAt": "2021-01-17T12:24:43.962Z",
"updatedAt": "2021-01-30T21:04:57.263Z",
"publishedAt": "2021-01-17T12:31:12.569Z",
"locale": "de",
"permalink": "title"
}
},
{
"attributes": {
"title": "Title 2",
"createdAt": "2021-01-17T12:24:43.962Z",
"updatedAt": "2021-01-30T21:04:57.263Z",
"publishedAt": "2021-01-17T12:31:12.569Z",
"locale": "de",
"permalink": "title-2"
}
},
],
"meta": {
"pagination": {
"page": 1,
"pageSize": 25,
"pageCount": 1,
"total": 2
}
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.