@@ -5,176 +5,95 @@ const path = require('path');
55const srcDir = './src' ;
66const publicDir = './public' ;
77
8- // Create public directory if it doesn't exist
8+ // Ensure public directory exists with images subdirectory
99if ( ! fs . existsSync ( publicDir ) ) {
1010 fs . mkdirSync ( publicDir , { recursive : true } ) ;
1111}
1212
13- // Copy HTML files from src/pages to public
14- const pagesDir = path . join ( srcDir , 'pages' ) ;
15- const files = fs . readdirSync ( pagesDir ) ;
16-
17- files . forEach ( file => {
18- if ( path . extname ( file ) === '.html' ) {
19- const srcPath = path . join ( pagesDir , file ) ;
20- const destPath = path . join ( publicDir , file ) ;
21-
22- let content = fs . readFileSync ( srcPath , 'utf8' ) ;
23-
24- // Update relative paths to work from public directory
25- content = content . replace ( / \. \. \/ s t y l e s \. c s s / g, 'styles.css' ) ;
26- content = content . replace ( / \. \. \/ c o m p o n e n t s / g, 'components' ) ;
27-
28- fs . writeFileSync ( destPath , content ) ;
29- console . log ( `Copied ${ file } to public directory` ) ;
30- }
31- } ) ;
32-
33- // Copy CSS file
34- const cssSrc = path . join ( srcDir , 'styles.css' ) ;
35- const cssDest = path . join ( publicDir , 'styles.css' ) ;
36- if ( fs . existsSync ( cssSrc ) ) {
37- fs . copyFileSync ( cssSrc , cssDest ) ;
38- console . log ( 'Copied styles.css to public directory' ) ;
39- } else {
40- // Create a default styles.css if it doesn't exist
41- const defaultCSS = `
42- /* Global Styles */
43- body {
44- font-family: 'Arial', sans-serif;
45- margin: 0;
46- padding: 0;
47- background-color: #f5f5f5;
48- color: #333;
13+ if ( ! fs . existsSync ( path . join ( publicDir , 'images' ) ) ) {
14+ fs . mkdirSync ( path . join ( publicDir , 'images' ) , { recursive : true } ) ;
4915}
5016
51- /* Navigation Styles */
52- .navbar {
53- background-color: #2c3e50;
54- padding: 1rem 0;
55- box-shadow: 0 2px 4px rgba(0,0,0,0.1);
56- }
57-
58- .nav-container {
59- max-width: 1200px;
60- margin: 0 auto;
61- display: flex;
62- justify-content: space-between;
63- align-items: center;
64- padding: 0 2rem;
65- }
66-
67- .nav-logo {
68- color: white;
69- font-size: 1.5rem;
70- text-decoration: none;
71- font-weight: bold;
72- }
73-
74- .nav-menu {
75- display: flex;
76- list-style: none;
77- margin: 0;
78- padding: 0;
79- }
80-
81- .nav-item {
82- margin-left: 2rem;
83- }
84-
85- .nav-link {
86- color: white;
87- text-decoration: none;
88- transition: color 0.3s;
89- }
90-
91- .nav-link:hover {
92- color: #3498db;
93- }
94-
95- /* RK Chips Header */
96- .rk-chips-header {
97- background-color: #ecf0f1;
98- padding: 1rem 2rem;
99- display: flex;
100- justify-content: space-around;
101- border-bottom: 1px solid #bdc3c7;
102- }
17+ // Copy HTML, CSS, JS files to public
18+ copyFileToPublic ( 'index.html' ) ;
19+ copyFileToPublic ( 'styles.css' ) ;
10320
104- .rk-chip {
105- text-align: center;
106- padding: 1rem;
107- background-color: white;
108- border-radius: 8px;
109- box-shadow: 0 2px 4px rgba(0,0,0,0.1);
110- width: 45%;
111- }
112-
113- .rk-chip h3 {
114- margin: 0 0 0.5rem 0;
115- color: #2c3e50;
116- }
117-
118- /* Container for page content */
119- .container {
120- max-width: 1200px;
121- margin: 2rem auto;
122- padding: 0 2rem;
123- background-color: white;
124- border-radius: 8px;
125- box-shadow: 0 2px 10px rgba(0,0,0,0.05);
126- padding: 2rem;
21+ // Copy JavaScript files
22+ const jsSrcDir = path . join ( srcDir , 'js' ) ;
23+ const jsDestDir = path . join ( publicDir , 'js' ) ;
24+ if ( fs . existsSync ( jsSrcDir ) ) {
25+ // Remove old js directory if it exists
26+ if ( fs . existsSync ( jsDestDir ) ) {
27+ fs . rmSync ( jsDestDir , { recursive : true , force : true } ) ;
28+ }
29+
30+ fs . mkdirSync ( jsDestDir , { recursive : true } ) ;
31+ const jsFiles = fs . readdirSync ( jsSrcDir ) ;
32+ jsFiles . forEach ( file => {
33+ const srcPath = path . join ( jsSrcDir , file ) ;
34+ const destPath = path . join ( jsDestDir , file ) ;
35+ if ( fs . statSync ( srcPath ) . isFile ( ) ) {
36+ fs . copyFileSync ( srcPath , destPath ) ;
37+ console . log ( `Copied ${ file } to public/js directory` ) ;
38+ }
39+ } ) ;
40+ }
41+
42+ // Copy content files (RK3588 and RK1820 documentation)
43+ const contentSrcDir = path . join ( srcDir , 'content' ) ;
44+ const contentDestDir = path . join ( publicDir , 'content' ) ;
45+ if ( fs . existsSync ( contentSrcDir ) ) {
46+ // Remove old content directory if it exists
47+ if ( fs . existsSync ( contentDestDir ) ) {
48+ fs . rmSync ( contentDestDir , { recursive : true , force : true } ) ;
49+ }
50+
51+ copyDirectory ( contentSrcDir , contentDestDir ) ;
52+ console . log ( 'Copied content directory to public/content' ) ;
12753}
12854
129- h1 {
130- color: #2c3e50;
131- border-bottom: 2px solid #3498db;
132- padding-bottom: 0.5rem;
55+ // Helper function to copy a single file to public
56+ function copyFileToPublic ( fileName ) {
57+ const srcPath = path . join ( srcDir , fileName ) ;
58+ const destPath = path . join ( publicDir , fileName ) ;
59+
60+ if ( fs . existsSync ( srcPath ) ) {
61+ fs . copyFileSync ( srcPath , destPath ) ;
62+ console . log ( `Copied ${ fileName } to public directory` ) ;
63+ } else {
64+ console . log ( `${ fileName } does not exist in src directory` ) ;
65+ }
13366}
13467
135- /* Responsive adjustments */
136- @media (max-width: 768px ) {
137- .nav-container {
138- flex-direction: column ;
139- padding: 1rem ;
68+ // Helper function to recursively copy directories
69+ function copyDirectory ( src , dest ) {
70+ if ( ! fs . existsSync ( src ) ) {
71+ console . log ( `Source directory does not exist: ${ src } ` ) ;
72+ return ;
14073 }
14174
142- .nav-menu {
143- margin-top: 1rem ;
75+ if ( ! fs . existsSync ( dest ) ) {
76+ fs . mkdirSync ( dest , { recursive : true } ) ;
14477 }
14578
146- .nav-item {
147- margin: 0 1rem;
148- }
149-
150- .rk-chips-header {
151- flex-direction: column;
152- }
79+ const items = fs . readdirSync ( src ) ;
15380
154- .rk-chip {
155- width: 100%;
156- margin-bottom: 1rem;
81+ for ( const item of items ) {
82+ const srcPath = path . join ( src , item ) ;
83+ const destPath = path . join ( dest , item ) ;
84+
85+ const stat = fs . statSync ( srcPath ) ;
86+
87+ if ( stat . isDirectory ( ) ) {
88+ copyDirectory ( srcPath , destPath ) ;
89+ } else {
90+ fs . copyFileSync ( srcPath , destPath ) ;
91+ }
15792 }
15893}
159- ` ;
160- fs . writeFileSync ( cssDest , defaultCSS ) ;
161- console . log ( 'Created default styles.css in public directory' ) ;
162- }
163-
164- // Copy components directory
165- const componentsSrc = path . join ( srcDir , 'components' ) ;
166- const componentsDest = path . join ( publicDir , 'components' ) ;
167-
168- if ( ! fs . existsSync ( componentsDest ) ) {
169- fs . mkdirSync ( componentsDest , { recursive : true } ) ;
170- }
171-
172- const componentFiles = fs . readdirSync ( componentsSrc ) ;
173- componentFiles . forEach ( file => {
174- const srcPath = path . join ( componentsSrc , file ) ;
175- const destPath = path . join ( componentsDest , file ) ;
176- fs . copyFileSync ( srcPath , destPath ) ;
177- console . log ( `Copied ${ file } to public/components directory` ) ;
178- } ) ;
17994
180- console . log ( 'Build completed successfully!' ) ;
95+ console . log ( 'Build completed successfully!' ) ;
96+ console . log ( 'Files in public/:' , fs . readdirSync ( publicDir ) ) ;
97+ if ( fs . existsSync ( path . join ( publicDir , 'content' ) ) ) {
98+ console . log ( 'Content directories:' , fs . readdirSync ( path . join ( publicDir , 'content' ) ) ) ;
99+ }
0 commit comments