11<script setup lang="ts">
2- import { useData } from ' vitepress'
2+ import { useData , useRoute } from ' vitepress'
33
44const { frontmatter } = useData ()
5+ const route = useRoute ()
6+
7+ const isRu = route .path .startsWith (' /ru/' )
8+ const blogUrl = isRu ? ' /ru/blog/' : ' /blog/'
9+ const backTitle = isRu ? ' Назад в блог' : ' Back to blog'
510
611function formatDate(date : string | Date ): string {
712 const d = new Date (date )
@@ -11,12 +16,18 @@ function formatDate(date: string | Date): string {
1116
1217<template >
1318 <div class =" blog-post-header" v-if =" frontmatter.image || frontmatter.date || frontmatter.author" >
14- <img
15- v-if =" frontmatter.image"
16- :src =" frontmatter.image"
17- :alt =" frontmatter.title"
18- class =" post-hero-image"
19- />
19+ <div class =" post-image-wrap" v-if =" frontmatter.image" >
20+ <a :href =" blogUrl" class =" back-to-blog" :title =" backTitle" >
21+ <svg width =" 18" height =" 18" viewBox =" 0 0 18 18" fill =" none" xmlns =" http://www.w3.org/2000/svg" >
22+ <path d =" M11 4L6 9L11 14" stroke =" currentColor" stroke-width =" 2" stroke-linecap =" round" stroke-linejoin =" round" />
23+ </svg >
24+ </a >
25+ <img
26+ :src =" frontmatter.image"
27+ :alt =" frontmatter.title"
28+ class =" post-hero-image"
29+ />
30+ </div >
2031 <div class =" post-meta" v-if =" frontmatter.date || frontmatter.author" >
2132 <span v-if =" frontmatter.date" class =" post-date" >{{ formatDate(frontmatter.date) }}</span >
2233 <span v-if =" frontmatter.author" class =" post-author" >{{ frontmatter.author }}</span >
@@ -29,6 +40,38 @@ function formatDate(date: string | Date): string {
2940 margin-bottom : 1.5rem ;
3041}
3142
43+ .post-image-wrap {
44+ position : relative ;
45+ }
46+
47+ .back-to-blog {
48+ position : absolute ;
49+ top : 12px ;
50+ left : -48px ;
51+ display : none ;
52+ align-items : center ;
53+ justify-content : center ;
54+ width : 36px ;
55+ height : 36px ;
56+ border-radius : 50% ;
57+ border : 1px solid var (--vp-c-divider );
58+ background : var (--vp-c-bg );
59+ color : var (--vp-c-text-2 );
60+ text-decoration : none ;
61+ transition : all 0.2s ;
62+ }
63+
64+ .back-to-blog :hover {
65+ color : var (--vp-c-brand-1 );
66+ border-color : var (--vp-c-brand-1 );
67+ }
68+
69+ @media (min-width : 1280px ) {
70+ .back-to-blog {
71+ display : flex ;
72+ }
73+ }
74+
3275.post-hero-image {
3376 width : 100% ;
3477 height : auto ;
0 commit comments