Skip to content

Commit 4c05ea7

Browse files
authored
chore: use cdn for lastModified plugin (#1662)
1 parent ca9adc2 commit 4c05ea7

File tree

1 file changed

+4
-32
lines changed

1 file changed

+4
-32
lines changed

index.html

+4-32
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
window.$docsify = {
4444
name: 'leetcode',
4545
repo: 'doocs/leetcode',
46+
lastModifiedText: isEn() ? 'Last updated: ' : '最近更新时间:',
4647
logo: '/images/doocs-leetcode.png',
4748
search: {
4849
depth: 2,
@@ -128,42 +129,11 @@
128129
return html + footer
129130
})
130131
},
131-
(hook, vm) => {
132-
hook.beforeEach((html) => {
133-
function formatDateTime(dateTimeString) {
134-
const date = new Date(dateTimeString);
135-
const year = date.getFullYear();
136-
const month = String(date.getMonth() + 1).padStart(2, '0');
137-
const day = String(date.getDate()).padStart(2, '0');
138-
const hours = String(date.getHours()).padStart(2, '0');
139-
const minutes = String(date.getMinutes()).padStart(2, '0');
140-
const seconds = String(date.getSeconds()).padStart(2, '0');
141-
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
142-
}
143-
const { file } = vm.route
144-
const apiUrl = `https://api.github.com/repos/${$docsify.repo}/commits?path=${file}`;
145-
fetch(apiUrl, { method: 'GET' }).then(response => response.json())
146-
.then(data => {
147-
const date = data[0].commit.committer.date
148-
const commitUrl = `https://github.com/${$docsify.repo}/commits/main/${file}`
149-
const lastModified = formatDateTime(date)
150-
const prompt = isEn() ? 'Last updated: ' : '最近更新时间:'
151-
const lastModifiedContent = `
152-
<blockquote>
153-
<a href="${commitUrl}" target="_blank" style="color: #858585">${prompt + lastModified}</a>
154-
</blockquote>
155-
`
156-
document.getElementById('last-modified').innerHTML = lastModifiedContent
157-
})
158-
return (
159-
html + '<span id="last-modified"></span>'
160-
);
161-
});
162-
},
163132
]
164133
}
165134
</script>
166135
<script src="https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/npm/docsify@4.13.0/lib/docsify.min.js"></script>
136+
<!-- components -->
167137
<script src="https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/npm/prismjs/components/prism-c.min.js"></script>
168138
<script src="https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/npm/prismjs/components/prism-go.min.js"></script>
169139
<script src="https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/npm/prismjs/components/prism-sql.min.js"></script>
@@ -180,8 +150,10 @@
180150
<script src="https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/npm/prismjs/components/prism-ruby.min.js"></script>
181151
<script src="https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/npm/prismjs/components/prism-rust.min.js"></script>
182152
<script src="https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/npm/docsify-copy-code@2.1.1/dist/docsify-copy-code.min.js"></script>
153+
<!-- plugins -->
183154
<script src="https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/npm/docsify/lib/plugins/search.min.js"></script>
184155
<script src="https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/npm/docsify/lib/plugins/zoom-image.min.js"></script>
156+
<script src="https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/npm/docsify-lastmodified/index.min.js"></script>
185157
<script src="https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/npm/docsify-tabs@1/dist/docsify-tabs@1.js"></script>
186158
<script src="https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/npm/docsify-pagination/dist/docsify-pagination.min.js"></script>
187159
<script src="https://cdn-doocs.oss-cn-shenzhen.aliyuncs.com/npm/docsify-darklight-theme@latest/dist/index.min.js"></script>

0 commit comments

Comments
 (0)