Block library: 15 blocks, registry, primitives, templates, manifest, eject
- @intecion/ipal-kit/blocks: libraryBlocks() opt-in, one builder per block, field
builders, option merging, blockLibraryManifest, faqItemsFromLayout
- @intecion/ipal-kit/blocks/rsc: createBlockRegistry, the block components and UI
primitives (token utilities only; next/image and next/link passed in)
- @intecion/ipal-kit/templates: 10 page templates as createSeeder data
- createSeeder: { $form: title } references
- ipal-blocks eject <block>
- tests: options, rendering and a11y per block, Payload + seeding, GraphQL, admin
wording, schema snapshot (versioning), eject imports
- shorter admin labels: link "New tab", table of contents "Show contents"
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
7918eaf6d4
commit
2d1cc0e77d
@@ -0,0 +1,40 @@
|
||||
import type { ReactNode } from 'react'
|
||||
|
||||
import type { ResolvedLink } from '../../links/resolveNav.js'
|
||||
import type { LinkData } from '../data.js'
|
||||
import type { LinkComponent } from './Anchor.js'
|
||||
|
||||
import { Anchor } from './Anchor.js'
|
||||
import { buttonClass as defaultButtonClass } from './Button.js'
|
||||
import { cx } from './cx.js'
|
||||
|
||||
export type ResolveLink = (link: LinkData, locale: string) => null | Promise<null | ResolvedLink> | ResolvedLink
|
||||
|
||||
export type CMSLinkProps = {
|
||||
/** For a link that wraps something (a card, an image): the content instead of the label. */
|
||||
children?: ReactNode
|
||||
className?: string
|
||||
link: LinkData
|
||||
locale: string
|
||||
}
|
||||
|
||||
/** The plugin's link: `resolve` (lib/content `resolveLink`), `buttonClass` and `Link` (next/link) are bound by createBlockRegistry. */
|
||||
export async function CMSLink({
|
||||
buttonClass = defaultButtonClass,
|
||||
children,
|
||||
className,
|
||||
link,
|
||||
Link,
|
||||
locale,
|
||||
resolve,
|
||||
}: { buttonClass?: (appearance?: null | string) => string; Link?: LinkComponent; resolve: ResolveLink } & CMSLinkProps) {
|
||||
const l = await resolve(link, locale)
|
||||
const content = children ?? l?.label
|
||||
if (!l || !content) {return null}
|
||||
const cls = cx(buttonClass(l.appearance), className) || undefined
|
||||
return (
|
||||
<Anchor className={cls} href={l.href} internal={l.internal} Link={Link} targetProps={l.targetProps}>
|
||||
{content}
|
||||
</Anchor>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user