Skip to content

Commit 8d5b271

Browse files
committed
metaタグで多言語化が必要な分をlayouts/default.vueに移動
1 parent 1b4946c commit 8d5b271

File tree

2 files changed

+67
-49
lines changed

2 files changed

+67
-49
lines changed

nuxt.config.js

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -14,63 +14,16 @@ export default {
1414
htmlAttrs: {
1515
prefix: 'og: http://ogp.me/ns#',
1616
},
17-
title: 'おうちで時間割',
1817
meta: [
1918
{ charset: 'utf-8' },
2019
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
21-
{
22-
hid: 'keyword',
23-
name: 'keyword',
24-
content: 'CodeforJapan, おうちで時間割, デジタル, 学び, 今後の学習',
25-
},
2620
{
2721
hid: 'author',
2822
name: 'author',
2923
content: 'Code for Japan',
3024
},
31-
{
32-
hid: 'og:site_name',
33-
property: 'og:site_name',
34-
content: 'おうちで時間割',
35-
},
36-
{
37-
hid: 'og:url',
38-
property: 'og:url',
39-
content: `https://app.studyathome.jp/`,
40-
},
41-
{
42-
hid: 'og:title',
43-
property: 'og:title',
44-
content: 'おうちで時間割',
45-
},
46-
{
47-
hid: 'og:description',
48-
property: 'og:description',
49-
content:
50-
'子どもの学びにデジタルの活用を - 臨時休校期間と今後の学習に向けて 簡単に楽しく学べる環境を今だから、みんなでつくろう。',
51-
},
52-
{
53-
hid: 'apple-mobile-web-app-title',
54-
name: 'apple-mobile-web-app-title',
55-
content: 'おうちで時間割',
56-
},
57-
{
58-
hid: 'description',
59-
name: 'description',
60-
content:
61-
'子どもの学びにデジタルの活用を - 臨時休校期間と今後の学習に向けて 簡単に楽しく学べる環境を今だから、みんなでつくろう。',
62-
},
6325
{ hid: 'og:type', property: 'og:type', content: 'website' },
64-
{
65-
hid: 'og:image',
66-
property: 'og:image',
67-
content: 'https://app.studyathome.jp/ogp.png',
68-
},
69-
{
70-
hid: 'twitter:image',
71-
name: 'twitter:image',
72-
content: 'https://app.studyathome.jp/ogp.png',
73-
},
26+
{ name: 'twitter:card', content: 'summary_large_image' },
7427
],
7528
link: [
7629
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },

src/layouts/default.vue

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,73 @@ export default Vue.extend({
3737
loading: true,
3838
}
3939
},
40+
head() {
41+
const ogpImage = () => {
42+
switch (this.$i18n.locale) {
43+
case 'zh-tw':
44+
return `https://app.studyathome.jp/ogp-${this.$i18n.locale}.png`
45+
default:
46+
return 'https://app.studyathome.jp/ogp.png'
47+
}
48+
}
49+
return {
50+
title: this.$tc('title'),
51+
meta: [
52+
{
53+
hid: 'description',
54+
name: 'description',
55+
content: this.$tc('description'),
56+
},
57+
{
58+
hid: 'apple-mobile-web-app-title',
59+
name: 'apple-mobile-web-app-title',
60+
content: this.$tc('title'),
61+
},
62+
{
63+
hid: 'og:title',
64+
property: 'og:title',
65+
content: this.$tc('title'),
66+
},
67+
{
68+
hid: 'og:description',
69+
property: 'og:description',
70+
content: this.$tc('description'),
71+
},
72+
{
73+
hid: 'og:site_name',
74+
property: 'og:site_name',
75+
content: this.$tc('title'),
76+
},
77+
{
78+
hid: 'og:image',
79+
property: 'og:image',
80+
content: ogpImage(),
81+
},
82+
{
83+
hid: 'og:image:width',
84+
property: 'og:image:width',
85+
content: '1200',
86+
},
87+
{
88+
hid: 'og:image:height',
89+
property: 'og:image:height',
90+
content: '630',
91+
},
92+
{
93+
hid: 'twitter:image',
94+
name: 'twitter:image',
95+
content: ogpImage(),
96+
},
97+
{
98+
hid: 'og:url',
99+
property: 'og:url',
100+
content: `https://app.studyathome.jp${this.$route.path}`,
101+
},
102+
],
103+
}
104+
},
40105
mounted(): void {
41-
this.loading = false
106+
;(this as any).loading = false
42107
},
43108
})
44109
</script>

0 commit comments

Comments
 (0)