Closed azappa closed 7 years ago
Got working, it not so a clean method but I can't do in other way...
In my pug template:
div.block-text!=slice.value.asHtml(ctx.linkResolver, (e, c) => { if (e.type === 'hyperlink') { return `<a href="/${(currentLang || defaultLang)}${e.url}">${c}</a>`; } return null; })
'Cleaner' methods are welcome!
@azappa You could simply have configured an HtmlSerializer somewhere and just put it in your prismicContext just like in this project : https://github.com/levimykel/html-serializer-example/blob/master/prismic-configuration.js#L22
I made a prismic repo with blog posts in two languages (EN, IT) so i duplicate fields like
and using
i18n-2
for routing passing a variable as language parameter. In my pug templates for posts how can i redirect linked posts to correct lang? At the moment I have something like this:My prismic.configuration.js got this fn as linkResolver
I know I can access to doc and ctx as parameters but I cannot pass other ones. Is there a way in route get fn where I can set into ctx a variable so I can use that value in my linkResolver fn?