mirror of
https://github.com/danpros/htmly.git
synced 2026-04-18 11:36:20 +05:30
Allow to change the post permalink prefix
Example: /blog/post-slug
This commit is contained in:
parent
435f871162
commit
a473482da8
5 changed files with 60 additions and 57 deletions
|
|
@ -399,7 +399,6 @@ function get_posts($posts, $page = 1, $perpage = 0)
|
|||
$auto = config('toc.automatic');
|
||||
$counter = config('views.counter');
|
||||
$caption = config('fig.captions');
|
||||
$permalink = config('permalink.type');
|
||||
|
||||
if ($counter == 'true') {
|
||||
$viewsFile = "content/data/views.json";
|
||||
|
|
@ -469,10 +468,10 @@ function get_posts($posts, $page = 1, $perpage = 0)
|
|||
// The archive per day
|
||||
$post->archive = site_url() . 'archive/' . date('Y-m', $post->date);
|
||||
|
||||
if ($permalink == 'post') {
|
||||
$post->url = site_url() . 'post/' . str_replace('.md', '', $arr[2]);
|
||||
} else {
|
||||
if (permalink_type() == 'default') {
|
||||
$post->url = site_url() . date('Y/m', $post->date) . '/' . str_replace('.md', '', $arr[2]);
|
||||
} else {
|
||||
$post->url = site_url() . permalink_type() . '/' . str_replace('.md', '', $arr[2]);
|
||||
}
|
||||
|
||||
$post->slug = str_replace('.md', '', $arr[2]);
|
||||
|
|
@ -3085,10 +3084,10 @@ function sitemap_post_path($posts, $page = 1, $perpage = 0)
|
|||
$post->archiveyear = site_url() . 'archive/' . date('Y', $post->date);
|
||||
|
||||
// The post URL
|
||||
if (config('permalink.type') == 'post') {
|
||||
$post->url = site_url() . 'post/' . str_replace('.md', '', $arr[2]);
|
||||
} else {
|
||||
if (permalink_type() == 'default') {
|
||||
$post->url = site_url() . date('Y/m', $post->date) . '/' . str_replace('.md', '', $arr[2]);
|
||||
} else {
|
||||
$post->url = site_url() . permalink_type() . '/' . str_replace('.md', '', $arr[2]);
|
||||
}
|
||||
|
||||
$tmp[] = $post;
|
||||
|
|
@ -3492,6 +3491,16 @@ function is_index()
|
|||
}
|
||||
}
|
||||
|
||||
// Return post permalink type
|
||||
function permalink_type()
|
||||
{
|
||||
$permalink = config('permalink.type');
|
||||
if (!is_null($permalink) && !empty($permalink)) {
|
||||
return strtolower($permalink);
|
||||
}
|
||||
return 'default';
|
||||
}
|
||||
|
||||
// Return blog path index
|
||||
function blog_path()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue