<!doctype html>
<html lang="pt-br">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <link rel="stylesheet" href="css/base.css" />
        <link rel="stylesheet" href="css/home.css" />
        <script type="text/javascript" src="javascript/libs/vanila.js"></script>
        <title>;-;</title>
    </head>
    <body>
        <div id="menu">
            <label>Logo</label>
            <header>
                <ul>
                    <a href="index.php"><li id="btn">
                        Inicio
                    </li></a>
                    <a href="index.php?pg=2"><li id="btn">
                        Escrever Historia
                    </li></a>
                </ul>
            </header>
        </div>
        <?php
        set_error_handler(function ($severity, $message, $file, $line) {
            throw new ErrorException($message, 0, $severity, $file, $line);
        });

        $page = filter_input(INPUT_GET, "pg", FILTER_VALIDATE_INT) ?: 1;
        $comps = ["inicio.php", "escrever.php"];
        try {
            $file = "componentes/" . $comps[$page - 1];

            if (!file_exists($file)) {
                http_response_code(404);
                die("<p>Error 404, arquivo não encontrado</p>");
            }
        } catch (Exception $e) {
            $file = "componentes/inicio.php";
        }
        require_once $file;
        ?>
    </body>
</html>
