generate head data
authorEduardo <[email protected]>
Sat, 11 Nov 2023 00:25:25 +0000 (01:25 +0100)
committerEduardo <[email protected]>
Sat, 11 Nov 2023 00:25:25 +0000 (01:25 +0100)
page-generator/index.php

index db37ea5c33322f23a4bbc2473b00d0e6eb8167c2..d6df73d6bac70d5d60cc8fe80f7a7d28ef5a7e44 100644 (file)
@@ -35,7 +35,9 @@ mkdir($partialsPath);
 
 #region head
 
-// TODO: get the header and idk
+// get head data
+$head_data = file_get_contents(URL . '?sheet=_header');
+$head_data = json_decode($head_data, true);
 
 $head_path = $partialsPath . "/head.html";
 
@@ -43,13 +45,26 @@ $head_path = $partialsPath . "/head.html";
 $generator->writeToFile($head_path, '
 <!DOCTYPE html>
 <html lang="' . $generator->templateVar("lang-code") . '">
-<head>
-    <meta charset="UTF-8">
-    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+<head>');
+
+foreach ($head_data as $item) {
+    switch ($item['type']) {
+        case 'meta':
+            $generator->writeToFile($head_path, '<meta ' . $item['value'] . '>');
+            break;
+
+        case 'css':
+            $generator->writeToFile($head_path, '<link rel="stylesheet" href="' . $item['value'] . '">');
+            break;
+
+        case 'js':
+            $generator->writeToFile($head_path, '<script src="' . $item['value'] . '"></script>');
+            break;
+    }
+}
+
+$generator->writeToFile($head_path, '
     <title>' . $generator->templateVar("page-title") . '</title>
-    
-    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css">
-    <link rel="stylesheet" href="../../assets/css/style.css">
 </head>
 <body>
 ');