Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24
22
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ Nooxy provides sophisticated URL rewriting that handles:

### Prerequisites

- Node.js
- Node.js 18.17.0 or higher
- A Cloudflare account (for deployment)
- A custom domain (optional, for production)

Expand Down Expand Up @@ -230,7 +230,7 @@ export const SITE_CONFIG = {
// Optional: 404 page configuration
// fof: {
// page: "NOTION_PAGE_ID",
// slug: "404", // default
// slug: "/404", // default
// },

// Optional: Subdomain redirects
Expand Down Expand Up @@ -660,7 +660,7 @@ Please see [CONTRIBUTING.md](CONTRIBUTING.md) for full guidelines, development s

**Solution**:

- Ensure you're using Node.js 22.0.0 or higher
- Ensure you're using Node.js 18.17.0 or higher
- Check that your `wrangler.toml` is configured correctly
- Verify your Notion pages are accessible

Expand Down
2 changes: 1 addition & 1 deletion examples/cloudflare/nooxy/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const SITE_CONFIG = {
// If you don't have one, the default 404 page will be used
// fof: {
// page: "NOTION_PAGE_ID",
// slug: "404", // default
// slug: "/404", // default
// },
// Subdomain redirects are optional
// But it is recommended to have one for www
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"email": "david@draphy.org"
},
"engines": {
"node": ">=22.0.0"
"node": ">=18.17.0"
},
"license": "MIT",
"publishConfig": {
Expand All @@ -63,7 +63,7 @@
}
},
"scripts": {
"prebuild": "node converter.js && pnpm biome:fix ",
"prebuild": "node converter.js && pnpm biome:fix",
"build": "pnpm run prebuild && tsup src/index.ts --format esm --dts-resolve --clean --sourcemap --out-dir dist && pnpm run build:cli",
"build:cli": "tsup src/cli/index.ts --format esm --clean --out-dir dist/cli && cp -r src/cli/templates dist/cli/",
"biome:lint": "biome lint .",
Expand Down
2 changes: 1 addition & 1 deletion src/cli/templates/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const SITE_CONFIG = {
// If you don't have one, the default 404 page will be used
// fof: {
// page: "NOTION_PAGE_ID",
// slug: "404", // default
// slug: "/404", // default
// },
// Subdomain redirects are optional
// But it is recommended to have one for www
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/handle-sitemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export function handleSitemap(siteConfig: NooxySiteConfigFull, protocol: string)
let sitemap = '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';

slugs.forEach((slug) => {
sitemap += `<url><loc>${protocol}//${domain}/${slug}</loc></url>`;
sitemap += `<url><loc>${protocol}//${domain}${slug}</loc></url>`;
});
sitemap += '</urlset>';

Expand Down
4 changes: 2 additions & 2 deletions src/helpers/config-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ export class ConfigManager {

siteConfig.fof = {
page: siteConfig.fof?.page,
slug: siteConfig.fof?.slug || '404',
slug: siteConfig.fof?.slug || '/404',
};

if (siteConfig.fof.page?.length) {
siteConfig.slugToPage[siteConfig.fof.slug ?? ''] = siteConfig.fof.page;
siteConfig.slugToPage[siteConfig.fof.slug ?? '/404'] = siteConfig.fof.page;
}

// Build helper indexes
Expand Down
15 changes: 7 additions & 8 deletions src/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,15 @@ export function isNotion404(pathname: string, slugToPage: Record<string, string>
) {
return false;
}
const lastSlashIndex = pathname.lastIndexOf('/');
const slugSlash = lastSlashIndex === -1 ? pathname : pathname.slice(lastSlashIndex + 1);
const lastHyphenIndex = slugSlash.lastIndexOf('-');
const slug = lastHyphenIndex === -1 ? slugSlash : slugSlash.slice(lastHyphenIndex + 1);
if (!slug) {
const lastSlash = pathname.slice(pathname.lastIndexOf('/') + 1);
const pageId = lastSlash.slice(lastSlash.lastIndexOf('-') + 1);
const slug = extractSlug(pathname);
if (!pageId && !slug) {
return false;
}
const page = slugToPage[`/${slug}`];
const notValidSlug = slug.length !== 32;
if (!page && notValidSlug) {
const page = slugToPage[slug ?? ''];
const validPageId = pageId.length === 32;
if (!page && !validPageId) {
return true;
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface NooxySiteConfigFull {
// Use the value from your Notion like example.notion.site
notionDomain: string

// 404 Notion page to display to visitors, the default slug is '404'
// 404 Notion page to display to visitors, the default slug is '/404'
fof?: {
page: string | undefined
slug: string | undefined
Expand Down
7 changes: 4 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"_version": "22.0.0",
"compilerOptions": {
"lib": [
"es2023"
"ES2021",
"DOM"
],
"strict": true,
"moduleResolution": "bundler",
Expand All @@ -16,7 +17,7 @@
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
/* Language and Environment */
"target": "ESNext", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"target": "ES2021", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
Expand All @@ -29,7 +30,7 @@
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
/* Modules */
"module": "ESNext", /* Specify what module code is generated. */
"module": "ES2022", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
Expand Down