Reactober is a project that simplifies the integration of React into October CMS projects, allowing developers to build React applications within the context of an October CMS backend. This project includes a file-based router for React, pre-installed Tailwind CSS with Webpack for efficient bundling, and code-splitting capabilities to reduce bundle sizes.
The project includes three main scripts in the package.json
file:
Serve:
webpack serve
Watch:
ts-node src/generator/watch.ts
Build:
ts-node src/generator/index.ts
Development Mode:
npm run serve
Real-time Conversion:
npm run watch
Build Theme:
npm run build
The Reactober project has the following directory structure:
/
hosting/
index.html
: HTML file for hosting purposes.src/
generator/
assets/
dirStructure.yaml
: YAML file describing the project directory structure.files/
theme.yaml
: YAML file for defining October CMS theme configurations.template.html
: HTML template for October CMS.index.ts
: Main generator script for building October CMS theme.utils.ts
: Utility functions for the generator.watch.ts
: Real-time conversion script for frontend source code to the October CMS template.lib/
october.ts
: Frontend helper functions for interacting with October CMS.main.tsx
: Main entry point for the React application.pages/
404.tsx
: Custom 404 page component._app.tsx
: App component wrapper for all pages.index.tsx
: Main index page component.with_id/
[id].tsx
: Dynamic route component with a parameter in the URL.routes.tsx
: File-based router for React.style/
global.css
: Global CSS styles.tailwind.config.js
: Tailwind CSS configuration file.theme_export/
assets/
css/
: Exported CSS files.images/
: Exported image assets.js/
: Exported JavaScript bundles.pages/
index.htm
: Exported October CMS index page.with_id/
PATHPARAM__id__.htm
: Exported October CMS page for dynamic routes.theme.yaml
: Exported October CMS theme configuration.tsconfig.json
: TypeScript configuration file.webpack.config.js
: Webpack configuration file.yarn.lock
: Yarn package manager lock file.hosting/
: Contains hosting-related files, such as the main HTML file for deployment.
src/generator/
: Generator scripts for building the October CMS theme.
assets/
: Contains YAML and HTML files defining the project directory structure and October CMS theme configurations.
index.ts
: Main script for generating the October CMS theme.
utils.ts
: Utility functions used by the generator.
watch.ts
: Real-time conversion script for frontend source code to the October CMS template.
src/lib/
: Frontend helper functions for interacting with October CMS.
src/pages/
: File-based router for React components.
with_id/
: Dynamic route components with parameters in the URL.src/style/
: Contains global CSS styles.
theme_export/
: Contains the exported October CMS theme.
assets/
: Exported CSS, image, and JavaScript files.
pages/
: Exported October CMS pages.
// src/pages/index.tsx
import React from 'react';
import { backendData, getBackendData, meta, html } from '../lib/october';
export const backend = backendData`
return array(
"name" => "John",
"age" => 30,
"city" => "New York"
);
`;
export const metadata = meta`
`;
export const header = html`
`;
export default function Post() {
const data = getBackendData<{ name: string; age: number; city: string }>();
return (
<div className="flex items-center justify-center content-center">
<div className="bold font-2xl">
<h1>Name: {data.name}</h1>
<span>Hi! I'm {data.age} years old, and I'm from {data.city}</span>
chipi chapa
<a href="/with_id/23">Check out my cat post</a>
</div>
</div>
);
}
Feel free to adapt this structure to fit your project's specific needs.
For a complete list of dependencies, refer to the package.json
file.
This project is licensed under the MIT License.
Make sure to check for updates to the dependencies regularly and update your project accordingly for security and compatibility reasons.