Code Monkey home page Code Monkey logo

strapi-plugin-permalinks's People

Contributors

mattmilburn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

strapi-plugin-permalinks's Issues

Store formatted permalink in database

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?

Permalink field remains empty

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.

Relation field not working correctly

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)

Screenshot from 2023-08-29 12-11-44

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?

Internationalization bug

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.

  1. Default language
    image
  2. changed to EN language
    image
  3. refreshed the page on the EN language to "fix" the issue
    image

How to reproduce:

  1. create a page with a slug
  2. add one different language and configure the slug too
  3. refresh the page on the default language
  4. change the language on the right sidebar

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!

Does not work after installation

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!

GraphQL support

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.

Error when populating localizations

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

Response is transformed incorrectly

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
        }
    }
}

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.