You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I, unfortunately, failed to create a PR, the repo seems to require permission to push a new branch for me. But nevertheless, here is the problem description and my proposed solution:
Problem: getCanonicalPageId does not support non-latin page titles
As deployed the project to Vercel, I realized that there were quite a few browser warnings about the page due to generated page URLs (they looked broken).
the page behind it:
moreover, this page also had the same URL generated /- despite being a separate page, and clicking on it would lead to the first page.
import{ExtendedRecordMap}from'notion-types'import{getCanonicalPageIdasgetCanonicalPageIdImpl,parsePageId}from'notion-utils'import{inversePageUrlOverrides}from'./config'exportfunctiongetCanonicalPageId(pageId: string,recordMap: ExtendedRecordMap,{ uuid =true}: {uuid?: boolean}={}): string|null{const cleanPageId =parsePageId(pageId,{uuid: false})if(!cleanPageId){
return null}constoverride=inversePageUrlOverrides[cleanPageId]if(override){return override
}else{// PROBLEM: this line seemed to be the issuereturngetCanonicalPageIdImpl(pageId,recordMap,{
uuid
})}}
I pulled the normalizeTitle function, and yes, it seems to be the case
functionnormalizeTitle(title){return(title||'').replace(//g,'-').replace(/[^a-zA-Z0-9-\u4e00-\u9fa5]/g,'').replace(/--/g,'-').replace(/-$/,'').replace(/^-/,'').trim().toLowerCase()}consteng=normalizeTitle('Naapurin Maalaiskana (NMK), in Lieto, in Turku area');constukr=normalizeTitle('Робота помічника з обслуговування контейнерів');constukr1=normalizeTitle('Ищем литейщиков в Карккила, Финляндия, для обработки изделий в металлургической промышленности');console.log('test',eng,ukr,ukr1)// "test"// "naapurin-maalaiskana-nmk-in-lieto-in-turku-area"// ""// "---"
Solution:
The one that worked for me was just replacing normalizeTitle(getBlockTitle(block, recordMap)) with slugify from the transliteration npm package.
Notion Test Page ID
701245d6db8c413689d180e87269ee56
The text was updated successfully, but these errors were encountered:
Description
I, unfortunately, failed to create a PR, the repo seems to require permission to push a new branch for me. But nevertheless, here is the problem description and my proposed solution:
Problem: getCanonicalPageId does not support non-latin page titles
Issue:
I am using [Notion.so](http://Notion.so) to run [FinUA.org](http://FinUA.org) website and currently it isb deployed with [super.so](http://super.so). I have been using nextjs-notion-starter-kit project for it (thank you).
As deployed the project to Vercel, I realized that there were quite a few browser warnings about the page due to generated page URLs (they looked broken).
the page behind it:
moreover, this page also had the same URL generated
/-
despite being a separate page, and clicking on it would lead to the first page.I have investigated it, and it seems that the problem was in the module https://github.com/transitive-bullshit/nextjs-notion-starter-kit/blob/main/lib/get-canonical-page-id.ts
I went to the module https://github.com/NotionX/react-notion-x/tree/master/packages/notion-utils
and copied https://github.com/NotionX/react-notion-x/blob/master/packages/notion-utils/src/get-canonical-page-id.ts module, the problem seemed to be
getCanonicalPageId
function, it only seemed to work for Latin symbolsnormalizeTitle(getBlockTitle(block, recordMap))
:I pulled the
normalizeTitle
function, and yes, it seems to be the caseSolution:
The one that worked for me was just replacing
normalizeTitle(getBlockTitle(block, recordMap))
withslugify
from the transliteration npm package.Notion Test Page ID
701245d6db8c413689d180e87269ee56
The text was updated successfully, but these errors were encountered: