mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-01-17 18:22:33 +00:00
Update RegExp
This commit is contained in:
parent
edf3675f32
commit
4de8a1d4ec
@ -10,13 +10,13 @@ hexo.extend.filter.register('after_post_render', data => {
|
||||
const theme = hexo.theme.config;
|
||||
if (!theme.exturl && !theme.lazyload) return;
|
||||
if (theme.lazyload) {
|
||||
data.content = data.content.replace(/(<img[^>]*)src=/ig, '$1data-src=');
|
||||
data.content = data.content.replace(/(<img[^>]*)\ssrc=/ig, '$1 data-src=');
|
||||
}
|
||||
if (theme.exturl) {
|
||||
const siteHost = parse(config.url).hostname || config.url;
|
||||
// External URL icon
|
||||
const exturlIcon = theme.exturl_icon ? '<i class="fa fa-external-link-alt"></i>' : '';
|
||||
data.content = data.content.replace(/<a[^>]*href="([^"]+)"[^>]*>([^<]+)<\/a>/ig, (match, href, html) => {
|
||||
data.content = data.content.replace(/<a[^>]*\shref="([^"]+)"[^>]*>([^<]+)<\/a>/ig, (match, href, html) => {
|
||||
// Exit if the href attribute doesn't exists.
|
||||
if (!href) return match;
|
||||
|
||||
|
||||
@ -42,8 +42,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
templates: {
|
||||
text: data => {
|
||||
const stats = CONFIG.i18n.hits_time
|
||||
.replace(/\$\{hits}/, data.nbHits)
|
||||
.replace(/\$\{time}/, data.processingTimeMS);
|
||||
.replace('${hits}', data.nbHits)
|
||||
.replace('${time}', data.processingTimeMS);
|
||||
return `<span>${stats}</span>
|
||||
<img src="${CONFIG.images}/logo-algolia-nebula-blue-full.svg" alt="Algolia">`;
|
||||
}
|
||||
@ -70,7 +70,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
},
|
||||
empty: data => {
|
||||
return `<div class="algolia-hits-empty">
|
||||
${CONFIG.i18n.empty.replace(/\$\{query}/, data.query)}
|
||||
${CONFIG.i18n.empty.replace('${query}', data.query)}
|
||||
</div>`;
|
||||
}
|
||||
},
|
||||
|
||||
2
source/js/third-party/search/local-search.js
vendored
2
source/js/third-party/search/local-search.js
vendored
@ -39,7 +39,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
}
|
||||
return right.id - left.id;
|
||||
});
|
||||
const stats = CONFIG.i18n.hits.replace(/\$\{hits}/, resultItems.length);
|
||||
const stats = CONFIG.i18n.hits.replace('${hits}', resultItems.length);
|
||||
|
||||
container.classList.remove('no-result');
|
||||
container.innerHTML = `<div class="search-stats">${stats}</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user