Skip to content

Commit

Permalink
2024.5.20 modified
Browse files Browse the repository at this point in the history
  • Loading branch information
icebooka committed May 20, 2024
1 parent f153830 commit 76325b4
Show file tree
Hide file tree
Showing 47 changed files with 510 additions and 70 deletions.
87 changes: 56 additions & 31 deletions .eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,70 @@ const { DateTime } = require('luxon')
const navigationPlugin = require('@11ty/eleventy-navigation')
const rssPlugin = require('@11ty/eleventy-plugin-rss')


module.exports = (config) => {
config.addPlugin(navigationPlugin);
config.addPlugin(rssPlugin);
config.addPlugin(navigationPlugin);
config.addPlugin(rssPlugin);

config.addPassthroughCopy('css');
config.addPassthroughCopy('static');
config.addPassthroughCopy('css');
config.addPassthroughCopy('static');
config.addPassthroughCopy("posts/pictures");
config.addPassthroughCopy("extensions/pictures");

config.setDataDeepMerge(true);
config.setDataDeepMerge(true);

config.addFilter('htmlDateString', (dateObj) => {
return DateTime.fromJSDate(dateObj, {zone: 'utc'}).toFormat('yyyy-LL-dd');
});
config.addFilter('htmlDateString', (dateObj) => {
return DateTime.fromJSDate(dateObj, {zone: 'utc'}).toFormat('yyyy-LL-dd');
});

config.addFilter("readableDate", dateObj => {
return DateTime.fromJSDate(dateObj, {zone: 'utc'}).toFormat("dd LLL, yyyy");
});
config.addFilter("readableDate", dateObj => {
return DateTime.fromJSDate(dateObj, {zone: 'utc'}).toFormat("dd LLL, yyyy");
});

config.addCollection("tagList", collection => {
const tagsObject = {}
collection.getAll().forEach(item => {
if (!item.data.tags) return;
item.data.tags
.filter(tag => !['post', 'all'].includes(tag))
.forEach(tag => {
if(typeof tagsObject[tag] === 'undefined') {
tagsObject[tag] = 1
} else {
tagsObject[tag] += 1
}
config.addCollection("tagList", collection => {
const tagsObject = {}
collection.getAll().forEach(item => {
if (!item.data.tags) return;
item.data.tags
.filter(tag => !['post', 'all'].includes(tag))
.forEach(tag => {
if(typeof tagsObject[tag] === 'undefined') {
tagsObject[tag] = 1
} else {
tagsObject[tag] += 1
}
});
});
const tagList = []
Object.keys(tagsObject).forEach(tag => {
tagList.push({ tagName: tag, tagCount: tagsObject[tag] })
})
return tagList.sort((a, b) => b.tagCount - a.tagCount)
});

const tagList = []
Object.keys(tagsObject).forEach(tag => {
tagList.push({ tagName: tag, tagCount: tagsObject[tag] })
})
return tagList.sort((a, b) => b.tagCount - a.tagCount)

});
config.addCollection("categoryList", collection => {
const categoriesObject = {};
collection.getAll().forEach(item => {
if (!item.data.categories) return;
item.data.categories
.filter(categories => !['extensions', 'all'].includes(categories))
.forEach(category => {
if(typeof categoriesObject[category] === 'undefined') {
categoriesObject[category] = { categoryName: category, categoryCount: 1, posts: [item] };
} else {
categoriesObject[category].categoryCount++;
categoriesObject[category].posts.push(item);
}
});
});
const categoryList = [];
Object.keys(categoriesObject).forEach(category => {
categoryList.push({
categoryName: category,
categoryCount: categoriesObject[category].categoryCount,
posts: categoriesObject[category].posts
});
});
return categoryList.sort((a, b) => b.categoryCount - a.categoryCount);
});

}
18 changes: 18 additions & 0 deletions _includes/components/extensionslist.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<div class="card-grid">
{% for extension in extensions %}
<div class="card">
<h3 class="card__title">
<a href="{{ extension.url | url }}">{{ extension.data.title }}</a>
</h3>
<p class="card__date">{{ extension.date | readableDate }}</p>
<p class="card__description">{{ extension.data.description }}</p>
<p class="card__subtitle">分类:</p>
<div class="card__categories">
{% for category in extension.data.categories %}
<a href="{{ '/categories/' | url }}{{ category }}">{{ category }}</a>
{%- if not loop.last %}, {% endif %}
{% endfor %}
</div>
</div>
{% endfor %}
</div>
4 changes: 2 additions & 2 deletions _includes/components/postslist.njk
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
</h3>
<p class="card__date">{{ post.date | readableDate }}</p>
<p class="card__description">{{ post.data.description }}</p>
<p class="card__subtitle">Tags:</p>
<p class="card__subtitle">标签:</p>
<div class="card__tags">
{% for tag in post.data.tags %}
{% if tag != 'post' %}
<a href="{{ '/tags/' | url }}{{ tag | slug }}">{{ tag }}</a>
<a href="{{ '/tags/' | url }}{{ tag }}">{{ tag }}</a>
{%- if not loop.last %}, {% endif %}
{% endif %}
{% endfor %}
Expand Down
2 changes: 1 addition & 1 deletion _includes/layouts/base.njk
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

<link rel="shortcut icon" href="{{ '/static/img/favicon.ico' | url }}" type="image/x-icon">
<link rel="stylesheet" href="{{ '/static/css/main.css' | url }}" media="all">

</head>
<body>

{% include 'components/navbar.njk' %}
{{ content | safe }}
{% include 'components/footer.njk' %}
Expand Down
28 changes: 28 additions & 0 deletions _includes/layouts/extensions.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
layout: layouts/base.njk
---

<div class="container">
<h1>
{% if icon %}
<img src="../{{ icon }}" alt="图标" style="width: auto; height: 70px;"/>
{% endif %}
{{ title }}
</h1>
<br>
{% if not hideCategoriesList %}
<b>扩展分类: </b>
{% for category in categories %}
{% if category != "extensions" %}
<a href="{{ '/categories/' | url }}{{ category }}">{{ category }}</a>
{%- if not loop.last %}, {% endif %}
{% endif%}
{% endfor %}
{% endif %}
<br><hr>

{{ content | safe }}

<br><br>
<a href="{{ '/' | url }}">&larr; 回到主页</a>
</div>
36 changes: 22 additions & 14 deletions _includes/layouts/post.njk
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,27 @@ layout: layouts/base.njk
---

<div class="container">
<h1>{{ title }}</h1>
{{ content | safe }}
<h1>{{ title }}</h1>
<br>
{% if not hideTagsList %}
<b>标签: </b>
{% for tag in tags %}
{% if tag != 'post' %}
<a href="{{ '/tags/' | url }}{{ tag }}">{{ tag }}</a>
{%- if not loop.last %}, {% endif %}
{% endif %}
{% endfor %}
{% endif %}
<br><hr>

<br><hr>
{% if not hideTagsList %}
<b>标签: </b>
{% for tag in tags %}
{% if tag != 'post' %}
<a href="{{ '/tags/' | url }}{{ tag | slug }}">{{ tag }}</a>
{%- if not loop.last %}, {% endif %}
{% endif %}
{% endfor %}
{% endif %}
<br><br>
<a href="{{ '/' | url }}">&larr; 回到主页</a>
{{ content | safe }}
<script src="https://utteranc.es/client.js"
repo="IceFlow0798/Code-site-comments"
issue-term="title"
theme="github-dark"
crossorigin="anonymous"
async>
</script>
<br><br>
<a href="{{ '/' | url }}">&larr; 回到主页</a>
</div>
30 changes: 30 additions & 0 deletions categories.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
layout: layouts/base.njk
pagination:
data: collections.categoryList
size: 1
alias: category
filter:
- all
- nav
- extension
- extensions
- categoryList
addAllPagesToCollections: true
eleventyComputed:
title: Categorized “{{ category.categoryName }}
permalink: /categories/{{ category.categoryName }}/
---

{% block content %}

<div class="container">
<h1>归属于“{{ category.categoryName }}” 分类</h1>

{% set extensions = category.posts %}
{% include 'components/extensionslist.njk' %}

<p>查看<a href="{{ '/extensions/' | url }}">所有的分类</a>.</p>
</div>

{% endblock %}
27 changes: 27 additions & 0 deletions categorieslist.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
title: 扩展
layout: layouts/base.njk
permalink: /extensions/
eleventyNavigation:
key: 扩展
weight: 1
---

<div class="container">
<h1>扩展分类</h1>
<div class="card-grid">
{% for category in collections.categoryList %}
<div class="card">
<h2 class="card__title">
<a href="{{ '/categories/' | url }}{{ category.categoryName }}">{{ category.categoryName }}</a>
<span class="card__count">({{ category.categoryCount }} 个扩展)</span>
</h2>
<ul>
{% for post in category.posts %}
<li><a href="{{ post.url }}">{{ post.data.title }}</a></li>
{% endfor %}
</ul>
</div>
{% endfor %}
</div>
</div>
10 changes: 10 additions & 0 deletions extensions/AutoRenameTag.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: Auto Rename Tag
categories: ["HTML","标签","自动修改"]
date: 2024-03-20
icon: "/pictures/icons/AutoRenameTag.png"
---

该扩展修改HTML标签时,自动修改匹配的标签。

![修改](../pictures/operations/autoRenameTag_change.gif)
6 changes: 6 additions & 0 deletions extensions/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"layout": "layouts/extensions.njk",
"categories": [
"extensions"
]
}
Binary file added extensions/pictures/icons/AutoRenameTag.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/pictures/operations/1-6-10.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/pictures/operations/1-6-11.webp
Binary file not shown.
Binary file added extensions/pictures/operations/1-6-12.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/pictures/operations/1-6-13.webp
Binary file not shown.
Binary file added extensions/pictures/operations/1-6-14.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/pictures/operations/1-6-15.webp
Binary file not shown.
Binary file added extensions/pictures/operations/1-6-16.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/pictures/operations/1-6-17.webp
Binary file not shown.
Binary file added extensions/pictures/operations/1-6-18.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/pictures/operations/1-6-19.webp
Binary file not shown.
Binary file added extensions/pictures/operations/1-6-2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/pictures/operations/1-6-20.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/pictures/operations/1-6-21.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/pictures/operations/1-6-3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/pictures/operations/1-6-4.webp
Binary file not shown.
Binary file added extensions/pictures/operations/1-6-5-1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/pictures/operations/1-6-5-2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/pictures/operations/1-6-6.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/pictures/operations/1-6-7.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/pictures/operations/1-6-8.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/pictures/operations/1-6-9.webp
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ eleventyNavigation:
{% include "components/postslist.njk" %}
<div class="pagination">
{% if pagination.previous %}
<a href="{{ pagination.href.previous | url }}" class="pagination__prev">&larr; Prev Page</a>
<a href="{{ pagination.href.previous | url }}" class="pagination__prev">&larr; 上一页</a>
{% endif %}
{% if pagination.next %}
<a href="{{ pagination.href.next | url }}" class="pagination__next">Next Page &rarr;</a>
<a href="{{ pagination.href.next | url }}" class="pagination__next">下一页 &rarr;</a>
{% endif %}
</div>
</div>
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@
"build": "npm run build:stylus && npm run build:11ty",
"dev": "concurrently -n stylus,11ty \"npm:watch:stylus\" \"npm:watch:11ty\"",
"start": "npx @11ty/eleventy --serve"
},
"dependencies": {
"lunr": "^2.3.9"
}
}
2 changes: 0 additions & 2 deletions posts/1-1.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ date: 2023-11-01
tags:
- 引入
- 开端
categories:
- vscode
---

这是一个引入。嗯对,**引入**
Expand Down
2 changes: 0 additions & 2 deletions posts/1-2.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ date: 2023-11-06
tags:
- 安装
- 部署
categories:
- vscode
---


Expand Down
2 changes: 0 additions & 2 deletions posts/1-3.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ title: 初步了解Code长啥样,有什么
date: 2023-11-12
tags:
- 界面布局
categories:
- vscode
---


Expand Down
2 changes: 0 additions & 2 deletions posts/1-4.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ title: 码码前的一些准备
date: 2023-11-16
tags:
- 准备工作
categories:
- vscode
---


Expand Down
2 changes: 0 additions & 2 deletions posts/1-5.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ tags:
- git
- 源码
- 管理
categories:
- vscode
---


Expand Down
Loading

0 comments on commit 76325b4

Please sign in to comment.