Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(nextra): allow to contain dots in page filenames (#546)
* fix(nextra): allow to contain dots in page filenames * add changeset
- Loading branch information
1 parent
4a7cc10
commit efd95ec
Showing
24 changed files
with
216 additions
and
87 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': patch | ||
--- | ||
|
||
fix(nextra): allow to contain dots in page filenames |
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
1 change: 1 addition & 0 deletions
1
examples/swr-site/pages/docs/advanced/file-name.with.DOTS.en-US.mdx
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 @@ | ||
# You can add dots in your file names |
1 change: 1 addition & 0 deletions
1
examples/swr-site/pages/docs/advanced/file-name.with.DOTS.es-ES.mdx
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 @@ | ||
# Puede agregar puntos en los nombres de sus archivos |
1 change: 1 addition & 0 deletions
1
examples/swr-site/pages/docs/advanced/file-name.with.DOTS.ja.mdx
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 @@ | ||
# ファイル名にドットを追加できます |
1 change: 1 addition & 0 deletions
1
examples/swr-site/pages/docs/advanced/file-name.with.DOTS.ko.mdx
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 @@ | ||
# 파일 이름에 점을 추가할 수 있습니다. |
1 change: 1 addition & 0 deletions
1
examples/swr-site/pages/docs/advanced/file-name.with.DOTS.ru.mdx
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 @@ | ||
# Вы можете добавить точки в имя своих файлов |
1 change: 1 addition & 0 deletions
1
examples/swr-site/pages/docs/advanced/file-name.with.DOTS.zh-CN.mdx
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 @@ | ||
# 您可以在文件名中添加点 |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"cache": "Cache", | ||
"performance": "Rendimiento", | ||
"react-native": "React Native" | ||
"react-native": "React Native", | ||
"file-name.with.DOTS": "Nombres de archivos con puntos" | ||
} |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"cache": "キャッシュ", | ||
"performance": "パフォーマンス", | ||
"react-native": "React Native" | ||
"react-native": "React Native", | ||
"file-name.with.DOTS": "ドット付きのファイル名" | ||
} |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"cache": "캐시", | ||
"performance": "성능", | ||
"react-native": "React Native" | ||
"react-native": "React Native", | ||
"file-name.with.DOTS": "점이 있는 파일 이름" | ||
} |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"cache": "Кеш", | ||
"performance": "Производительность", | ||
"react-native": "React Native" | ||
"react-native": "React Native", | ||
"file-name.with.DOTS": "Имя файла может содержать точки" | ||
} |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"cache": "缓存", | ||
"performance": "性能", | ||
"react-native": "React Native" | ||
"react-native": "React Native", | ||
"file-name.with.DOTS": "带点的文件名" | ||
} |
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
File renamed without changes.
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,108 @@ | ||
import { describe, it, expect } from 'vitest' | ||
import { parseFileName } from '../src/utils' | ||
|
||
describe('Utils', () => { | ||
describe('parseFileName()', () => { | ||
describe('extension', () => { | ||
it('parse different extensions', () => { | ||
expect(parseFileName('./foo.bar.baz-qux.zh-CN.js')).toEqual({ | ||
name: 'foo.bar.baz-qux', | ||
locale: 'zh-CN', | ||
ext: '.js' | ||
}) | ||
expect(parseFileName('MY_FOLDER/foo.bar.qux.mtsx')).toEqual({ | ||
name: 'foo.bar.qux', | ||
locale: '', | ||
ext: '.mtsx' | ||
}) | ||
expect(parseFileName('docs-folder/foo.bar.ba-qu.zh-CN.json5')).toEqual({ | ||
name: 'foo.bar.ba-qu', | ||
locale: 'zh-CN', | ||
ext: '.json5' | ||
}) | ||
expect(parseFileName('hello/foo.bar.ba-qu.txt')).toEqual({ | ||
name: 'foo.bar.ba-qu', | ||
locale: '', | ||
ext: '.txt' | ||
}) | ||
}) | ||
|
||
it('parse no extension', () => { | ||
expect(parseFileName('bazru-RU')).toEqual({ | ||
name: 'bazru-RU', | ||
locale: '', | ||
ext: '' | ||
}) | ||
}) | ||
}) | ||
|
||
describe('locale', () => { | ||
it('with 2 letters', () => { | ||
expect(parseFileName('foo.ru.mdx')).toEqual({ | ||
name: 'foo', | ||
locale: 'ru', | ||
ext: '.mdx' | ||
}) | ||
}) | ||
|
||
it('with 4 letters', () => { | ||
expect(parseFileName('foo.en-US.jsx')).toEqual({ | ||
name: 'foo', | ||
locale: 'en-US', | ||
ext: '.jsx' | ||
}) | ||
}) | ||
|
||
it('not with incorrect case', () => { | ||
const fileNames = [ | ||
'foo.Ru.mdx', | ||
'foo.rU.mdx', | ||
'foo.RU.mdx', | ||
|
||
'foo.Ru-ru.mdx', | ||
'foo.Ru-Ru.mdx', | ||
'foo.Ru-rU.mdx', | ||
'foo.Ru-RU.mdx', | ||
|
||
'foo.rU-ru.mdx', | ||
'foo.rU-Ru.mdx', | ||
'foo.rU-rU.mdx', | ||
'foo.rU-RU.mdx', | ||
|
||
'foo.RU-ru.mdx', | ||
'foo.RU-Ru.mdx', | ||
'foo.RU-rU.mdx', | ||
'foo.RU-RU.mdx', | ||
|
||
'foo.ru-ru.mdx', | ||
'foo.ru-Ru.mdx', | ||
'foo.ru-rU.mdx' | ||
] | ||
|
||
for (const fileName of fileNames) { | ||
expect(parseFileName(fileName).locale).toBe('') | ||
} | ||
}) | ||
|
||
it('not without leading dot', () => { | ||
expect(parseFileName('fooen-US.mdx')).toEqual({ | ||
name: 'fooen-US', | ||
locale: '', | ||
ext: '.mdx' | ||
}) | ||
}) | ||
|
||
it('not with underscore', () => { | ||
expect(parseFileName('foo.en_US.mdx').locale).toBe('') | ||
}) | ||
|
||
it('not for 5 letters', () => { | ||
expect(parseFileName('foo.en-USZ.json')).toEqual({ | ||
name: 'foo.en-USZ', | ||
locale: '', | ||
ext: '.json' | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) |
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 @@ | ||
export const MARKDOWN_EXTENSION_REGEX = /\.mdx?$/ | ||
|
||
export const IS_PRODUCTION = process.env.NODE_ENV === 'production' | ||
|
||
export const LOCALE_REGEX = /\.([a-z]{2}(-[A-Z]{2})?)$/ |
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
Oops, something went wrong.