diff --git a/WebApp/index.html b/WebApp/index.html
index 788fca5..0002b62 100644
--- a/WebApp/index.html
+++ b/WebApp/index.html
@@ -1,92 +1,83 @@
-
-
-
EasyBlog
-
🗽to be a human
-
-
-
-
+
+
EasyBlog
+
🗽to be a human
+
+
+
+
-
-
-
-
-
-
-
-
-
- 👨💻 NilTor
-
- ⏱️
-
-
-
+
+
+
+
+
+
+
+
+
+ 👨💻 NilTor
+
+ ⏱️
+
+
+
-
-
+
+
-
-
-
-
-
存档
-
- 全部 [1]
-
-
- 2024-04 [1]
-
-
+
+
+
+
+
存档
+
+ 全部 [1]
+
+
+ 2024-04 [1]
+
+
-
-
+
+
-
\ No newline at end of file
diff --git a/WebApp/package.json b/WebApp/package.json
deleted file mode 100644
index 1141b82..0000000
--- a/WebApp/package.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "dependencies": {
- "typescript": "^5.4.3"
- }
-}
\ No newline at end of file
diff --git a/WebApp/sitemap.xml b/WebApp/sitemap.xml
index 6bf84b8..fd48f6b 100644
--- a/WebApp/sitemap.xml
+++ b/WebApp/sitemap.xml
@@ -1,7 +1,7 @@
- https://aterdev.github.io/EasyBlog/blogs/introduction.html
+ https://aterdev.github.io/EasyBlog/EasyBlog/blogs/introduction.html
2024-04-07
daily
0.9
diff --git a/WebApp/tailwind.config.js b/WebApp/tailwind.config.js
deleted file mode 100644
index 3cf7ddf..0000000
--- a/WebApp/tailwind.config.js
+++ /dev/null
@@ -1,10 +0,0 @@
-/** @type {import('tailwindcss').Config} */
-module.exports = {
- content: ['./**/*.html'],
- darkMode: ['media'],
- theme: {
- extend: {},
- },
- plugins: [],
-}
-
diff --git a/WebApp/ts/index.ts b/WebApp/ts/index.ts
deleted file mode 100644
index 3a67a17..0000000
--- a/WebApp/ts/index.ts
+++ /dev/null
@@ -1,193 +0,0 @@
-interface Blog {
- Title: string;
- Path: string;
- PublishTime: string;
-}
-
-interface Catalog {
- Name: string;
- Blogs: Blog[];
- Children: Catalog[];
-}
-
-interface WebInfo {
- AuthorName: string;
-}
-
-// @ts-ignore
-const BaseUrl = baseUrl;
-
-class Index {
- blogs: Blog[] = [];
- allBlogs: Blog[] = [];
- catalogs: Catalog[] = [];
- webInfo!: WebInfo;
- constructor() {
- document.addEventListener('DOMContentLoaded', () => this.init());
- }
-
- init() {
- this.getData();
- this.addEvent();
- }
-
- getData(): void {
- fetch(BaseUrl + 'data/blogs.json')
- .then(res => res.json()).then((data: Catalog) => {
- this.allBlogs = this.getAllBlogs(data).sort((a, b) => {
- return new Date(b.PublishTime).getTime() - new Date(a.PublishTime).getTime();
- });
- this.blogs = this.allBlogs.slice(0, 50);
- this.catalogs = data.Children;
- });
-
- fetch(BaseUrl + 'data/webinfo.json')
- .then(res => res.json()).then((data: WebInfo) => {
- this.webInfo = data;
- });
- }
-
- addEvent(): void {
- const self = this;
- document.getElementById('searchBtn')!.addEventListener('click', function () {
- var searchText = (document.getElementById('searchText') as HTMLInputElement).value;
- self.search(searchText);
- });
-
- document.getElementById('searchText')!.addEventListener('keydown', function (e: KeyboardEvent) {
- if (e.key === 'Enter') {
- var searchText = (document.getElementById('searchText') as HTMLInputElement).value;
- self.search(searchText);
- }
- });
-
- document.getElementById("catalog-list")!.addEventListener('click', function (e: MouseEvent) {
- if ((e.target as Element).classList.contains('filter-item')) {
- let catalogName = (e.target as HTMLElement).dataset.catalog ?? '';
- self.filterBlogs(catalogName, 'all');
- }
- });
-
- document.getElementById("date-list")!.addEventListener('click', function (e: MouseEvent) {
- if ((e.target as Element).classList.contains('filter-item')) {
- let date = (e.target as HTMLElement).dataset.date ?? '';
- self.filterBlogs('all', date);
- }
- });
-
- var dates = document.querySelectorAll('.publish-time');
-
- dates.forEach((date: Element) => {
- const dateTime = (date as HTMLElement).dataset.time;
- (date as HTMLElement).innerText = self.timeAgo(new Date(dateTime!));
- });
- }
-
- search(key: string): void {
- if (!key) {
- this.blogs = this.allBlogs.slice(0, 50);
- } else {
- this.blogs = this.allBlogs.filter(blog => blog.Title.toLowerCase().includes(key));
- }
- this.renderBlogs();
- }
-
- filterBlogs(catalogName: string, date: string): void {
- if (catalogName != 'all') {
- let catalog = this.catalogs.find(catalog => catalog.Name == catalogName);
- if (catalog) {
- this.blogs = catalog.Blogs;
- }
- } else if (date != 'all') {
- this.blogs = this.allBlogs.filter(blog => blog.PublishTime.substr(0, 7) == date);
- } else {
- this.blogs = this.allBlogs.slice(0, 50);
- }
- this.renderBlogs();
- }
-
- getAllBlogs(rootCatalog: Catalog): Blog[] {
- let blogs: Blog[] = [];
- blogs.push(...rootCatalog.Blogs);
- if (rootCatalog.Children && rootCatalog.Children.length > 0) {
- rootCatalog.Children.forEach(catalog => {
- blogs.push(...this.getAllBlogs(catalog));
- });
- }
- return blogs;
- }
-
- renderBlogs(): void {
- let blogList = document.getElementById('blogList');
- if (blogList) {
- const pathName = window.location.pathname;
- blogList.innerHTML = '';
- this.blogs.forEach(blog => {
- let blogDiv = document.createElement('div');
- blogDiv.className = 'w-100 rounded overflow-hidden shadow-lg dark:bg-neutral-800 my-2';
- let blogInnerDiv = document.createElement('div');
- blogInnerDiv.className = 'px-6 py-3';
- let blogTitleDiv = document.createElement('div');
- blogTitleDiv.className = 'font-bold text-xl mb-2';
- let blogLink = document.createElement('a');
- blogLink.href = pathName + 'blogs' + blog.Path;
- blogLink.target = '_blank';
- blogLink.className = 'block text-lg py-2 text-neutral-600 hover:text-neutral-800 dark:text-neutral-300 dark:hover:text-neutral-100';
- blogLink.innerText = "📑 " + blog.Title;
- blogTitleDiv.appendChild(blogLink);
- blogInnerDiv.appendChild(blogTitleDiv);
- let blogInfoP = document.createElement('p');
- blogInfoP.className = 'text-neutral-700 text-base dark:text-neutral-300';
- blogInfoP.innerHTML = `👨💻 ${this.webInfo.AuthorName} ⏱️ ${this.timeAgo(new Date(blog.PublishTime))}`;
- blogInnerDiv.appendChild(blogInfoP);
- blogDiv.appendChild(blogInnerDiv);
- blogList?.appendChild(blogDiv);
- });
- }
- }
-
- timeAgo(date: Date): string {
- const seconds = Math.floor((new Date().getTime() - date.getTime()) / 1000);
- const intervals: { [unit: string]: number } = {
- '年': 31536000,
- '月': 2592000,
- '天': 86400,
- '小时': 3600,
- '分钟': 60,
- '秒': 1
- };
-
- let counter: number;
- let values: [number, string][] = [];
- for (const [unit, secondsPerUnit] of Object.entries(intervals)) {
- counter = Math.floor(seconds / secondsPerUnit);
- values.push([counter, unit]);
- }
-
- for (let i = 0; i < values.length; i++) {
- const [counter, unit] = values[i];
- if (counter > 0) {
- if (unit === '年') {
- let month = Math.floor((seconds - counter * intervals[unit]) / intervals['月']);
- let str = month > 0 ? month + '月' : '';
- return `${counter}${unit}${str}前`;
- }
- if (unit === '月') {
- let day = Math.floor((seconds - counter * intervals[unit]) / intervals['天']);
- let str = day > 0 ? day + '天' : '';
- return `${counter}${unit}${str}前`;
- }
- if (unit === '天') {
- let hour = Math.floor((seconds - counter * intervals[unit]) / intervals['小时']);
- let str = hour > 0 ? hour + '小时' : '';
- return `${counter}${unit}${str}前`;
- }
- return `${counter}${unit}前`;
- }
- }
-
- return '刚刚';
- }
-}
-
-new Index();
diff --git a/WebApp/ts/markdown.ts b/WebApp/ts/markdown.ts
deleted file mode 100644
index b08a260..0000000
--- a/WebApp/ts/markdown.ts
+++ /dev/null
@@ -1,75 +0,0 @@
-// @ts-ignore
-const mermaid = window.mermaid;
-// @ts-ignore
-const nomnoml = window.nomnoml;
-
-
-class MarkdownHandler {
- private copyContent: string = '📋copy code';
-
- constructor() {
- document.addEventListener('DOMContentLoaded', () => this.init());
- }
-
- private init(): void {
- this.initMermaid();
- this.initCodeCopy();
- this.initNomnoml();
- }
-
- private initMermaid(): void {
-
- if (typeof mermaid !== 'undefined') {
- mermaid.initialize({ startOnLoad: true });
- }
- }
-
- private initCodeCopy(): void {
- const languageDivs = document.querySelectorAll('div[class^="language-"]');
- languageDivs.forEach(languageDiv => this.addCopyIcon(languageDiv));
- }
-
- private addCopyIcon(languageDiv: Element): void {
- const language = languageDiv.className.split(' ')[0].split('-')[1];
-
- const codeActionBar = document.createElement('div');
- codeActionBar.classList.add('code-action-bar', 'flex', 'justify-between');
-
- codeActionBar.innerHTML = `${language}${this.copyContent}`;
- languageDiv.parentNode!.insertBefore(codeActionBar, languageDiv);
-
- const copyIcon = codeActionBar.querySelector('.copy-icon');
- copyIcon!.addEventListener('click', () => this.copyCode(languageDiv, copyIcon));
- }
-
- private copyCode(languageDiv: Element, copyIcon: Element | null): void {
- const textToCopy = languageDiv.querySelector('pre')!.innerText;
- navigator.clipboard.writeText(textToCopy)
- .then(() => {
- copyIcon!.innerHTML = '✓ copied!';
- setTimeout(() => {
- copyIcon!.innerHTML = this.copyContent;
- }, 1000);
- })
- .catch(err => {
- console.error('Failed to copy: ', err);
- });
- }
-
- private initNomnoml(): void {
- if (typeof nomnoml !== 'undefined') {
- var nomnomlDivs = document.querySelectorAll('.nomnoml');
- if (nomnomlDivs.length > 0) {
- const nomnomlDiv = nomnomlDivs[0];
- const content = nomnomlDiv.textContent!;
- nomnomlDiv.innerHTML = '';
-
- const canvas = document.createElement('canvas');
- nomnoml.draw(canvas, content);
- nomnomlDiv.appendChild(canvas);
- }
- }
- }
-}
-
-new MarkdownHandler();
\ No newline at end of file
diff --git a/WebApp/tsconfig.json b/WebApp/tsconfig.json
deleted file mode 100644
index 6fb5993..0000000
--- a/WebApp/tsconfig.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "compilerOptions": {
- // Enable latest features
- "lib": [
- "ESNext",
- "DOM"
- ],
- "target": "ESNext",
- "module": "ESNext",
- "outDir": "./js",
- "rootDir": "./ts",
- "noImplicitAny": false,
- "strictNullChecks": true,
- "esModuleInterop": true,
- "removeComments": true
- }
-}
\ No newline at end of file
diff --git a/WebApp/web.config b/WebApp/web.config
deleted file mode 100644
index 8b436bf..0000000
--- a/WebApp/web.config
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/BuildSite/Command.cs b/src/BuildSite/Command.cs
index a48ced5..5e7895a 100644
--- a/src/BuildSite/Command.cs
+++ b/src/BuildSite/Command.cs
@@ -36,6 +36,7 @@ public static void Build(string contentPath, string outputPath)
{
LogInfo(Language.Get("notExistWebInfo"));
}
+
var builder = new HtmlBuilder(contentPath, outputPath, webInfo!);
builder.BuildWebSite();
}
diff --git a/src/BuildSite/HtmlBuilder.cs b/src/BuildSite/HtmlBuilder.cs
index 46a188a..e86829f 100644
--- a/src/BuildSite/HtmlBuilder.cs
+++ b/src/BuildSite/HtmlBuilder.cs
@@ -38,6 +38,7 @@ public HtmlBuilder(string input, string output, WebInfo webinfo)
public void BuildWebSite()
{
+ EnableBaseUrl();
ExtractWebAssets();
BuildData();
BuildBlogs();