【搭建你的日记本】使用 Properties 与 templates 实现一个日记模板

用periodic notes 呢?

大佬,为什么我的这个不会解析为property,就纯文字展示。
辛苦大佬指点~

已解决,使用源码模式发现,property区域的开始和结束符号配对出现问题。有我这个问题的伙伴们,也可以通过源码模式确认下。

新手,我也出现这个只有文字,没有属性的问题了,不太懂,请问怎么调整修改


进入模板(或者任意一个笔记)右上角有三个点,有源码模式的选项,勾选后,就能进入源码模式了。
在源码模式下,看看属性那边的—配对是否有问题。如果配对没问题,—应该是深灰色,而不是黑色。也不会带尖括号。
在Markdown中,—是分割线,有可能复制粘贴时,导致一些字符串的增减,让配对出现了问题。

删去位置和天气的部分可运行良好,保留的话控制台有这个报错。已关闭全局代理

已解决,是Easy-Tying插件导致的空格错误

我最近试了试博主的方法,发现高德开放平台出现了收不到邮件的情况,并且贴吧中有很多人反馈这个问题。于是我改写了代码,只用了腾讯地图的api,并加了一个节假日提醒:

---
<%*
let weatherUrl = 'https://apis.map.qq.com/ws/weather/v1'
let key = 'YouKey'

let ipUrl = `https://apis.map.qq.com/ws/location/v1/ip?key=${key}`
let ipResponse = await request({ url: ipUrl, method: "GET" })
let ipResult = eval("(" + ipResponse + ")").result
let location = ipResult.location.lat + ',' + ipResult.location.lng
console.log("📍 location:", location)

let weatherUrlWithLocation = `${weatherUrl}?key=${key}&location=${location}`
let weatherResponse = await request({ url: weatherUrlWithLocation, method: "GET" })
let weatherData = eval("(" + weatherResponse + ")")
console.log("🌦 weatherData:", weatherData)

let info = weatherData.result.realtime[0]

tp.user.位置 = `${info.province}${info.city}`
tp.user.天气 = info.infos.weather
tp.user.温度 = `${info.infos.temperature}℃`
tp.user.风向 = `${info.infos.wind_direction} ${info.infos.wind_power}`
tp.user.湿度 = `${info.infos.humidity}%`

const apiKey = "YouKey"
let apiDate = tp.date.now("YYYY-MM-DD") 
let ApiAdress = "http://apis.juhe.cn/fapig/calendar/day"
let apiUrl = ApiAdress + `?date=` + apiDate + `&detail=1&key=` + apiKey;
let wUrl = new URL(apiUrl);
const res = await request({
	url: wUrl.href,
	method: "GET",
});
let JsonData = JSON.parse(res);
console.log(JsonData)

tp.user.jieqi = `${JsonData.result["term"]}`
%>
📅日期📅: <% tp.file.creation_date("YYYY年MM月DD日 dddd ") %><% tp.user.jieqi %>
⌚️时间⌚️: <% tp.file.creation_date("HH:mm:ss") %>
🌍位置🌍: <% tp.user.位置 %>
☁️天气☁️: <% tp.user.天气 %>
🌡️温度🌡️: <% tp.user.温度 %>
---
<%*
let 一言 = ""
let 来源 = ""
let 作者 = ""

await fetch('https://v1.hitokoto.cn/?c=d&c=h&c=i&c=j')
.then(response => response.json())
.then(data => { 
	一言 = data.hitokoto
	来源 = data.from
	作者 = data.from_who === null ? '佚名' : data.from_who
})
-%>
>[!quote] 一言
 <% 一言 %>  —— 《<% 来源 %>》 · <% 作者 %>

---
# 今日任务

- [ ] 
- [ ] 
- [ ] 
- [ ] 
# 灵感

- 
- 
- 
- 
# 小结


---
<< [[<% tp.date.now("YYYY-MM-DD", -1) %>]] | [[<% tp.date.now("YYYY-MM-DD", 1) %>]] >>


注意:我添加了聚合数据的节假日api,以完成节假日的显示,如果没有这方面的需要,可以自行删除。