I am wanting to create a blog, this blog is for me to record my journey learning to become a software engineer/web developer. I have a separate offline blog uploader where I will create a title and the content and upload it to a database this has two inputs.
1.title
2.post_text
. However I want my blog posts to be able to render custom html for example the output from the database is this title: Test, post_text:<h1>This is a test!</h1>
However I have no clue how to render this HTML.I tried using createElement() and. then adding that to the DOM however that wasn't working First step is displaying it on the 'all posts' section in mini cards. Next would be creating the page that will render this detail.
I am using React.js for the blog. Can anyone link me to some help, or can anyone suggest any ideas I could to tackle this issue
React has dangerouslySetInnerHTML for exactly this. If you're receiving HTML and you want it to be rendered as HTML (not as a string):
<div dangerouslySetInnerHTML={{ __html: post_text }} />
You should make sure your HTML is coming from a trusted source - in your case, a CMS should be fine.
Related
I'm using Blogger and trying to make a Blogger speed and SEO friendly template from scratch but I have a problem with the blogposts pagination:-
I want to display all the posts in the same grid with load more posts button but without that big load slowing javascripts so the type of load more posts button that I want is just like mogu template.
No need for links Google it and you'll find it because it's the only blogger template with that name and they have it on the template's home page.
My question here is that any chance to get all posts to display as a grid with a functional load more posts pagination button like the one on mogu template and how to do it without getting big javascripts to slow my blog down ?
Sorry in advance for disturbing because I'm totally a newbie to blogger.
PS: for the Blog1 widget I'm using the default generated code once we type this:-
<b:section id='example'>
<b:widget type='Blog' id='Blog1'/>
</b:section>
Any help would be highly appreciated and thank you for reading
I have tried to use mogu template's Blog1 widget code entirely using the necessary <b:defaultmarkups> to work and it worked except for the load more posts pagination button and after a couple of tests it turns out that the pagination is connected to a hidden javascripts from the template's owners outside the given template's code.
( expected but I just checked it as I thought maybe the load more pagination javascript was there some where in the template). So I don't want to have that slow speed as it's really important for me to make it fast and seo friendly as much as possible and also according to my blog design to make my project works
everyone currently I am working on a project which a Financial web application. But as I'm moving forward code redundancy is increasing & particularly for HTML code.
I have multiple Html pages on my website such as Dashboard, EditProfile, AccountStatistics, etc. For Eg.
DashBorad - enter image description here
EditProfile - enter image description here
AccountStats - enter image description here
Now judging from the above pics you guys can see every time we navigate from one page to another only the main section content is changing but the body structure & design of the website remains the same.
Problem: If i want to create a new page I have to include code for header, sub-header, sideBar, footer which is repetitive. I just want the main-section code to change. For eg - Made one file like Body.html which contains code for header, sidebar, etc & every time I want to create a new page then only code for the main-section has to written which be can later merge with the body.
How can we achieve this?
(Tech used - Html, Css & JavaScript)
Note: I can also attach code if anyone wants more clear understanding!
Thank You!
Cheers to coding :)
You can use Frontend Frameworks like React/Vue.
Depending on if it's a static site, you can use stuff like Jekyl/Hugo.
If you want to go the SSR way, then you have Angular Universal/ ASP.NET Core/ PHP way.
Depending on your use case, you can't really go wrong either way. If you're new, pick either one and get started Learning.
Have fun!
This is an excellent use-case for a library like ReactJS (and other similar alternatives). Using React you can define 'components' for your header, sidebar and other common parts of your webpages that can be reused in different places. You can also update each of these components separately.
Ok so I'm making a custom blogger template. I know concepts like data tags and basic structure of blogger. But, since
I'm new at programming I am having some difficulties with this specific widget "blog post".
I know this is the most important widget but it's kinda difficult for me to edit this one because i don't know
what to change or what should i look for.
The problem here is whenever I apply this code, instead of showing thumbnail and title of the post it just shows whole post on my homepage.
The homepage looks fine before publishing anything but as soon as I publish a post it disappears leaving a disorientate page.
So please tell me if you guys know what type of specific code I need to change or do i have to write it from scratch in order to show only thumbnail and title of the post.
Here you can see the widget code: https://github.com/Blayke01/blogger/blob/master/blogger.html
I have searched ALOT for this question and didnt find an answer,
I designed a complex HTML template and I tried to make a Joomla template based on it
I found the whole process time consuming and I cant get exactly same result as I wanted, also even If I do this I dont have a user friendly Joomla panel and for changing every module and component the Admin should know a basic HTML understanding to edit my tags and doesnt mess up my code
so I realized what If I use modern Joomla template instead with a user friendly panel
and bring the content to the page and rewrite the whole DOM via Javascript like this
1)first make variables and store the content on the rendered template
2)$('body').innerHTML = "" (make the DOM empty)
3)$('body').innerHTML => rerwrite my structure using variables I stored
then every element is exactly the same and my css, js files do the rest
Is it usual to do this way?
whats the problem with this method?
Thanks
Hi i got a question about pagination. First of all, im new at html and javascript.
Ok, here is my doubt. Im building a website from cero. Im not using any web editor.
I filled the index.html with enough content (based on what i think is enough).
Now i want to add a new page with new content, and this page will be my new index.html, and the first index.html will be page-2.html (for example).
And I will be adding a new page like every 3 days, so what happens when I got more than 30 or 40 pages?
I know how to do a pagination, but i want to know if there`s a way to have a pagination without having to change name of pages every time?
Like a dynamic pagination or something like that. I dont know how to do it. I have been searching but I found nothing.
-Is there a way to do it with javascript?
-I donĀ“t have knowledge about PHP.
-Thanks for your answer in advance.
Consider the datatables.net library. It paginates for you: https://datatables.net/reference/api/
Only javascript solution :
You don't have to rename pages nor having multiple pages.
What you need to do is create a sinlge long pages with content separated liek this for exemple
<article>
Content 1
</article>
<article>
Content 2
</article>
...
And then simply do a pagination since you know how to do that.
And display element like, first of pagination show article 1 to 5
and display:none the other etc...
However this is clearly not a good idea mostly due to time of loading. The way you should do is to use php and sql to store your content in database and display it calling the server (with php).