ryan4yin / thiscute.world

Ryan4Yin's Space
https://thiscute.world
17 stars 3 forks source link

Suggest: load static images with jsdelivr #1

Closed vensing closed 3 years ago

vensing commented 3 years ago

It may be possible to use the jsdelivr CDN to speed up the loading of static images : ) Set up a repository and then load the static resources using the JsDelivr CDN service.

ryan4yin commented 3 years ago

@vensing Appreciate further details :smile: so how to upload those static images to jsdelivr CDN via github actions?

vensing commented 3 years ago

Just create a github repo to save static resources,and then push your images or other resources to the repo. So you can load images with format like that https://cdn.jsdelivr.net/gh/username/reponame@version/folder/sample.png

ryan4yin commented 3 years ago

@vensing got it, thanks~

vensing commented 3 years ago

More detailed usage:https://github.com/jsdelivr/jsdelivr#github

ryan4yin commented 3 years ago

@vensing jsdelivr cdn for js/css can be enabled by default through the theme's configuration:

  # LoveIt 更改 | 0.2.7 第三方库文件的 CDN 设置
  [params.cdn]
    # CDN 数据文件名称, 默认不启用
    # ("jsdelivr.yml")
    # 位于 "themes/LoveIt/assets/data/cdn/" 目录
    # 可以在你的项目下相同路径存放你自己的数据文件:
    # "assets/data/cdn/"
    data = "jsdelivr.yml"

and I'll try to speed up the static images using the method you provided.

ryan4yin commented 3 years ago

晚安,明天再搞了hhh

vensing commented 3 years ago

Good night!

ryan4yin commented 3 years ago

Just create a github repo to save static resources,and then push your images or other resources to the repo. So you can load images with format like that https://cdn.jsdelivr.net/gh/username/reponame@version/folder/sample.png

it seems there is no need to create a repo to save static resources, I just replace all image path from ![](/images/xxx.png "title") to ![](https://cdn.jsdelivr.net/gh/ryan4yin/ryan4yin.space@gh-pages/images/xxx.png "title"), and everything works fine.

vensing commented 3 years ago

yeah,it works!

ryan4yin commented 3 years ago

now the only problem is, how to add friend links just like: https://chee5e.space/friends/ or https://matnoble.me/search/

I found an implementatin: https://github.com/MatNoble/matnoble.me/blob/master/layouts/shortcodes/friend.html, But I can't make it work.

ryan4yin commented 3 years ago

@vensing I tried to copy your implementation https://github.com/vensing/vensing.github.io/blob/source-action/source/friends/index.md, but the result is terrible...

vensing commented 3 years ago

Since I used hexo to build site, so hugo page implementation will be different. I will take a look at hugo.

ryan4yin commented 3 years ago

@vensing thanks~ I temporarily add friend links in pure markdown: https://ryan4yin.space/friends/

vensing commented 3 years ago

I have completed the code transplant. It works on PC and mobile. So I will send an email with md file to you, maybe css style should move to scss file of your site theme.

ryan4yin commented 3 years ago

@vensing wow~ this is really great! :smile:

vensing commented 3 years ago

Please check your email and test to see if the code works properly.

ryan4yin commented 3 years ago

@vensing it works very well~