Skip to content

Proposals on formation Title and Slug for StaticPage. #2

@InfDev

Description

@InfDev

Sample implementation to remove restrictions:

  • Slug in English only
  • Sequence number only 2 digits

Class SlugService taken from the project OrchardCore

        private IList<StaticPage> GetStructureItemsRecursive(StaticSitemap structure, string path, string prefix = "")
        {
            var items = new List<StaticPage>();
            var slugService = new SlugService();
            foreach (var info in GetDirectoryItems(path))
            {
                if (info.Name != "Index.md")
                {
                    var title = info is DirectoryInfo ? info.Name : Path.GetFileNameWithoutExtension(info.Name);
                    var indexSpace = title.IndexOf(' ');
                    if (indexSpace >= 0)
                        title = title.Substring(indexSpace + 1);
                    var slug = slugService.Slugify(title);
                    var item = new StaticPage
                    {
                        Title = title, // Utils.GenerateTitle(info),
                        Slug = prefix + slug, // Utils.GenerateSlug(info),
                        Path = info.FullName,
                        Created = info.CreationTime,
                        LastModified = info.LastWriteTime
                    };
				}
				// ...
			}
			// ...
		}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions