current position:Home>Eight blog views / hexubs
Eight blog views / hexubs
2022-04-29 04:21:12【Xia ordinary】
【 Roof placement 】【 special column 】 use Github Pages+Hexo Build a blog
List of articles
- 【 Roof placement 】【 special column 】[ use Github Pages+Hexo Build a blog ](https://blog.csdn.net/qq_34243930/category_9662425.html)
- 1. register LeanCloud
- 2. establish & Configure the application
- 3. Modify theme profile
- 4. Configure the domain name , Set up network security
- 5. Restart deployment Hexo
- 6. Background management
- 7. Deploy the cloud engine to ensure that the number of visitors is not tampered with at will
- 8. Some of the pit
- Solve the problem that some articles do not display the number of readings ,LeanCloud Automatic deployment failed ?
- Solve the number of readings : Counter not initialized! More info at console err msg.
- solve hexo+next The number of times you read the home page has always been 0, The reading times in the article can be displayed normally ?

1. register LeanCloud
Go to LeanCloud Register and log in
2. establish & Configure the application
I'm gonna go ahead and create an app
Enter the app name ( Name at will ), Choose development , Click Create
After the creation is successful, click the settings in the upper right corner of the application
Click on Storage
, establish Class
,Class The name is set to Counter
( It has to be for Counter), Choose unlimited , Click Create
Click settings after creation , Click application Key, obtain App ID and App Key, Copy standby
3. Modify theme profile
The theme profile /themes/next/_config.yml
Medium leancloud_visitors:
Of enable
Set to true
, And will App ID and App Key fill
4. Configure the domain name , Set up network security
Click Security Center , Fill in the domain name corresponding to your blog ( Pay attention to the protocol 、 The domain name and port number should be strictly consistent )
because App ID and App Key Is completely exposed , So prevent others from using , We can set... In the application settings Web Secure domain name , Only the added domain name can use this application , Prevent someone Hack Our database . Click Settings , Security Center ,Web Domain name security , add to Blog domain name , Click Save to OK 了
5. Restart deployment Hexo
hexo clean
hexo g
hexo d
6. Background management
When the above parts are configured , When our blog page first opened , It will automatically send information to the server , In the application just created test Of Counter Create a piece of data in the table .
7. Deploy the cloud engine to ensure that the number of visitors is not tampered with at will
Click the cloud engine on the left in turn -> Deploy -> Online editing
Click Create function
Select... In the pop-up window Hook type , In the choice Hook Place selection beforeUpdate, In the choice Class Place selection Counter class . After pasting the code below , Point save .
var query = new AV.Query("Counter");
if (request.object.updatedKeys.indexOf('time') !== -1) {
return query.get(request.object.id).then(function (obj) {
if (obj.get("time") + 1 !== request.object.get("time")) {
throw new AV.Cloud.Error('Invalid update!');
}
})
}
Then click deploy... To the right of the Create button -> Production environment -> Deploy
To be displayed, the deployment is completed :1 If an instance is deployed successfully
8. Some of the pit
Many articles end here , But there are still some pits …
Solve the problem that some articles do not display the number of readings ,LeanCloud Automatic deployment failed ?
terms of settlement : Manually create LeanCloud Of Counter data row
Imitate existing data formats to create :
If your manual creation fails , I'm going to check url Is the format correct .
Solve the number of readings : Counter not initialized! More info at console err msg.
Method 1 、 Installing a plug-in hexo-leancloud-counter-security
Command line execution npm install hexo-leancloud-counter-security
Method 2 、 The theme profile _config.yml The corresponding item in security Set as false
solve hexo+next The number of times you read the home page has always been 0, The reading times in the article can be displayed normally ?
A lot on the Internet hexo Add reading statistics are old versions next Theme approach , The new version has been collected leancloud, Just open the topic below lean_cloud Function and in
/next/layout/_macro/post.swig
The following code is enough
{# LeanCould PageView #}
{% if theme.leancloud_visitors.enable %}
<span id="{
{ url_for(post.path) }}" class="leancloud_visitors" data-flag-title="{
{ post.title }}">
<span class="post-meta-divider">|</span>
{% if theme.post_meta.item_text %}
</span>
{% endif %}
copyright notice
author[Xia ordinary],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/118/202204280553438424.html
The sidebar is recommended
- Basic usage of JavaScript
- About the problems encountered in the value transfer of react parent-child components! (Language JavaScript)
- How to realize the function of jQuery small ticket printing
- [JavaScript] handwriting a lazy loading component
- HTTP protocol
- JavaScript performance optimization
- I've taught myself Python for half a month. I feel it's useless. What should I do?
- Is it a blessing or a curse that the biggest customer of Ningde era changes ownership of Tesla?
- Element UI realizes the function of table radio selection
- Elementui realizes the function of table radio selection
guess what you like
Apache shardingsphere code formatting practice -- spotless
Vue console error information collection and reporting
Initialize the react project environment under mac
React dynamically adds elements to the list
React realizes form data collection
Vernacular react life cycle
JavaScript generates a tree
vue2. How to register and login with 0 + koa2 + mongodb
vue. JS how to realize single page application
How to realize login registration and token verification in Vue
Random recommended
- How to set the background color for individual pages in Vue cli
- How does Vue router cooperate with elementui to realize navigation
- Vue2 how to load more data on the scroll bar
- How to use margin and padding in CSS
- How does vue2x implement the vueslidershow function of the responsive adaptive rotation component plug-in
- How does vue2 recursive component implement tree menu
- How to use the three selectors of CSS
- Same blog, different styles -- hexo alternative construction
- Optimize nginx HTTPS latency - see how I can speed up nginx by 30%?
- The development model in the era of consumer Internet only transfers industrial elements from offline to online
- Advanced features of Vue
- CSS shadow advanced, to achieve a more three-dimensional shadow effect!
- Introduction to the number type method in JavaScript
- Differences between nginx forward and reverse proxy
- Front end schema form configuration generation scheme
- Units that can be used by the rotate method of transform in CSS
- Why CSS3 sticky doesn't work?
- [bug resolution] webpack error: module not found Did you mean xxx
- [bug resolution] can't perform a react state update on an unmounted component This is > a no-op, but it...
- Remember to speed up the construction of a webpack
- Browser review hover element
- Vue insert iframe
- Vue realizes downloading pictures
- Some common problem-solving methods in Vue (sort out some truly effective methods that can be used in the project) (wait for continuous update and accumulation)
- About database data response to HTML page, Chinese appears? Solution to garbled code (multiple question marks)
- Ask a question about CSS selector
- When Vue jumps the route, the timer cannot be cleared in time
- Document is not defined
- Vue quill editor stepping on pit record -- the echo style of rich text content is wrong
- The multi selection box of table in element is combined with paging to echo the bug step hole
- Vue project optimizes the loading speed of the first screen
- Use / deep / to report an error CSS (CSS selected expected)
- Nginx configuration
- Vue cli reverse proxy
- Vuex persistedstate plug-in - vuex persistent storage
- Understanding and summary of CSS
- vue2. Implementation of X data response
- JavaScript content understanding
- Props in react
- JavaScript stack“