diff --git a/docs/content/getting-started/publish-site.md b/docs/content/getting-started/publish-site.md index 471fe07..b05ea5e 100644 --- a/docs/content/getting-started/publish-site.md +++ b/docs/content/getting-started/publish-site.md @@ -69,4 +69,10 @@ deploy: buildDir: dist username: devlive-community email: support@devlive.org +``` + +使用以下命令发布到 Github Pages: + +```bash +pageforge deploy-github ``` \ No newline at end of file diff --git a/lib/indexer-generator.js b/lib/indexer-generator.js index e363df6..107a458 100644 --- a/lib/indexer-generator.js +++ b/lib/indexer-generator.js @@ -1,6 +1,6 @@ const fs = require('fs'); const path = require('path'); -const { isFeatureEnabled } = require('./utils'); +const {isFeatureEnabled} = require('./utils'); class SearchIndexBuilder { constructor(config, pages, getNavigation) { @@ -18,7 +18,9 @@ class SearchIndexBuilder { // 处理导航项 processNavItem(item, lang) { - if (!item) return; + if (!item) { + return; + } if (item.href) { // 将 /.html 转换为 /index.html @@ -32,7 +34,7 @@ class SearchIndexBuilder { const filePath = this.getFilePath(normalizedHref); if (filePath && fs.existsSync(filePath)) { const content = fs.readFileSync(filePath, 'utf-8'); - const { title, processedContent } = this.parseContent(content, filePath); + const {title, processedContent} = this.parseContent(content, filePath); // 构建搜索项 const searchItem = { @@ -101,7 +103,7 @@ class SearchIndexBuilder { // 清理 Markdown 语法 processedContent = this.cleanMarkdown(processedContent); - return { title, processedContent }; + return {title, processedContent}; } // 清理 Markdown 语法 diff --git a/templates/assets/js/pageforge-search.js b/templates/assets/js/pageforge-search.js index 2b7033c..52c60b2 100644 --- a/templates/assets/js/pageforge-search.js +++ b/templates/assets/js/pageforge-search.js @@ -204,22 +204,23 @@ const Search = { this.els.searchResults.innerHTML = `
${results.map(result => { - const highlightedTitle = this.highlightText(result.title, query); - const contentExcerpt = this.getContentExcerpt(result.content, query); - const highlightedContent = this.highlightText(contentExcerpt, query); - - return ` + const highlightedTitle = this.highlightText(result.title, query); + const contentExcerpt = this.getContentExcerpt(result.content, query); + const highlightedContent = this.highlightText(contentExcerpt, query); + + return `
${highlightedTitle} + ${result.lang ? `${result.lang}` : ''}
${highlightedContent}
`; - }).join('')} + }).join('')}
`; } diff --git a/templates/includes/header-nav.ejs b/templates/includes/header-nav.ejs index c8499a6..94b2666 100644 --- a/templates/includes/header-nav.ejs +++ b/templates/includes/header-nav.ejs @@ -1,15 +1,18 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/templates/includes/header.ejs b/templates/includes/header.ejs index a824d76..c0ab1e9 100644 --- a/templates/includes/header.ejs +++ b/templates/includes/header.ejs @@ -37,13 +37,13 @@ const darkClasses = (classes) => darkModeEnabled ? classes : ''; <%- include('./header-nav', { darkClasses, isPathInNavItem }) %> - - - <%- include('./header-search', { darkClasses }) %>
+ + <%- include('./header-search', { darkClasses }) %> + <% if (darkModeEnabled) { %>