nextbox/neos-urlshortener

NextBox Neos 网址缩短器

1.1.0 2023-04-12 08:01 UTC

This package is auto-updated.

Last update: 2024-09-12 10:57:52 UTC


README

此包为 Neos 提供网址缩短功能。

配置

默认

将以下混入添加到您的文档节点类型中: NextBox.Neos.UrlShortener:Identifier

创建一个新的 Routes.yaml,内容如下

# Configuration/Routes.yaml

-
  name: 'Redirect for default'
  uriPattern: 'short/{shortIdentifier}' # replace `short` with your preferences
  defaults:
    '@package': 'NextBox.Neos.UrlShortener'
    '@controller': 'Redirect'
    '@action': 'redirectToPage'
    'shortType': 'default' # if you are using the default Mixin then do not change this line
  appendExceedingArguments: false
  httpMethods: ['GET']

可扩展性

如果您希望网址缩短有不同的路径名,可以创建自己的配置。

  1. 创建混入或使用现有的节点类型
# Configuration/NodeTypes.UrlIdentifier.yaml

'Foo.Bar:ProductIdentifier': # change with your name
  abstract: true
  superTypes:
    'NextBox.Neos.UrlShortener:BaseIdentifier': true
  properties:
    productId: # you can change the property name individually
      type: string
      ui:
        label: 'URL Short Identifier'
        reloadIfChanged: true
        inspector:
          group: 'document'
  1. 创建设置
# Configuration/Settings.yaml

NextBox:
  Neos:
    UrlShortener:
      shortTypes:
        'product': # change the name of the type
          nodeType: 'Foo.Bar:ProductIdentifier' # change the NodeType name to the new created Mixin or to the existing NodeType
          property: 'productId' # the property name of the identification - this field must be globally unique for the used Mixin
          rootNodePath: '/sites/siteOne' # optional, the base path for the Flow Query to search for the nodes 
  1. 创建路由
# Configuration/Routes.yaml

-
  name: 'Redirect for product'
  uriPattern: 'product/{shortIdentifier}' # do not change `shortIdentifier`, just change the path for your preferences
  defaults:
    '@package': 'NextBox.Neos.UrlShortener'
    '@controller': 'Redirect'
    '@action': 'redirectToPage'
    'shortType': 'product' # change this to the name of the type from the settings
  appendExceedingArguments: false
  httpMethods: ['GET']