
Security News
Package Maintainers Call for Improvements to GitHub’s New npm Security Plan
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
@stnew/prismic
Advanced tools
This package exports:
urlResolver
- A helper function to create link resolvers.The urlResolver
function will help Prismic and (optionally) Next.js resolve the correct prismic documents when you wire up links.
Inside each function is a hash map. The key is the API ID of your Prismic "Single" or "Repeatable" type.
Each route contains up to three keys:
href
: The URL of the page that will resolve to when passed to our Link
componentpage
: (optional): The Next.js page to resolve to. Only neccessary if you're using hrefResolver
or PrismicLink
root
: (optional): The uid
of the index page from Prismic"Single" types, will resolve directly to href
. "Repeatable" types resolve to a the href
+ the uid
field, and you can use the root
field in conjuction with that to filter out the root uid
, so that your URLs are clean.
The urlResolver
function will return two more functions.
linkResolver
will resolve the url as you would see it in the address bar, such as /about-us
or /blog/hello-world
.
hrefResolver
is for only for next/link
components to resolve the correct route, such as /[page]
or /blog/[...post]
. If you're not using Next.js don't worry about it.
import { urlResolver } from '@sntew/prismic'
const routeMap = {
home_page: {
href: '/',
page: '/',
},
about_page: {
href: '/about',
page: '/about',
}
privacy_page: {
href: '/privacy',
page: '/privacy/[[...uid]]',
root: 'privacy-policy'
}
}
export const { linkResolver, hrefResolver} = urlResolver(routeMap)
import NextLink from 'next/link'
import { linkResolver, hrefResolver } from './resolvers.js'
function NavLink({ href, label }) {
return (
<NextLink as={linkResolver(href)} href={hrefResolver(href)}>
<a>{label}</a>
</NextLink>
)
}
The @stnew/prismic-react package has a Context/Provider pattern, as well as a hook for accessing the linkResolver in any component.
FAQs
Prismic components and utilities for React
We found that @stnew/prismic demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.