xcatliu / pagic

A static site generator powered by Deno + React
https://pagic.org
MIT License
1.64k stars 104 forks source link

[Develop Theme] How to theme debugging on development #61

Open drizzlesconsin opened 3 years ago

drizzlesconsin commented 3 years ago

Is your feature request related to a problem? Please describe.

error: Uncaught (in promise) TypeError: Import 'https://deno.land/x/pagic@v0.12.0/src/pagic_theme_custom/mod.ts' failed: 404 Not Found

Describe the solution you'd like 请问可以支持这样引用主题吗? https://github.com/xcatliu/pagic/blob/8df4be35ea/src/Pagic.ts#L30

theme: "../pagic_theme_custom",

Describe alternatives you've considered 还是目前只能基于 Pagic 源码进行开发调试。

Additional context https://github.com/xcatliu/pagic/blob/8df4be35ea8b4f1d820d9e1a12d4664d2ffb782f/src/utils/import.ts#L30-L37

xcatliu commented 3 years ago

error: Uncaught (in promise) TypeError: Import 'https://deno.land/x/pagic@v0.12.0/src/pagic_theme_custom/mod.ts' failed: 404 Not Found

这只是一个示例链接,当前还不存在这个 custom theme,所以是 404。

theme: "../pagic_theme_custom",

目前不支持这样的格式。

你可以先使用 default 主题,然后在本地创建 _layout.tsx 来调试和开发页面,等开发完成后创建一个主题目录,只保留 _layout.tsx 以及一些样式文件,然后发布到 github(或其他地方)上,就可以通过 url 来加载主题了。

xcatliu commented 3 years ago

可以看看这个 https://pagic.org/zh-CN/docs/themes.html

drizzlesconsin commented 3 years ago

可以看看这个 https://pagic.org/zh-CN/docs/themes.html

本地开发似乎比较慢,修改 CSS JS 不能实时更新,比较麻烦,需要重新启动服务。

xcatliu commented 3 years ago

嗯,这里确实有问题。后续我优化一下开发体验。

我的意思是你可以先写网站内容,然后在网站里写 _layout.tsx 和样式文件,最后调试好了再去掉内容做成主题。像这样:

/site
  hello.md
  _layout.tsx
  assets/index.css

此时运行 pagic runhello.md 会以 _layout.tsx 为模版,也支持保存后自动刷新。等 _layout.tsx 开发完成了,再删掉 hello.md,添加一个 mod.ts 就是一个主题了。

drizzlesconsin commented 3 years ago

明白你意思了 👍

trilom commented 3 years ago

I have a PR incoming for this soon that I am excited about.

Thank you for this project, I really like how simple and clean it is to deploy static sites as I resist Go as much as possible.

My changes include a "watcher" to watch changed files a little better, and some fixes/changes around sourcing themes and utilities to help local development of themes.

trilom commented 3 years ago

Scope creep is real...

trilom commented 3 years ago

Hello,

I wanted to share some of my work on this, it is not capable of being pulled but you can at least see the direction of a handful of things. Most of my time has not explicitly been spent on the watcher but more on a logger which was pretty fun.

Another thing to take a look at would be the usage of the PagicConfiguration object and how it is utilized (incompletely) to encapsulate most of the configuration setting/getting and allow the Pagic object to not be as bloated and remain focused by extending the PagicConfiguration class.

I am in a big cleanup phase and will be putting PR's to this work but wanted to get some eyes on it for collaboration or other direction you might have.

Thanks