Script to generate sitemap
This commit is contained in:
parent
269cc735a4
commit
7431b50b8d
34
php/sitemap.php
Normal file
34
php/sitemap.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
$root = "https://sqkhor.com/pixel-icons/";
|
||||
$icon_json = json_decode(file_get_contents(__DIR__ . "/assets/icons.json"), true);
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
<?='<' . '?xml version="1.0" encoding="UTF-8"?' . '><' . '?xml-stylesheet type="text/xsl" href="//sqkhor.com/wp-content/plugins/wordpress-seo/css/main-sitemap.xsl"?' . '>' ?>
|
||||
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd http://www.google.com/schemas/sitemap-image/1.1 http://www.google.com/schemas/sitemap-image/1.1/sitemap-image.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||
<url>
|
||||
<loc>https://sqkhor.com/pixel-icons/</loc>
|
||||
<lastmod><?= date("Y-m-d", filemtime(__DIR__ . "/assets/icons.json")) ?></lastmod>
|
||||
<changefreq>always</changefreq>
|
||||
<image:image>
|
||||
<image:loc>https://sqkhor.com/pixel-icons/cover3.1.png</image:loc>
|
||||
</image:image>
|
||||
</url>
|
||||
<?php foreach ($icon_json as $filename => $tags): ?>
|
||||
<?php $icon_name = str_replace(".svg", "", $filename) ?>
|
||||
<url>
|
||||
<loc><?= $root . $icon_name ?></loc>
|
||||
<lastmod><?= date("Y-m-d", filectime(__DIR__ . "/icons/$filename")) ?></lastmod>
|
||||
<changefreq>yearly</changefreq>
|
||||
<image:image>
|
||||
<image:loc><?= $root . "preview/$icon_name.png" ?></image:loc>
|
||||
</image:image>
|
||||
</url>
|
||||
<?php endforeach ?>
|
||||
</urlset>
|
||||
<?php
|
||||
$sitemap = ob_get_clean();
|
||||
file_put_contents(__DIR__ . "/pixel-icons-sitemap.xml", $sitemap);
|
||||
header("Content-type: application/xml");
|
||||
echo $sitemap;
|
Loading…
Reference in New Issue
Block a user