Skip to content

Commit

Permalink
fix: make page title optional
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed Dec 16, 2018
1 parent a9e84d3 commit 9f34e95
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
6 changes: 5 additions & 1 deletion src/css/markdown.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
@import "vars.css";

.markdown-body {
& >*:first-child:not(h2) {
& >*:first-child {
margin-top: 0;
}

&.has-page-title >h2:first-child {
margin-top: 7rem;
}

& a {
text-decoration: none;

Expand Down
10 changes: 7 additions & 3 deletions src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
</div>
<div class="Main" v-else>
<InjectedComponents position="main:start" />
<component :is="MarkdownTitle" class="page-title" />
<component :is="MarkdownBody" />
<component v-if="pageTitle" :is="MarkdownTitle" class="page-title" />
<component :class="{'has-page-title': pageTitle}" :is="MarkdownBody" />
<EditLink />
<PrevNextLinks />
<InjectedComponents position="main:end" />
Expand Down Expand Up @@ -85,10 +85,14 @@ export default {
},
computed: {
pageTitle() {
return this.$store.state.page.title
},
MarkdownTitle() {
return {
name: 'MarkdownTitle',
template: `<h1>${this.$store.state.page.title}</h1>`
template: `<h1>${this.pageTitle}</h1>`
}
},
Expand Down
23 changes: 12 additions & 11 deletions website/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ new Docute({
{
title: 'Credits',
link: '/credits'
},
{
title: 'Changelog',
link: '/changelog'
}
]
}
Expand Down Expand Up @@ -190,17 +194,14 @@ new Docute({
]
}
},
pageData: () => fetch('https://jsonplaceholder.typicode.com/posts')
.then(res => res.json())
.then(posts => {
return posts.reduce((result, post) => {
result['/post/' + post.id] = {
title: post.title,
content: post.body
}
return result
}, {})
})
pageData: () => {
return {
'/changelog': {
title: 'Changelog',
file: 'https://raw.githubusercontent.com/leptosia/docute/master/CHANGELOG.md'
}
}
}
})

Vue.component('ReverseText', {
Expand Down

0 comments on commit 9f34e95

Please sign in to comment.