Comments (14)
Wow, thank you so much! Now I got it!
from hexo-theme-phantom.
Sorry for the late reply, I have been busy starting a new job.
you will have to define what is the order of importance in the front matter then you can go here:
https://github.com/klugjo/hexo-theme-phantom/blob/master/layout/index.ejs#L7
And you have access to all the posts, so order them whichever way you like.
from hexo-theme-phantom.
Thanks for replying! But I am still a little confused about that. Is there any example of that? For example, I have articles called A and B, and then how to define the order in this "index.ejs" file?
from hexo-theme-phantom.
So you want to sort by name ?
from hexo-theme-phantom.
No, I want to sort by the importance. But I have no idea how to define the order.
from hexo-theme-phantom.
what is importance ? It is not a default hexo parameter
from hexo-theme-phantom.
For example, say I have "A" and "B". I write "A" first and normally, it will be in the second place. But I still want it to be the first one in the display. Is it possible to do that?
from hexo-theme-phantom.
As I said you need to defined it in front matter then modify the sort order in the file I indicated
from hexo-theme-phantom.
https://hexo.io/docs/front-matter.html
from hexo-theme-phantom.
for example
first post:
title: Hello World
date: 2013/7/13 20:46:25
importance: 1
second post:
title: Hello World 2
date: 2013/7/13 20:46:25
importance: 2
---
then you can do something like
<section class="tiles">
<%
// Fast array clone
var sortedPosts = page.posts.slice(0);
sortedPosts.sort(function(a, b){
return a.importance < b.importance
});
%>
<% sortedPosts.forEach(function(item, index){ %>
<%- partial('_partial/article-index', {item: item, index: index}) %>
<% }); %>
</section>
from hexo-theme-phantom.
Sorry to bother again. I understand what you said, and copy and paste the code. But it still keeps the same order.
/Users/weijiawu/blog/source/_posts/A.md
---
title: Medical Device for foot pressure
date: 2018-04-03 19:57:46
tags: Sensor
cover_index: /images/Medical Device.jpg
importance: 5
---
/Users/weijiawu/blog/source/_posts/B.md
---
title: Self-Balance Bike with Inverted Pendulum
date: 2018-04-02 12:13:09
tags:
Control
Robotics
cover_index: /images/Inverted Pendulum Cover.jpg
importance: 7
---
/Users/weijiawu/blog/themes/phantom/layout/index.ejs
<header>
<h1><%- theme.subtitle_main %></h1>
<p><%- theme.susbtitle_secondary %></p>
</header>
<section class="tiles">
<%
// Fast array clone
var sortedPosts = page.posts.slice(0);
sortedPosts.sort(function(a, b){
return a.importance < b.importance
});
%>
<% sortedPosts.forEach(function(item, index){ %>
<%- partial('_partial/article-index', {item: item, index: index}) %>
<% }); %>
</section>
<%- partial('_partial/pagination') %>
from hexo-theme-phantom.
Have you tried return a.importance > b.importance
from hexo-theme-phantom.
Yes, I tried but still failed.
from hexo-theme-phantom.
I suddenly know how to solve it! Just in the "_config.yml" and change the section"order_by: -date" to "order_by: -importance". Then it is solved!
from hexo-theme-phantom.
Related Issues (20)
- Home page articles not 3 column arrangement in IE9 desktop
- Theme Alpha-Dust is not support by GitHub Page HOT 1
- Custom css and js HOT 1
- can this theme generate the Tags or Category index page? Can you that help me out in telling how? HOT 3
- Using custom grid with markdown in posts and pages HOT 2
- How can i set website favicon ? HOT 1
- 怎么开启文章预览
- How to support disqus ? Or any other comment plugin?
- how to config a favicon for website. HOT 3
- Dont work with github pages HOT 3
- 请问怎么设置文章封面图片
- How to make image in the post auto re-size? HOT 3
- How to insert Gallery in post ?
- How to make the page load with the Nav bar as default
- I did not understand: why 10 although it should be 9 HOT 1
- no index file HOT 1
- How can use "READ MORE"
- picture cannot be displayed
- implement: auto resize photo according to the window size of the browser
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hexo-theme-phantom.