@kon10/slug
v1.0.3
Published
Kon10 slug plugin — template-based slug field with uniqueness and Studio UX.
Downloads
206
Maintainers
Readme
@kon10/slug
Template-based slug field plugin for Kon10. It provides a slug() field builder, server-side field registration, slug/path normalization, uniqueness hooks, nested path support, and a Studio field renderer.
Install
pnpm add @kon10/slugWhen to use this package
Use @kon10/slug when collections need editor-friendly URL segments or nested paths derived from fields such as title, date, or parent records.
Public API
slugPlugin()to register the field type and hooks.slug()field builder for content models.slugify(),slugifyPath(), and template helpers for custom workflows.@kon10/slug/studiofor the Studio renderer.
Example
import { defineConfig, text } from '@kon10/core'
import { Collection, ContentModule } from '@kon10/content'
import { slug, slugPlugin } from '@kon10/slug'
export default defineConfig({
plugins: [slugPlugin()],
modules: [
ContentModule({
entities: [
Collection({
slug: 'posts',
fields: {
title: text({ required: true }),
slug: slug({ from: '{title}' }),
},
}),
],
}),
],
})Operational notes
- Register
slugPlugin()once in the Kon10 config before usingslug()fields. - Server-side validation enforces the path pattern; client-side validation intentionally falls back for plugin field types.
- Use nested slug options when page paths must cascade from parent records.
