Skip to content

Support for normalize chinese title #176

@vv13

Description

@vv13

When I execuse building script, I got some Collecting page data like this:

info  - Collecting page data ...[
  { params: { pageId: '500' } },
  { params: { pageId: '31cc504c078a4d23843fb9d0ae69c590' } },
]

and it throw some strange error:

> Build error occurred
[Error: ENOENT: no such file or directory, rename '/Users/xxx/nextjs-notion-starter-kit/.next/export/500.html' -> '/Users/xxx/nextjs-notion-starter-kit/.next/server/pages/500.html'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'rename',
  path: '/Users/xxx/nextjs-notion-starter-kit/.next/export/500.html',
  dest: '/Users/xxx/nextjs-notion-starter-kit/.next/server/pages/500.html'
}

In notion-utils package, I found in src/get-canonical-page-id.ts , It including the function:

export const normalizeTitle = (title: string | null): string => {
  return (title || '')
    .replace(/ /g, '-')
    .replace(/[^a-zA-Z0-9-]/g, '')
    .replace(/--/g, '-')
    .replace(/-$/, '')
    .replace(/^-/, '')
    .trim()
    .toLowerCase()
}

Because of this, it converting my pageId from rawPageTitle 星空 500 法则 to 500.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions