[pl][blog] display most important posts prominently
This commit is contained in:
parent
8a8e80d820
commit
1d898a39a8
|
@ -8,7 +8,7 @@
|
|||
<nuxt-link :to="generateLink(post.slug)" class="card-body text-center h4 p-3 mb-0">
|
||||
<Spelling :text="post.title"/>
|
||||
</nuxt-link>
|
||||
<div class="card-footer small">
|
||||
<div v-if="details" class="card-footer small">
|
||||
<ul class="list-inline mb-0">
|
||||
<li class="list-inline-item small">
|
||||
<Icon v="calendar"/>
|
||||
|
@ -36,6 +36,7 @@
|
|||
export default {
|
||||
props: {
|
||||
posts: { required: true },
|
||||
details: { type: Boolean },
|
||||
},
|
||||
data() {
|
||||
const shortcuts = {};
|
||||
|
@ -58,7 +59,7 @@
|
|||
? `/${this.shortcuts[slug]}`
|
||||
: `/blog/${slug}`;
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
|
|
|
@ -1724,13 +1724,13 @@ census:
|
|||
blog:
|
||||
shortcuts:
|
||||
manifest: 'manifest'
|
||||
grupy: 'jak-zwracać-się-do-grup'
|
||||
formularze: 'rekomendacja-formularze'
|
||||
ktosio: 'zaimki-nie-tylko-osobowe'
|
||||
tłumaczenie: 'ściągawka-tłumaczenie'
|
||||
autokorekta: 'autokorekta'
|
||||
grupy: 'jak-zwracać-się-do-grup'
|
||||
liczebniki: 'inkluzywne-liczebniki'
|
||||
zaimki-postpłciowe: 'zaimki-postpłciowe'
|
||||
formularze: 'rekomendacja-formularze'
|
||||
|
||||
redirects:
|
||||
- { from: '^/slowniki/neutratywy$', to: '/neutratywy' }
|
||||
|
|
|
@ -231,12 +231,14 @@ export default {
|
|||
if (config.links.blog) {
|
||||
routes.push({ path: '/' + encodeURIComponent(config.links.blogRoute), component: resolve(__dirname, 'routes/blog.vue'), name: 'blog' });
|
||||
routes.push({ path: '/' + encodeURIComponent(config.links.blogRoute) + '/:slug', component: resolve(__dirname, 'routes/blogEntry.vue'), name: 'blogEntry' });
|
||||
if (config.blog && config.blog.shortcuts) {
|
||||
for (let shortcut in config.blog.shortcuts) {
|
||||
if (!config.blog.shortcuts.hasOwnProperty(shortcut)) { continue; }
|
||||
const slug = config.blog.shortcuts[shortcut];
|
||||
routes.push({ path: '/' + encodeURIComponent(shortcut), component: resolve(__dirname, 'routes/blogEntry.vue'), meta: {slug}, name: 'blogEntryShortcut:' + shortcut });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (config.links.zine && config.links.zine.enabled) {
|
||||
routes.push({ path: '/' + encodeURIComponent(config.links.zine.route), component: resolve(__dirname, 'routes/zine.vue') });
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<Icon v="pen-nib"/>
|
||||
<T>links.blog</T>
|
||||
</h2>
|
||||
<BlogEntriesList :posts="posts"/>
|
||||
<BlogEntriesList :posts="posts" details/>
|
||||
<Separator icon="heart"/>
|
||||
<Support/>
|
||||
<section>
|
||||
|
|
|
@ -60,6 +60,13 @@
|
|||
</div>
|
||||
</section>
|
||||
|
||||
<template v-if="posts.length">
|
||||
<Separator icon="pen-nib" class="mb-5"/>
|
||||
<section>
|
||||
<BlogEntriesList :posts="posts"/>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<Separator icon="heart"/>
|
||||
<section>
|
||||
<Support/>
|
||||
|
@ -100,7 +107,13 @@
|
|||
})
|
||||
}
|
||||
|
||||
return { mainLinks };
|
||||
}
|
||||
return {
|
||||
mainLinks,
|
||||
posts: [],
|
||||
};
|
||||
},
|
||||
async mounted() {
|
||||
this.posts = await this.$axios.$get(`/blog?shortcuts`);
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<Icon v="pen-nib"/>
|
||||
<T>links.blog</T>
|
||||
</h2>
|
||||
<BlogEntriesList :posts="posts"/>
|
||||
<BlogEntriesList :posts="posts" details/>
|
||||
</section>
|
||||
<Links/>
|
||||
<Recommended/>
|
||||
|
|
|
@ -6,7 +6,7 @@ import { caches } from "../../src/cache";
|
|||
const router = Router();
|
||||
|
||||
router.get('/blog', handleErrorAsync(async (req, res) => {
|
||||
return res.json(await caches.blog.fetch(async () => {
|
||||
const posts = await caches.blog.fetch(async () => {
|
||||
const dir = __dirname + '/../../data/blog';
|
||||
const posts = [];
|
||||
fs.readdirSync(dir).forEach(file => {
|
||||
|
@ -57,12 +57,25 @@ router.get('/blog', handleErrorAsync(async (req, res) => {
|
|||
posts.push({slug, title, date, authors, hero});
|
||||
});
|
||||
|
||||
return posts.sort((a, b) => {
|
||||
posts.sort((a, b) => {
|
||||
if (a.date < b.date) { return 1; }
|
||||
if (a.date > b.date) { return -1; }
|
||||
return 0;
|
||||
});
|
||||
}));
|
||||
|
||||
return posts;
|
||||
})
|
||||
|
||||
if (req.query.shortcuts !== undefined && global.config.blog && global.config.blog.shortcuts) {
|
||||
const postsShortcuts = [];
|
||||
for (let slug of Object.values(global.config.blog.shortcuts)) {
|
||||
postsShortcuts.push(posts.filter(p => p.slug === slug)[0])
|
||||
}
|
||||
|
||||
return res.json(postsShortcuts);
|
||||
}
|
||||
|
||||
return res.json(posts);
|
||||
}));
|
||||
|
||||
export default router;
|
||||
|
|
Reference in New Issue