设置主页
public setBaseUrl ( string $baseUrl ) : void | ||
$baseUrl | string | 主页地址 |
return | void |
$context->sitemap['/index.html'] = 1; le_do_workflow('build', $template, $target, ['index' => $index]); }); // generate feeds le_add_workflow('generate_feeds', function () use($context) { if (!isset($context->config['feeds'])) { return; } $config = $context->config['feeds']; if (!isset($config['source']) || !isset($context->index[$config['source']])) { return; } $config = array_merge(['title' => isset($context->data['title']) ? $context->data['title'] : 'My Feeds', 'description' => isset($context->data['description']) ? $context->data['description'] : 'My Feeds Description', 'recent' => 20, 'target' => 'feeds.xml', 'url' => isset($context->data['url']) ? $context->data['url'] : '/'], $config); $feedsUrl = rtrim($config['url'], '/') . '/' . ltrim($config['target'], '/'); $feeds = new \Atom(); $feeds->setBaseUrl($config['url']); $feeds->setFeedUrl($feedsUrl); $feeds->setTitle($config['title']); $feeds->setSubTitle($config['description']); $posts = array_slice($context->index[$config['source']], 0, $config['recent']); foreach ($posts as $post) { $post = le_do_workflow('get_post', $config['source'], $post); $item = ['title' => $post['title'], 'link' => $post['permalink'], 'updated' => $post['date'], 'published' => $post['date'], 'author' => isset($config['author']) ? ['name' => $config['author'], 'url' => $config['url']] : NULL, 'content' => $post['content']]; foreach ($context->config['blocks'] as $type => $val) { if (isset($val['source']) && is_string($val['source'])) { continue; } if ('archive' != $type && !empty($post[$type])) { foreach ($post[$type] as $meta) { $item['category'][] = ['feeds_url' => $meta['url'], 'name' => $meta['name']]; }