Giter Club home page Giter Club logo

Comments (8)

realDuang avatar realDuang commented on May 24, 2024 1

感谢更新,但是功能实现有些问题,我看了下代码,下面这一段mode为function与字符串的情况不是等价的。

const titleSort = (obj, mode, key = "filename") => Object.values(obj).forEach(s => {
  if (typeof mode === "function") {
    return s.sort(mode);
  }

  s.sort((SORT_OPTIONS[mode] || SORT_OPTIONS["asc"])(key))
});

应该是:

  if (typeof mode === "function") {
    return s.sort(mode(key));
  }

以解构高阶。

BTW,如果必须要实现高阶的目的是为了指定一个key值的话,那为什么不把key导出来呢?

from vuepress-plugin-auto-sidebar.

shanyuhai123 avatar shanyuhai123 commented on May 24, 2024

好的,感谢您的意见,大概晚上更新一下。

from vuepress-plugin-auto-sidebar.

shanyuhai123 avatar shanyuhai123 commented on May 24, 2024

你是对的,我搞错了。
导出 key 暂时没有好的思路。

from vuepress-plugin-auto-sidebar.

shanyuhai123 avatar shanyuhai123 commented on May 24, 2024

你 closed 的 pr 我可以 reopen 吗

from vuepress-plugin-auto-sidebar.

realDuang avatar realDuang commented on May 24, 2024

你 closed 的 pr 我可以 reopen 吗

嗯嗯可以的。

from vuepress-plugin-auto-sidebar.

realDuang avatar realDuang commented on May 24, 2024

关于导出key,我的想法是,将导出的排序规则对象化。利用重载判断sort还是挺难维护的。

大概长成这样

interface sortOptions {
   sortMode: 'asc' || 'desc' || 'custom',
   sortFn?: Function,
   sortKey: String
 }

但这可能包含一个breaking change,所以需要你取舍一下啦

from vuepress-plugin-auto-sidebar.

hzmming avatar hzmming commented on May 24, 2024

请问可以按时间排序么?谢谢

from vuepress-plugin-auto-sidebar.

shanyuhai123 avatar shanyuhai123 commented on May 24, 2024

请问可以按时间排序么?谢谢

已支持,可以指定 sort 的 mode 为 created_time_asc 或 created_time_desc

from vuepress-plugin-auto-sidebar.

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.