-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[v3] set default
head
option as null
in nextra-theme-docs
and i…
…mprove bundle size (#2270)
- Loading branch information
Dimitri POSTOLOV
authored
Sep 7, 2023
1 parent
b9f88e3
commit c77485e
Showing
11 changed files
with
105 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'nextra-theme-docs': minor | ||
--- | ||
|
||
set default `head` option as `null` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import title from 'title' | ||
import type { Folder, MdxFile } from '../types' | ||
|
||
export const logger = { | ||
info: console.log.bind(null, '-', '\x1b[36minfo\x1b[0m', '[nextra]'), | ||
warn: console.log.bind(null, '-', '\x1b[33mwarn\x1b[0m', '[nextra]'), | ||
error: console.log.bind(null, '-', '\x1b[31merror\x1b[0m', '[nextra]') | ||
} | ||
|
||
export function pageTitleFromFilename(fileName: string) { | ||
return title(fileName.replaceAll(/[-_]/g, ' ')) | ||
} | ||
|
||
export function sortPages( | ||
pages: (Omit<MdxFile, 'route'> | Omit<Folder, 'route' | 'children'>)[], | ||
locale?: string | ||
): [string, string][] { | ||
return pages | ||
.map(item => ({ | ||
name: item.name, | ||
date: 'frontMatter' in item && item.frontMatter?.date, | ||
title: | ||
('frontMatter' in item && item.frontMatter?.title) || | ||
pageTitleFromFilename(item.name) | ||
})) | ||
.sort((a, b) => { | ||
if (a.date && b.date) { | ||
return new Date(b.date).getTime() - new Date(a.date).getTime() | ||
} | ||
if (a.date) { | ||
return -1 // sort a before b | ||
} | ||
if (b.date) { | ||
return 1 // sort a after b | ||
} | ||
return a.title.localeCompare(b.title, locale || undefined, { | ||
numeric: true | ||
}) | ||
}) | ||
.map(item => [item.name, item.title]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters