Coder Social home page Coder Social logo

halo-sigs / theme-astro-starter Goto Github PK

View Code? Open in Web Editor NEW
13.0 1.0 5.0 366 KB

Halo 2.0 Theme base on Astro and Thymeleaf(Experimental)

Home Page: theme-astro-starter.vercel.app

JavaScript 3.99% Astro 26.32% Vue 6.35% HTML 63.10% CSS 0.24%
halo halo-theme halo-theme-starter astro

theme-astro-starter's Introduction

theme-astro-starter(Experimental)

Halo 2.0 基于 AstroThymeleaf 的主题快速开始模板。

目前还处于实验和探索的阶段。

原理

  1. Astro 作为 SSG 渲染框架,用于组件封装、页面框架组织、静态页面生成、静态资源的构建。
  2. Thymeleaf 作为后端页面渲染框架,并且负责提供数据进行页面数据的渲染。由于 Thymeleaf 的语法是基于 HTML 元素的 Attributes 扩展,所以理论上并不会破坏 HTML 的结构。那么就可以在 Astro 组件中使用 Halo 提供的数据和页面进行绑定。这样就实现了在开发环境并不依赖于 Halo 后端,可以在开发过程中保留 hmr。并且可以做到在构建之后可以直接给 Halo 使用。

特性

  1. 得益于 Astro 框架,可以使用现代的前端技术栈开发页面。包括但不限于 Vue React Svelte 等,意味着可以使用这些现代前端框架进行组件开发。
  2. 在开发环境可以实现 hmr。
  3. 在构建页面之后,会自动处理构建产物的资源地址,转换为 Thymeleaf 可识别的语法。
  4. 最终构建的产物可通过 HTML 直接访问,也可以部署在任何静态页面服务器,可作为页面预览原型。但因为没有经过 Halo 进行数据绑定,所以没有数据填充。

开发

项目结构:

├── astro.config.mjs                                        Astro 配置文件
├── package.json
├── pnpm-lock.yaml
├── src
│   ├── components
│   │   ├── Card.astro
│   │   └── PostCard.vue                                    Vue 3 组件
│   ├── layouts                                             Astro 布局组件
│   │   └── Layout.astro
│   └── pages
│       ├── index.astro                                     Astro 页面组件
│       └── post.astro
├── templates
│   ├── assets                                              bundle 之后的静态资源文件
│   │   ├── 4669d51c.dbc606a6.css
│   │   ├── PostCard.42ac9187.js
│   │   ├── chunks
│   │   │   └── runtime-core.esm-bundler.e59bb94c.js
│   │   └── client.e67fc49c.js
│   ├── favicon.ico
│   ├── index.html                                          构建之后的静态页面,作为 Thymeleaf 渲染模板
│   └── post.html
├── theme.yaml                                              主题描述文件
└── tsconfig.json
git clone https://github.com/ruibaby/theme-astro-starter

pnpm install

# 启动 Vite 开发环境
pnpm dev

# 构建最终产物,构建之后可以直接在 Halo 当中安装使用
pnpm build

theme-astro-starter's People

Contributors

ruibaby avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

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.