增加 keywords (#280)

This commit is contained in:
i-abc 2023-03-29 12:40:02 +08:00 committed by GitHub
parent e0ee1d8198
commit 8451c546b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 0 deletions

View File

@ -37,6 +37,17 @@ function generate_description() {
} }
return '<meta name="description" content="' + config.description + '">'; return '<meta name="description" content="' + config.description + '">';
} }
function generate_keywords() {
if (page.keywords && page.keywords.length > 0) {
return '<meta name="keywords" content="' + page.keywords + '">';
} else if (page.tags && page.tags.length > 0) {
return '<meta name="keywords" content="' + page.tags.map(tag => tag.name).join(',') + '">';
} else if (config.keywords && config.keywords.length > 0) {
return '<meta name="keywords" content="' + config.keywords + '">';
} else {
return '';
}
}
function generate_robots() { function generate_robots() {
if (is_home() == true) { if (is_home() == true) {
@ -83,6 +94,8 @@ function og_args() {
<% } %> <% } %>
<%- generate_description() %> <%- generate_description() %>
<%- generate_keywords() %>
<!-- feed --> <!-- feed -->
<% if (config.feed && config.feed.path) { %> <% if (config.feed && config.feed.path) { %>
<%- feed_tag(config.feed.path, {title: config.title}) %> <%- feed_tag(config.feed.path, {title: config.title}) %>