bot converting Duda.co websites

Hosting Duda.co exported websites on a regular host (convert Duda to HTML/PHP)

Duda.co websites that have been exported do not follow a regular hosting structure. For that reason, you cannot host these exported websites in hosts like GoDaddy, Hostgator, etc, without first doing some changes.

I made a Node.js script to automate that process.

const fs = require('fs-extra');
const path = require('path');

function copyFiles(sourceFolder, destinationFolder) {
    if (!fs.existsSync(destinationFolder)) {
        fs.mkdirSync(destinationFolder);
        console.log('Destination folder created:', destinationFolder);
    }
    fs.copySync(sourceFolder, destinationFolder, { overwrite: true });
}

const sourceFolder = 'website/Pages';
const destinationFolder = 'converted';

copyFiles(sourceFolder, destinationFolder);

copyFiles('website/Resources', path.join(destinationFolder, 'Resources'));
copyFiles('website/Style', path.join(destinationFolder, 'Style'));
copyFiles('website/Pages', path.join(destinationFolder, 'Pages'));

const files = fs.readdirSync(destinationFolder);
files.forEach(file => {
    const filePath = path.join(destinationFolder, file);
    const isFile = fs.statSync(filePath).isFile();

    if (isFile) {
        const fileContent = fs.readFileSync(filePath, 'utf8');

        const newFileContent = fileContent
            .replace(/window.exportsite=true/g, '')
            .replace('</body>', '<link rel="stylesheet" href="/overrides.css" type="text/css" /></body>');

        fs.writeFileSync(filePath, newFileContent, 'utf8');
    }
});

This code moves the files of the extracted website to the correct places.

Also, you need a small .css file with this content:

body {
    overflow: scroll!important;
}

For the homepage to work, you also need to add this index.html file.

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Responsive Content</title>
</head>

<link href="/overrides.css" /><link href="/overrides.css" /><link rel="stylesheet" href="/overrides.css" /><link rel="stylesheet" href="/overrides.css" /><link rel="stylesheet" href="/overrides.css" type="text/css" /></body>

    <script>
        // Function to detect the device type
        function getDeviceType() {
            const userAgent = navigator.userAgent;
            if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(userAgent)) {
                return 'mobile';
            } else if (/iPad/i.test(userAgent)) {
                return 'tablet';
            } else {
                return 'desktop';
            }
        }

        // Function to load content based on device type and path
        function loadContent() {
            const deviceType = getDeviceType();
            let path = window.location.pathname;
            if (path === '/') {
                path = '/home';
            }
            // Adjust the path based on device type
            const adjustedPath = `/${deviceType}${path}`;

            // Fetch content based on the adjusted path
            fetch(adjustedPath)
                .then(response => response.text())
                .then(content => {
                    // Update the body content with the fetched content
                    document.body.innerHTML = content;
                })
                .catch(error => console.error('Error fetching content:', error));
        }

        // Call the loadContent function when the page loads
        window.onload = loadContent;
    </script>

<link href="/overrides.css" /></body>

</html>

I have tested with multiple sites and it works properly. With some extra steps, this could be converted to an WordPress/Elementor website.

This should work well for static websites. Blogs and e-commerce would have some extra steps.

If you need assistance with this process or have other Duda.co inquiries, feel free to reach out at ngvjqp@gmail.com.

Read other Duda-related tutorials here.


Comments

Deixe um comentário

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *

pt_BRPortuguês do Brasil