From 430d3dba0fccf59a0ef13f425886a74304cd7293 Mon Sep 17 00:00:00 2001 From: e11sy Date: Mon, 15 Jul 2024 21:23:09 +0300 Subject: [PATCH] moved JSON-LD markup to plugin --- nginx.conf | 2 +- nuxt.config.js | 1 + package.json | 6 +- pages/ru.vue | 136 +++++++++++++++++++++------------------------- plugins/jsonld.js | 4 ++ yarn.lock | 12 ++++ 6 files changed, 84 insertions(+), 77 deletions(-) create mode 100644 plugins/jsonld.js diff --git a/nginx.conf b/nginx.conf index 7f915fc..6803884 100644 --- a/nginx.conf +++ b/nginx.conf @@ -14,6 +14,6 @@ server { } location ~ (?.*)/$ { - return 301 $scheme://$host$no_slash; + return 301 $scheme://$host$no_slash; } } diff --git a/nuxt.config.js b/nuxt.config.js index 0693778..089b1fa 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -67,6 +67,7 @@ export default { // Plugins to run before rendering page (https://go.nuxtjs.dev/config-plugins) plugins: [ + '~/plugins/jsonld' ], // Auto import components (https://go.nuxtjs.dev/config-components) diff --git a/package.json b/package.json index 1ef59fd..9755cfe 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ }, "dependencies": { "core-js": "^3.16.1", - "nuxt": "^2.15.8" + "nuxt": "^2.15.8", + "nuxt-jsonld": "v1" }, "devDependencies": { "@nuxt/types": "^2.15.8", @@ -30,7 +31,6 @@ "postcss-custom-media": "^7.0.8", "postcss-loader": "^3.0.0", "postcss-nested": "^4.2.3", - "postcss-nested-ancestors": "^2.0.0", - "vue-meta": "^2.4.0" + "postcss-nested-ancestors": "^2.0.0" } } diff --git a/pages/ru.vue b/pages/ru.vue index f3b0a80..f1bf280 100644 --- a/pages/ru.vue +++ b/pages/ru.vue @@ -70,7 +70,6 @@ import UsedByTable, {UsedByItem} from '~/components/used-by-table.vue'; import UiButton from '~/components/ui-button.vue'; import Contact from '~/components/contact.vue'; import gridInfo from '~/components/grid-info.vue'; -import { MetaInfo } from 'vue-meta'; export default Vue.extend({ components: { @@ -87,6 +86,68 @@ export default Vue.extend({ gridInfo, }, layout: 'ru', + jsonld() { + return [{ + "@context": "https://schema.org", + "@type": "WebPage", + "name": "Хоук — российский трекер ошибок", + "description": "Мониторинг ошибок в ПО с серверами в России и открытым исходным кодом", + "image": "https://hawk.so/hawk-ru-og-image.png", + "url": "https://hawk.so/ru", + "publisher": { + "@type": "Organization", + "name": "Хоук", + "logo": { + "@type": "ImageObject", + "url": "https://hawk.so/hawk-ru-og-image.png" + } + }, + "creator": { + "@type": "Organization", + "name": "CodeX", + "description": "Команда open-source разработчиков", + "url": "https://codex.so", + "logo": { + "@type": "ImageObject", + "url": "https://codex.so/public/app/img/codex-logo.svg" + }, + "sameAs": [ + "http://twitter.com/codex_team" + ] + } + }, + { + "@context": "https://schema.org", + "@type": "Product", + "name": "Хоук — российский трекер ошибок", + "description": "Мониторинг ошибок в ПО с серверами в России и открытым исходным кодом", + "image": "https://hawk.so/hawk-ru-og-image.png", + "brand": { + "@type": "Brand", + "name": "Хоук" + }, + "offers": { + "@type": "Offer", + "url": "https://hawk.so/ru", + "priceCurrency": "RUB", + "price": "0", // Adjust this value to the actual price + "availability": "https://schema.org/InStock" + }, + "creator": { + "@type": "Organization", + "name": "CodeX", + "description": "Команда open-source разработчиков", + "url": "https://codex.so", + "logo": { + "@type": "ImageObject", + "url": "https://codex.so/public/app/img/codex-logo.svg" + }, + "sameAs": [ + "http://twitter.com/codex_team" + ] + } + }] + }, data(): { /** * Features list description @@ -316,7 +377,7 @@ export default Vue.extend({ } }, }, - head(): MetaInfo { + head() { return { title: "Хоук — российский трекер ошибок", meta: [ @@ -376,77 +437,6 @@ export default Vue.extend({ content: 'https://hawk.so/ru' }, ], - script: [ - { - // JSON-LD schema.org markup for WebPage - type: 'application/ld+json', - json: { - "@context": "https://schema.org", - "@type": "WebPage", - "name": "Хоук — российский трекер ошибок", - "description": "Мониторинг ошибок в ПО с серверами в России и открытым исходным кодом", - "image": "https://hawk.so/hawk-ru-og-image.png", - "url": "https://hawk.so/ru", - "publisher": { - "@type": "Organization", - "name": "Хоук", - "logo": { - "@type": "ImageObject", - "url": "https://hawk.so/hawk-ru-og-image.png" - } - }, - "creator": { - "@type": "Organization", - "name": "CodeX", - "description": "Команда open-source разработчиков", - "url": "https://codex.so", - "logo": { - "@type": "ImageObject", - "url": "https://codex.so/public/app/img/codex-logo.svg" - }, - "sameAs": [ - "http://twitter.com/codex_team" - ] - } - } - }, - { - // JSON-LD schema.org markup for Product - type: 'application/ld+json', - json: { - "@context": "https://schema.org", - "@type": "Product", - "name": "Хоук — российский трекер ошибок", - "description": "Мониторинг ошибок в ПО с серверами в России и открытым исходным кодом", - "image": "https://hawk.so/hawk-ru-og-image.png", - "brand": { - "@type": "Brand", - "name": "Хоук" - }, - "offers": { - "@type": "Offer", - "url": "https://hawk.so/ru", - "priceCurrency": "RUB", - "price": "0", // Adjust this value to the actual price - "availability": "https://schema.org/InStock" - }, - "creator": { - "@type": "Organization", - "name": "CodeX", - "description": "Команда open-source разработчиков", - "url": "https://codex.so", - "logo": { - "@type": "ImageObject", - "url": "https://codex.so/public/app/img/codex-logo.svg" - }, - "sameAs": [ - "http://twitter.com/codex_team" - ] - } - } - } - ], - __dangerouslyDisableSanitizers: ['script'], } } }); diff --git a/plugins/jsonld.js b/plugins/jsonld.js new file mode 100644 index 0000000..00cf43a --- /dev/null +++ b/plugins/jsonld.js @@ -0,0 +1,4 @@ +import Vue from 'vue'; +import NuxtJsonld from 'nuxt-jsonld'; + +Vue.use(NuxtJsonld); diff --git a/yarn.lock b/yarn.lock index bc67fdd..2079132 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5457,6 +5457,13 @@ num2fraction@^1.2.2: version "1.2.2" resolved "https://registry.npmjs.org/num2fraction/-/num2fraction-1.2.2.tgz" +nuxt-jsonld@v1: + version "1.5.8" + resolved "https://registry.yarnpkg.com/nuxt-jsonld/-/nuxt-jsonld-1.5.8.tgz#bc14a9261d7fba4df779f7f29f80214c43ebfb23" + integrity sha512-D+xYmegfxNtDH39W6Aa8B7swAfYvIF807BsDe5KtQNLk83YpYm+dqASSDVeVN6sZsrBNy5Qr/VqzB+z0M2InYQ== + dependencies: + schema-dts "^1.0.0" + nuxt@^2.15.8: version "2.15.8" resolved "https://registry.npmjs.org/nuxt/-/nuxt-2.15.8.tgz" @@ -6923,6 +6930,11 @@ sax@~1.2.4: version "1.2.4" resolved "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz" +schema-dts@^1.0.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/schema-dts/-/schema-dts-1.1.2.tgz#82ccf71b5dcb80065a1cc5941888507a4ce1e44b" + integrity sha512-MpNwH0dZJHinVxk9bT8XUdjKTxMYrA5bLtrrGmFA6PTLwlOKnhi67XoRd6/ty+Djt6ZC0slR57qFhZDNMI6DhQ== + schema-utils@2.7.0: version "2.7.0" resolved "https://registry.npmjs.org/schema-utils/-/schema-utils-2.7.0.tgz"