I'm trying to use nextjs for just a part of my web-site.
The navbar already exists in other frameworks, not even react. i want to use nextjs in a <div id="nextjs_div">...</div>, ie. just a part of my website.
The problem is that nextjs renders a whole HTML page with head and body components. so what I want basically is to delete these components and render just one div that will be mounted in my page.
I tried to modify the page/_document but couldn't succeed.
Do you have an idea of how i can do this.
Next.js is a framework intended to create full pages and most likely not appropriate tool to use for creating a part of a page. You could use just React then.
If you can make an HTML from the navbar then you could insert it into Next.js project.
See Add HTML header to Document.js example
Related
I'm creating a new website and I will have different pages on it. However, instead of creating new HTML files for each page and an anchor for each, I want all my pages contained in one HTML file. Is it possible in any way?
You can try Vue js or React js or many js frameworks ... which contain components.
Using HTML
You can control HTML page section how tabs working in HTML, take a look in Bootstrap Tabs, or you can hide/show sections using CSS or using JS, you may store HTML for each page in array of js and load that HTML to Body based on URL you create
Using Server Side Language
Also if you need single page application with multiple pages you need a Server Side language, where Database contains your website configurations and you can load based on the URL each page's layout or text like heading forms etc...
In ASP.NET Webforms I have a Master Page where bootstrap css is imported. All of the child pages of the site use this Master Page.
One of the child pages displays HTML content originally created in a WYSIWYG editor. Since this child pages uses the master page and relies on it so the header and footer match everything else the styles override the WYSIWYG content styles.
Is there a way I can make it so a section of the page ignores bootstrap even though it is being imported from the master page but the rest of the page like the header and footer still use it?
Trying to avoid separating this page from using the Master Page.
The only possible method I can think of would be to create a custom css file for this page, and create specific css classes for each element that will override the css imported from the bootstrap via masterpage.
In my Rails webapp I would like to have a view that only gets its css from a specific css/scss file. I have tried several suggested solutions on here but none to my avail.
However, would I be able to place the example.css.scss file outside of the assets/stylesheets directory and restrict the view file example.html.erb to the example.css.scss styling only for example.html.erb?
From what I understand by reading rails asset pipeline all files in the myapp/app/assets directory inherits its css rules from the application.css file and as well the corresponding css file when the controller is generated creating a view file, css file, etc. etc.
I've created a webapp using Ruby on Rails. The app is almost done and is staged. I had an idea that a landing page would be a nice opener to the webapp.
My goal is to create a landing page for webapp. The landing page consists of a background image with a text centered link, which I would like to link to the home page of the webapp and not receive any styling from the application.css file.
Basically I want this view file to have nothing to do with the application.css file.
Thanks in advance.
While there may be reasons to use a totally different css file that's not part of the asset pipeline (e.g. landing page working while rails is restarting, keeping landing page lightweight, etc.), my guess is that you're more motivated by getting something to work.
I'm assuming you've got styles for most of your app that would conflict with the landing page, so if the styles from app apply also to the landing page, the landing page looks funny, and vice versa. So my guess is that you're looking for a way to have some styles apply to the app, and other styles apply to the landing page.
For this, I would first of all bypass your regular layout - see bypass application.html.erb in Rails app
Then, I would update your regular layout to somehow indicate that it is the app and not the landing page. There are any number of ways to do this, but I might do the following:
application.html.erb:
<body class='app'><!-- etc. -->
landing_page.html.erb:
<body class='landing_page'><!-- etc. -->
Then, in your scss files, update it thus:
application.css.scss:
body.app {
/* All your regular app styles */
}
body.landing_page {
/* All your landing page styles */
}
Of course you can split those into multiple files, etc..
TL;DR
Unless you're running into loading time issues or you have some other reason why you really really don't want app styles loading for the landing page, then just put it all together but scope the styles so that they don't apply when they shouldn't.
You are already working in the Rails domain, so it would probably be easier to continue to stay in that domain.
In my opinion, the best/easiest thing to do would be to create a welcome controller. Create an empty index action in the controller and a view for that action. The view you are creating seems rather simple, so you can just prefix the class/id names (which don't seem like many) with welcome_ and this will differentiate them from your normal class/id names. The link for the homepage text will point to the index action of that particular controller.
Then you can create the root route in your routes.rb file to point to welcome#index.
I'm building a simple personal static webpage. It'll be 4-5 pages (maybe more later) that all share a nav bar and header design at the top of the page.
I don't want to repeat the HTML and CSS for the navbar/header at the top of every page - ideally I'd like it all in one place.
If I were creating this using a web framework like Django, Sinatra, Rails, etc... I could use templates and partials to build the page using shared components like the navbar/header.
But I'm trying to keep things as simple as possible since it's a small set of static pages.
Is there a way to keep all the HTML in one file and reference it from the other files?
If not, is there a simple tool that will let me leverage the functionality that partials and templates provide, and just "compile" the final product into a series of HTML pages?
Thanks!
Use a one main Html file with all navigation bars, footer, menu and etc.
Keep a blank place, for example a blank div in the main page.
Keep other html pages in a separate place.
Load the contents dynamically to the blank div in the main page using javascripts.
I am using ui-router of angularjs in my SPA. When i add an style to my view pages, angularjs loads them when switching to than view. Thats actually pretty cool that it can be done in runtime.
The problem is i do not want it to do so. for example i want to use bootstrap css in my view. it is already inserted in the main page, so it is not needed to get loaded again form child view. but for my IDE to auto-complete class names, it is needed to be added to html page of subview.
Is there any way to ask Angularjs to ignore Head part and just load Body part of my html?