Skip to content

部署到github page #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows /static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
# Upload entire repository
path: './dist'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
20 changes: 10 additions & 10 deletions Cargo.lock

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

26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
Mini Note

采用 Rust 编程语言,选择 Yew 框架
采用 Rust 编程语言,选择 Yew 框架

## 目录结构

目录结构:
my_blog_project/
├── src/
│ ├── components/
│ │ ├── header.rs # 导航栏组件
│ │ ├── sidebar.rs # 目录树组件
│ │ ├── content.rs # 内容展示区域
│ ├── routes/
│ │ ├── home.rs # 首页路由
│ │ ├── post.rs # 单个笔记页面路由
│ ├── context/
│ │ └── app_context.rs # 应用的全局上下文(例如主题管理、用户状态)
│ ├── main.rs # 应用主入口
│ ├── markdown.rs # 处理 Markdown 文件的加载与渲染
│ ├── app.css # 样式文件,包含 Tailwind CSS
│ └── utils.rs # 工具函数,可能包括文件加载和异步处理等
├── static/ # 静态资源目录,存放图片、文件等
│ ├── assets/ # 其他静态资源,如图标、图片等
│ └── posts/ # 存放 Markdown 文件的目录
├── Cargo.toml # Rust 项目配置文件
└── README.md # 项目说明文件
145 changes: 145 additions & 0 deletions dist/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
<!doctype html>
<html lang="en">
<head><link rel="modulepreload" href="/mini-note-dd0ee225576671bf.js" crossorigin=anonymous integrity="sha384-KsnTD8RMZuTYNhdmh0d5MAS8OGc55h5HHSbzqCstI/LD0W37NJ99GIMog3YZZAb6"><link rel="preload" href="/mini-note-dd0ee225576671bf_bg.wasm" crossorigin=anonymous integrity="sha384-gqTkPWMAsYcUvPapd2DLq91BmhOb5vnHmIi32ruM998yghWImzbmYdt/qIlzXBS3" as="fetch" type="application/wasm"></head>
<body>
<script type="module" nonce="VEXomg5aQ5Rwu9MRIMLWJw==">
import init, * as bindings from '/mini-note-dd0ee225576671bf.js';
const wasm = await init({ module_or_path: '/mini-note-dd0ee225576671bf_bg.wasm' });


window.wasmBindings = bindings;


dispatchEvent(new CustomEvent("TrunkApplicationStarted", {detail: {wasm}}));

</script><script>"use strict";

(function () {

const address = '{{__TRUNK_ADDRESS__}}';
const base = '{{__TRUNK_WS_BASE__}}';
let protocol = '';
protocol =
protocol
? protocol
: window.location.protocol === 'https:'
? 'wss'
: 'ws';
const url = protocol + '://' + address + base + '.well-known/trunk/ws';

class Overlay {
constructor() {
// create an overlay
this._overlay = document.createElement("div");
const style = this._overlay.style;
style.height = "100vh";
style.width = "100vw";
style.position = "fixed";
style.top = "0";
style.left = "0";
style.backgroundColor = "rgba(222, 222, 222, 0.5)";
style.fontFamily = "sans-serif";
// not sure that's the right approach
style.zIndex = "1000000";
style.backdropFilter = "blur(1rem)";

const container = document.createElement("div");
// center it
container.style.position = "absolute";
container.style.top = "30%";
container.style.left = "15%";
container.style.maxWidth = "85%";

this._title = document.createElement("div");
this._title.innerText = "Build failure";
this._title.style.paddingBottom = "2rem";
this._title.style.fontSize = "2.5rem";

this._message = document.createElement("div");
this._message.style.whiteSpace = "pre-wrap";

const icon= document.createElement("div");
icon.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" fill="#dc3545" viewBox="0 0 16 16"><path d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995A.905.905 0 0 1 8 5zm.002 6a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"/></svg>';
this._title.prepend(icon);

container.append(this._title, this._message);
this._overlay.append(container);

this._inject();
window.setInterval(() => {
this._inject();
}, 250);
}

set reason(reason) {
this._message.textContent = reason;
}

_inject() {
if (!this._overlay.isConnected) {
// prepend it
document.body?.prepend(this._overlay);
}
}

}

class Client {
constructor(url) {
this.url = url;
this.poll_interval = 5000;
this._overlay = null;
}

start() {
const ws = new WebSocket(this.url);
ws.onmessage = (ev) => {
const msg = JSON.parse(ev.data);
switch (msg.type) {
case "reload":
this.reload();
break;
case "buildFailure":
this.buildFailure(msg.data)
break;
}
};
ws.onclose = this.onclose;
}

onclose() {
window.setTimeout(
() => {
// when we successfully reconnect, we'll force a
// reload (since we presumably lost connection to
// trunk due to it being killed, so it will have
// rebuilt on restart)
const ws = new WebSocket(this.url);
ws.onopen = () => window.location.reload();
ws.onclose = this.onclose;
},
this.poll_interval);
}

reload() {
window.location.reload();
}

buildFailure({reason}) {
// also log the console
console.error("Build failed:", reason);

console.debug("Overlay", this._overlay);

if (!this._overlay) {
this._overlay = new Overlay();
}
this._overlay.reason = reason;
}
}

new Client(url).start();

})()
</script></body>
</html>
Loading