Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(docs) Перевод Meta Tags #175

Merged
merged 5 commits into from
Jun 14, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions docs/7.migration/4.meta.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
---
title: Meta Tags
description: Manage your meta tags, from Nuxt 2 to Nuxt 3.
title: Мета-теги
description: Управление мета-тегами, от Nuxt 2 до Nuxt 3.
---

Nuxt 3 provides several different ways to manage your meta tags:
1. Through your `nuxt.config`.
2. Through the [`useHead`](/docs/api/composables/use-head) [composable](/docs/getting-started/seo-meta)
3. Through [global meta components](/docs/getting-started/seo-meta)
Nuxt 3 предоставляет несколько способов управления мета-тегами:
1. Через ваш `nuxt.config`.
2. С помощью [`useHead`](/docs/api/composables/use-head) [composable](/docs/getting-started/seo-meta)
3. С помощью [глобальных компонентов мета-тегов](/docs/getting-started/seo-meta)

You can customize `title`, `titleTemplate`, `base`, `script`, `noscript`, `style`, `meta`, `link`, `htmlAttrs` and `bodyAttrs`.
Вы можете настраивать `title`, `titleTemplate`, `base`, `script`, `noscript`, `style`, `meta`, `link`, `htmlAttrs` и `bodyAttrs`.

::tip
Nuxt currently uses [`vueuse/head`](https://github.com/vueuse/head) to manage your meta tags, but implementation details may change.
В настоящее время Nuxt использует [`vueuse/head`](https://github.com/vueuse/head) для управления метатегами, но детали реализации могут измениться.
::

:read-more{to="/docs/getting-started/seo-meta"}

## Миграция

1. In your `nuxt.config`, rename `head` to `meta`. Consider moving this shared meta configuration into your `app.vue` instead. (Note that objects no longer have a `hid` key for deduplication.)
2. If you need to access the component state with `head`, you should migrate to using [`useHead`](/docs/api/composables/use-head) . You might also consider using the built-in meta-components.
3. If you need to use the Options API, there is a `head()` method you can use when you use `defineNuxtComponent`.
1. В вашем `nuxt.config`, переименуйте `head` в `meta`. Рассмотрите возможность перемещения этой общей конфигурации мета-тегов в ваш `app.vue`. (Обратите внимание, что объекты больше не имеют ключа `hid` для устранения дубликатов.)
2. Если вам нужен доступ к состоянию компонента с помощью `head`, вам следует мигрировать на использование [`useHead`](/docs/api/composables/use-head). Вам также может быть полезно использовать встроенные мета-компоненты.
3. Если вам нужно использовать Options API, есть метод `head()`, который вы можете использовать при использовании `defineNuxtComponent`.

### useHead

Expand All @@ -30,8 +30,8 @@ Nuxt currently uses [`vueuse/head`](https://github.com/vueuse/head) to manage yo
<script>
export default {
data: () => ({
title: 'My App',
description: 'My App Description'
title: 'Мое приложение',
description: 'Описание моего приложения'
})
head () {
return {
Expand All @@ -49,10 +49,10 @@ export default {

```vue [Nuxt 3]
<script setup lang="ts">
const title = ref('My App')
const description = ref('My App Description')
const title = ref('Мое приложение')
const description = ref('Описание моего приложения')

// This will be reactive when you change title/description above
// Это будет реактивно при изменении title/description выше
useHead({
title,
meta: [{
Expand All @@ -65,9 +65,9 @@ useHead({

::

### Meta-components
### Мета-компоненты

Nuxt 3 also provides meta components that you can use to accomplish the same task. While these components look similar to HTML tags, they are provided by Nuxt and have similar functionality.
Nuxt 3 также предоставляет мета-компоненты, которые вы можете использовать для выполнения того же задания. Хотя эти компоненты похожи на теги HTML, они предоставляются Nuxt и имеют схожую функциональность.

::code-group

Expand All @@ -76,11 +76,11 @@ Nuxt 3 also provides meta components that you can use to accomplish the same tas
export default {
head () {
return {
title: 'My App',
title: 'Мое приложение',
meta: [{
hid: 'description',
name: 'description',
content: 'My App Description'
content: 'Описание моего приложения'
}]
}
}
Expand All @@ -92,8 +92,8 @@ export default {
<template>
<div>
<Head>
<Title>My App</Title>
<Meta name="description" content="My app description"/>
<Title>Мое приложение</Title>
<Meta name="description" content="Описание моего приложения"/>
</Head>
<!-- -->
</div>
Expand All @@ -103,22 +103,22 @@ export default {
::

::important
1. Make sure you use capital letters for these component names to distinguish them from native HTML elements (`<Title>` rather than `<title>`).
2. You can place these components anywhere in your template for your page.
1. Убедитесь, что вы используете прописные буквы для этих имен компонентов, чтобы отличать их от нативных элементов HTML (<Title> вместо <title>).
2. Вы можете размещать эти компоненты в любом месте шаблона вашей страницы.
::

### Параметры API

```vue [Nuxt 3 (Options API)]
<script>
// if using options API `head` method you must use `defineNuxtComponent`
// если используется метод head Options API, необходимо использовать `defineNuxtComponent`
export default defineNuxtComponent({
head (nuxtApp) {
// `head` receives the nuxt app but cannot access the component instance
// `head` получает приложение nuxt, но не может получить доступ к экземпляру компонента
return {
meta: [{
name: 'description',
content: 'This is my page description.'
content: 'Это описание моей страницы.'
}]
}
}
Expand Down
Loading