Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(nextra): allow to contain dots in page filenames #546

Merged
merged 2 commits into from
Jul 22, 2022
Merged

fix(nextra): allow to contain dots in page filenames #546

merged 2 commits into from
Jul 22, 2022

Conversation

dimaMachina
Copy link
Collaborator

@dimaMachina dimaMachina commented Jul 16, 2022

fixes #545

  • removes getLocaleFromFilename, removeExtension and getFileName in favor of simple and more generic parseFileName function
  • add tests for parseFileName to ensure it works like expected
  • fix locales.ts, const PUBLIC_FILE = /\.(.*)$/ not allow redirect page names with dots

@vercel
Copy link

vercel bot commented Jul 16, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
nextra-theme-docs-dev ✅ Ready (Inspect) Visit Preview Jul 22, 2022 at 9:43AM (UTC)
1 Ignored Deployment
Name Status Preview Updated
nextra ⬜️ Ignored (Inspect) Jul 22, 2022 at 9:43AM (UTC)

Comment on lines 3 to 22
const PUBLIC_FILE = /\.(.*)$/

export function locales(request: NextRequest) {
const { nextUrl } = request

const shouldHandleLocale =
!PUBLIC_FILE.test(nextUrl.pathname) &&
!nextUrl.pathname.includes('/api/') &&
!nextUrl.pathname.includes('/_next/') &&
!/^\/(api|_next)\//.test(nextUrl.pathname) &&
!/\.(jpe?g|svg|png|webmanifest)$/.test(nextUrl.pathname) &&
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines -20 to +18
pageMaps: PageMapItem[],
pageMap: PageMapItem[],
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

Comment on lines +20 to 24
export const parseJsonFile = (
content: string,
path: string
) => Record<string, any> = (content: string, path: string) => {
): Record<string, any> => {
try {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be simplified

@changeset-bot
Copy link

changeset-bot bot commented Jul 22, 2022

🦋 Changeset detected

Latest commit: ba954cf

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@shuding
Copy link
Owner

shuding commented Jul 22, 2022

Great refactor, thanks!

@shuding shuding merged commit efd95ec into shuding:core Jul 22, 2022
@dimaMachina dimaMachina deleted the fix-files-with-dotes branch July 22, 2022 14:12
tatukoivisto pushed a commit to tatukoivisto/nextra that referenced this pull request Aug 20, 2023
* fix(nextra): allow to contain dots in page filenames

* add changeset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants