From 54e7e138761c6b536b73459cf60c14a3d5708d67 Mon Sep 17 00:00:00 2001 From: Anton Vakhrushev <anwinged@ya.ru> Date: Sat, 30 Jun 2018 09:31:26 +0300 Subject: [PATCH] Add site map --- .editorconfig | 2 +- app/SculpinKernel.php | 14 ++++++++++++ composer.json | 3 +++ composer.lock | 50 ++++++++++++++++++++++++++++++++++++++++--- source/robots.txt | 2 ++ source/sitemap.xml | 28 ++++++++++++++++++++++++ 6 files changed, 95 insertions(+), 4 deletions(-) create mode 100644 app/SculpinKernel.php create mode 100644 source/sitemap.xml diff --git a/.editorconfig b/.editorconfig index f6ae93a..fc68585 100644 --- a/.editorconfig +++ b/.editorconfig @@ -6,7 +6,7 @@ insert_final_newline = true indent_style = space indent_size = 4 -[*.{html,twig,yml}] +[*.{html,twig,yml,xml}] indent_size = 2 [gulpfile.js] diff --git a/app/SculpinKernel.php b/app/SculpinKernel.php new file mode 100644 index 0000000..fbaedcd --- /dev/null +++ b/app/SculpinKernel.php @@ -0,0 +1,14 @@ +<?php + +use Nickpeirson\Sculpin\Bundle\SitemapBundle\SculpinSitemapBundle; +use Sculpin\Bundle\SculpinBundle\HttpKernel\AbstractKernel; + +class SculpinKernel extends AbstractKernel +{ + protected function getAdditionalSculpinBundles() + { + return [ + SculpinSitemapBundle::class, + ]; + } +} diff --git a/composer.json b/composer.json index a0770ae..57e7019 100644 --- a/composer.json +++ b/composer.json @@ -9,5 +9,8 @@ ], "require": { "sculpin/sculpin": "dev-develop" + }, + "require-dev": { + "nickpeirson/sculpin-sitemap-bundle": "^0.1.1" } } diff --git a/composer.lock b/composer.lock index 5df5e56..e70eb64 100644 --- a/composer.lock +++ b/composer.lock @@ -1,10 +1,10 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "09837fa5dccbc4721add5bfea70217ec", + "content-hash": "2ceda98de71b914666795da69e2c6df6", "packages": [ { "name": "dflydev/ant-path-matcher", @@ -2149,7 +2149,51 @@ "time": "2017-05-11T10:04:12+00:00" } ], - "packages-dev": [], + "packages-dev": [ + { + "name": "nickpeirson/sculpin-sitemap-bundle", + "version": "0.1.1", + "source": { + "type": "git", + "url": "https://github.com/nickpeirson/sculpin-sitemap-bundle.git", + "reference": "db9c7c979fcf9c13af11c6dfdc7c3ff877cfb14a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nickpeirson/sculpin-sitemap-bundle/zipball/db9c7c979fcf9c13af11c6dfdc7c3ff877cfb14a", + "reference": "db9c7c979fcf9c13af11c6dfdc7c3ff877cfb14a", + "shasum": "" + }, + "require": { + "php": ">=5.5.0" + }, + "require-dev": { + "sculpin/sculpin": ">=2.0.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Nickpeirson\\Sculpin\\Bundle\\SitemapBundle\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nick Peirson", + "email": "nickpeirson@gmail.com" + } + ], + "description": "Sculpin sitemap bundle", + "keywords": [ + "Sitemap", + "sculpin" + ], + "time": "2016-10-07T17:18:47+00:00" + } + ], "aliases": [], "minimum-stability": "stable", "stability-flags": { diff --git a/source/robots.txt b/source/robots.txt index 686bdfb..a0f54f6 100644 --- a/source/robots.txt +++ b/source/robots.txt @@ -1,4 +1,6 @@ --- permalink: none +sitemap: + _exclude: yes --- User-agent: * diff --git a/source/sitemap.xml b/source/sitemap.xml new file mode 100644 index 0000000..e0c3512 --- /dev/null +++ b/source/sitemap.xml @@ -0,0 +1,28 @@ +--- +permalink: none +use: + - sitemap +sitemap: + _exclude: yes +--- +<?xml version="1.0" encoding="UTF-8"?> +<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> + {% for url in data.sitemap %} + <url> + + {# Last slash for pretty url #} + <loc>{{ site.url }}{{ url.loc != '/.' ? (url.loc ~ '/') : '' }}</loc> + + <lastmod>{{ url.lastmod }}</lastmod> + + {% if url.changefreq %} + <changefreq>{{ url.changefreq }}</changefreq> + {% endif %} + + {% if url.priority %} + <priority>{{ url.priority }}</priority> + {% endif %} + + </url> + {% endfor %} +</urlset>