Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions components/changelog-generator.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { buildDynamicMDX, buildDynamicMeta } from 'nextra/remote'
import { buildDynamicMDX } from 'nextra/remote'

export const getChangelog = async (packageName, locale = 'en') => {
let page = 1
let releases = await fetch(
`https://api.github.com/repos/napi-rs/napi-rs/releases?per_page=100&page=${page}`,
{
headers: {
Accept: 'application/vnd.github+json',
'X-GitHub-Api-Version': '2022-11-28',
Authorization: `token ${process.env.GITHUB_TOKEN}`,
},
},
Expand All @@ -18,6 +20,8 @@ export const getChangelog = async (packageName, locale = 'en') => {
`https://api.github.com/repos/napi-rs/napi-rs/releases?per_page=100&page=${page}`,
{
headers: {
Accept: 'application/vnd.github+json',
'X-GitHub-Api-Version': '2022-11-28',
Authorization: `token ${process.env.GITHUB_TOKEN}`,
},
},
Expand All @@ -39,12 +43,11 @@ export const getChangelog = async (packageName, locale = 'en') => {
)
return `## <a href="${
release.html_url
}" target="_blank" rel="noopener">${release.tag_name}</a>
}" target="_blank" rel="noopener">${release.tag_name}</a>
${new Date(release.published_at).toLocaleDateString(locale)} \n${body}`
})
.join('\n\n'),
)),
...(await buildDynamicMeta()),
},
revalidate: 10,
}
Expand Down
4 changes: 2 additions & 2 deletions components/sponsors.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useSSG } from 'nextra/ssg'
import { useData } from 'nextra/hooks'

export function Sponsors() {
const sponsorsSVG = useSSG()
const sponsorsSVG = useData()
const reg =
/<svg xmlns="http:\/\/www.w3.org\/2000\/svg" xmlns:xlink="http:\/\/www.w3.org\/1999\/xlink" width="([0-9]+)" height="([0-9]+)">/
const [_, width, height] = reg.exec(sponsorsSVG)
Expand Down
9 changes: 7 additions & 2 deletions middleware.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import { locales } from 'nextra/locales'
export { middleware } from 'nextra/locales'

export const middleware = locales
export const config = {
// Matcher ignoring `/_next/` and `/api/`
matcher: [
'/((?!api|_next/static|_next/image|favicon.ico|icon.svg|apple-icon.png|manifest).*)',
],
}
2 changes: 1 addition & 1 deletion next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information.
24 changes: 17 additions & 7 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
const { PerfseePlugin } = require('@perfsee/webpack')
const withNextra = require('nextra')({
import { join } from 'node:path'
import { fileURLToPath } from 'node:url'

import { PerfseePlugin } from '@perfsee/webpack'
import nextra from 'nextra'

const withNextra = nextra({
theme: 'nextra-theme-docs',
themeConfig: './nextra.config.js',
flexsearch: true,
search: true,
staticImage: true,
})

module.exports = withNextra({
export default withNextra({
i18n: {
defaultLocale: process.env.LOCALE || 'en',
locales: ['en', 'cn', 'pt-BR'],
defaultLocale: 'en',
locales: ['en', 'pt-BR'],
},
webpack(config, { dev, isServer }) {
webpack(
/** @type {import('webpack').Configuration} */ config,
{ dev, isServer },
) {
if (!dev && !isServer) {
const plugin = new PerfseePlugin({
project: 'napi-rs-website',
Expand All @@ -33,6 +41,8 @@ module.exports = withNextra({
outputPath: `${isServer ? '../' : ''}static/videos/`,
},
})

config.resolve.alias['@'] = join(fileURLToPath(import.meta.url), '..')
return config
},
})
5 changes: 2 additions & 3 deletions nextra.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ import Script from 'next/script'

const LOADING_LOCALES = {
en: 'Loading',
cn: '正在加载',
'pt-BR': 'Carregando',
}

const PLACEHOLDER_LOCALES = {
en: 'Search documentation',
cn: '搜索文档',
'pt-BR': 'Buscar documentação',
}

const DEFAULT_LOCALE = 'en'

export default {
docsRepositoryBase: 'https://github.com/napi-rs/website/blob/main',
chat: {
Expand Down Expand Up @@ -153,7 +153,6 @@ export default {
},
i18n: [
{ locale: 'en', text: 'English' },
{ locale: 'cn', text: '简体中文' },
{ locale: 'pt-BR', text: 'Português do Brasil' },
],
useNextSeoProps: () => ({ titleTemplate: '%s \u2013 NAPI-RS' }),
Expand Down
38 changes: 20 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"description": "Website for https://napi.rs",
"author": "[email protected]",
"license": "MIT",
"type": "module",
"prettier": {
"printWidth": 80,
"semi": false,
Expand All @@ -13,32 +14,33 @@
"arrowParens": "always"
},
"dependencies": {
"@mdx-js/react": "^3.0.0",
"@vercel/analytics": "^1.1.1",
"@mdx-js/react": "^3.1.0",
"@vercel/analytics": "^1.3.2",
"lodash-es": "^4.17.21",
"next": "14.2.16",
"nextra": "2.13.4",
"nextra-theme-docs": "2.13.4",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"next": "15.0.1",
"nextra": "3.1.1",
"nextra-theme-docs": "3.1.1",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"devDependencies": {
"@perfsee/webpack": "^1.10.0",
"@types/node": "^20.10.5",
"@types/react": "^18.2.45",
"@perfsee/webpack": "^1.13.0",
"@types/node": "^22.8.1",
"@types/react": "^18.3.12",
"@types/sharp": "^0.32.0",
"autoprefixer": "^10.4.16",
"@types/webpack": "^5.28.5",
"autoprefixer": "^10.4.20",
"cross-env": "^7.0.3",
"file-loader": "^6.2.0",
"husky": "9",
"lint-staged": "^15.2.0",
"lint-staged": "^15.2.10",
"next-mdx-remote": "^5.0.0",
"postcss": "^8.4.32",
"prettier": "^3.1.1",
"sharp": "^0.33.1",
"tailwindcss": "^3.4.0",
"typescript": "^5.3.3",
"vercel": "^37.0.0"
"postcss": "^8.4.47",
"prettier": "^3.3.3",
"sharp": "^0.33.5",
"tailwindcss": "^3.4.14",
"typescript": "^5.6.3",
"vercel": "^37.12.1"
},
"scripts": {
"dev": "next",
Expand Down
16 changes: 8 additions & 8 deletions pages/_app.mdx → pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ export default function Nextra({ Component, pageProps }) {
// Use the layout defined at the page level, if available
const getLayout = Component.getLayout || ((page) => page)

const layout = getLayout(<Component {...pageProps} />)
return (

<>
<Analytics />
{layout}
</>
) }
const layout = getLayout(<Component {...pageProps} />)
return (
<>
<Analytics />
{layout}
</>
)
}
18 changes: 0 additions & 18 deletions pages/_meta.cn.json

This file was deleted.

18 changes: 0 additions & 18 deletions pages/_meta.en.json

This file was deleted.

18 changes: 0 additions & 18 deletions pages/_meta.pt-BR.json

This file was deleted.

Loading