关于代码调试
wangyang0210 opened this issue · 0 comments
wangyang0210 commented
博主给了一种方法,我这里也提供一种可以参考,通过github的api获取最新的tag,然后通过jsdelivr来引入最新的tag进行测试;
- fork仓库
- 博客园侧边栏配置,配置内容请参考下面的配置
- 修改代码
- 编译制品
- 添加并提交tag
- 到博客园测试查看效果
<script>
async function request(url = '', method = 'GET', data = {}, headers = {}) {
let options = {
method: method,
mode: 'cors',
redirect: 'follow',
referrerPolicy: 'no-referrer',
}
if (Object.keys(headers).length) {
options.headers = headers
}
if (Object.keys(data).length) {
options.body = JSON.stringify(data)
}
const response = await fetch(url, options)
return response.json()
}
request('https://api.github.com/repos/wangyang0210/Cnblogs-Theme-SimpleMemory/tags').then(r => {
const url = `https://cdn.jsdelivr.net/gh/wangyang0210/Cnblogs-Theme-SimpleMemory@${r[0].name}/dist/simpleMemory.js?_t=${(new Date()).valueOf()}`;
$.ajax({
type: 'GET',
dataType: 'script',
cache: true,
url,
success: function (data) {
console.log('simpleMemory request success')
},
error: function (err) {
console.log('simpleMemory request', err)
},
})
// <script src="https://cdn.jsdelivr.net/gh/wangyang0210/Cnblogs-Theme-SimpleMemory@"+localStorage.getItem('version')+"/dist/simpleMemory.js" defer>
})
</script>