Skip to content
This repository was archived by the owner on Dec 1, 2023. It is now read-only.

Commit 1aa51a9

Browse files
Open Graph support
1 parent 283f55a commit 1aa51a9

File tree

4 files changed

+45
-2
lines changed

4 files changed

+45
-2
lines changed

app/components/post-meta.vue

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<template>
2+
3+
<div class="uk-form-horizontal">
4+
5+
<div class="uk-form-row">
6+
<label for="form-class" class="uk-form-label">{{ 'Title' | trans }}</label>
7+
<div class="uk-form-controls">
8+
<input id="form-class" class="uk-form-width-large" type="text" v-model="post.data.meta['og:title']">
9+
</div>
10+
</div>
11+
12+
<div class="uk-form-row">
13+
<label for="form-class" class="uk-form-label">{{ 'Description' | trans }}</label>
14+
<div class="uk-form-controls">
15+
<textarea id="form-class" class="uk-form-width-large" rows="5" type="text" v-model="post.data.meta['og:description']"></textarea>
16+
</div>
17+
</div>
18+
19+
</div>
20+
21+
</template>
22+
23+
<script>
24+
25+
module.exports = {
26+
27+
section: {
28+
label: 'Meta',
29+
priority: 100
30+
},
31+
32+
props: ['post']
33+
34+
};
35+
36+
window.Post.components['post-meta'] = module.exports;
37+
38+
</script>

index.php

+1
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@
163163

164164
'view.scripts' => function ($event, $scripts) {
165165
$scripts->register('link-blog', 'blog:app/bundle/link-blog.js', '~panel-link');
166+
$scripts->register('post-meta', 'blog:app/bundle/post-meta.js', '~post-edit');
166167
}
167168

168169
]

src/Controller/SiteController.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,10 @@ public function postAction($id = 0)
133133
return [
134134
'$view' => [
135135
'title' => __($post->title),
136-
'name' => 'blog/post.php'
136+
'name' => 'blog/post.php',
137+
'og:title' => $post->get('meta.og:title') ?: $post->title,
138+
'og:description' => $post->get('meta.og:description') ?: $post->excerpt,
139+
'og:image' => $post->get('image.src') ? App::url()->getStatic($post->get('image.src'), [], 0) : false
137140
],
138141
'$comments' => [
139142
'config' => [

webpack.config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ module.exports = [
99
"comments": "./app/views/comments",
1010
"post": "./app/views/post",
1111
"posts": "./app/views/posts",
12-
"link-blog": "./app/components/link-blog.vue"
12+
"link-blog": "./app/components/link-blog.vue",
13+
"post-meta": "./app/components/post-meta.vue"
1314
},
1415
output: {
1516
filename: "./app/bundle/[name].js"

0 commit comments

Comments
 (0)