diff --git a/lib/plugins/tag/post_link.js b/lib/plugins/tag/post_link.js index d8d94fbfb8..553e7599ce 100644 --- a/lib/plugins/tag/post_link.js +++ b/lib/plugins/tag/post_link.js @@ -8,7 +8,7 @@ const { postFindOneFactory } = require('./'); * Post link tag * * Syntax: - * {% post_link slug [title] [escape] %} + * {% post_link slug | title [title] [escape] %} */ module.exports = ctx => { return function postLinkTag(args) { @@ -24,7 +24,8 @@ module.exports = ctx => { escape = 'true'; } - const post = postFindOneFactory(ctx)({ slug }); + const factory = postFindOneFactory(ctx); + const post = factory({ slug }) || factory({ title: slug }); if (!post) { throw new Error(`Post not found: post_link ${slug}.`); } diff --git a/lib/plugins/tag/post_path.js b/lib/plugins/tag/post_path.js index 0b81ed69e9..89346560f4 100644 --- a/lib/plugins/tag/post_path.js +++ b/lib/plugins/tag/post_path.js @@ -8,14 +8,15 @@ const { postFindOneFactory } = require('./'); * Post path tag * * Syntax: - * {% post_path slug %} + * {% post_path slug | title %} */ module.exports = ctx => { return function postPathTag(args) { const slug = args.shift(); if (!slug) return; - const post = postFindOneFactory(ctx)({ slug }); + const factory = postFindOneFactory(ctx); + const post = factory({ slug }) || factory({ title: slug }); if (!post) return; const link = encodeURL(resolve(ctx.config.root, post.path));