Giter Club home page Giter Club logo

Comments (2)

x-cold avatar x-cold commented on May 26, 2024

这个功能尚未实现,可以 MR 提供一下~

from yuque-hexo.

allen-wong avatar allen-wong commented on May 26, 2024

这是加入categories front-matter的关键代码,目前hexo本身并没有显示目录的功能。我认为这不是本插件能解决的。
第73行改成这样:const { config, client, toc, _cachedArticles } = this;

lib\Downloader.js 77行插入以下代码(写得丑,自己优化一下)

        if (config.autoFrontMatter) { // 自己在package.js添加配置项
          let categories = new Array();
          const getCategories = function (toc, item) { // 根据toc生成categories
            for (let i = 0; i < toc.length; i++) {
              if (toc[i].uuid === item.parent_uuid) {
                categories.push(toc[i].title);
                if (!!toc[i].parent_uuid) {
                  getCategories(toc, toc[i]);
                } else {
                  break;
                }
              }
            }
          }
          for (let i = 0; i < toc.length; i++) { // 取得文章对应知识库的目标项
            if (toc[i].type === 'DOC' && toc[i].id == article.id) {
              getCategories(toc, toc[i]);
            }
          }
          const str_categories = categories.length < 1 ? '' : `categories:\n- ${categories.length > 1 ? '[' + categories.join(',') + ']' : categories[0]}\n`;
          const front_matter = `---\ntitle: ${article.title}\ndate: ${article.created_at}\nupdated: ${article
            .updated_at}\n${str_categories}---\n`;
          article.body = front_matter + article.body;
        }

from yuque-hexo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.