How I can follow all files to Imports in blazor - file

I create a new Blazor Server app and clean some files from unused code.
But after that my _Imports.razor not work.
#page "/"
<NavBar />
#code{
}
NavBar is my custom component in shared folder.
And it's show error - 'Found markup element with unexpected name 'NavBar'. If this is intended to be a component, add a #using directive for its namespace.'
I cheked _Imports and it keep #using YagodnoeProject.Shared
How I can follow all files to _Imports again. And may I follow all files to another file, 'GlobalVariabels' for example?

Related

react native react-native-web-view working ok with embedded JS but not with separate JS

I have a test app with react-native-web-view rendering a local HTML file
for using JS, it works if I have the JS embedded in the HTML, but if I call it on a separate JS file it won't work...
in my App.tsx:
<WebView source={{uri: `${origin}/${file}`}} style={styles.webview} />
here is the embedded HTML:
<button type="button" onclick="alabama();">Play</button>
<button type="button" onclick="alert('Hello alabama')">music</button>
<script src="./chusa.js"></script>
chusa.js:
function alabama() {
alert('Hello alabama');
}
So, alert works, the function doesn't.
How can I call the script on a separate file?
React-Native Web WebView uses an iframe in replace of the webview component, so the issue is likely due the html file (e.g. the iframe) not having access to external files once mounted/created.
Possible Solution:
If you want the file to still be external, change it to a string and use back-quotes:
export const javascript = `alert("hello")`
Import js component. Something like:
import externalJS from "./filename"
The imported variable is a string and your html should also be a string, so you'll want to append the script string to the end of the html string. Something like this:
html = html.replace('</body>', '<script>${externalJS}</script></body>')
Use the new html string as the source via prop:
<WebView source={{ html: html }/>
Note: When you say "call" the script, if you are referring to calling a function after the web webview has been created without re-rendering, then that isn't possible at this time due when using the web webview instead of an actual webview component. This is actually an issue I am trying to resolve: How do I post a message to a iframe (not webview) in React-Native?
Hopefully this helps you with your issue.

Next.JS Static Generation not optimal for SEO when using `map` method

I am currently using Next.JS to create a static website with the main objective to have a very good SEO-optimized website.
Everything works fine and the website is correctly deployed with Vercel, but I have noticed that part of the content is not present directly in the HTML files.
For instance, I have a component that loops over an array of data, using the array map method, like this:
{imageTexts.map((image) => (
<ImageText
key={image.title + 'TitleImage'}
title={image.title}
description={image.description}
size={imagesSize}
image={image.image}
/>
))}
Once the website is deployed to Vercel, I search inside the HTML file for the information/strings contained in the array of data (imageTexts), but I can't find them. I guess Next.JS uses javascript to target some sort of div and then loops over its own JSON file to dynamically display content.
For me, this seems to kill a lot of the SEO advantage that static websites have over SPA. Is there any way I can have those strings directly inside my HTML files?
I am still not 100% sure this is caused by the map method, but I don't find any other explanations. Especially because other dynamically loaded components don't have the same problem. For example, this component string can be found on the HTML file, without a problem:
{title ? (
<Text
type="h2"
textAlign="center"
>
{title}
</Text>
) : null}
If you are mapping over ImageTexts on the server and that component renders HTML tags, then that HTML should be sent on the first-page load, and you could see it if you do CTRL+U or disable javascript.
Ok, I have just found that the reason. It has nothing to do with the map method. I was actually using the <Remark> component from library called react-remark. It seems it does not play well with Next.JS

How to set HUGO.io landing page?

I'm trying to set one of my sub-pages as a landing page in my hugo.io page setup. But all I can find so far is the hint to change the content of the home.html file in my layout folder.
This is not what I want to do, because by this I will duplicate the existing layout file for the sub-page whis is error prone. Is there any Site parameter that sets my sub-page "Portfolio" to be my landing page?
My setup:
|content
|posts
|about
|portfolio
|work1 (This is a page bundle)
|work2 (This is a page bundle)
index.md (Page Content File)
_index.md (List File)
My template setup:
|layouts
|_default
list.html
single.html
|portfolio
list.html
single.html
index.html
home.html
So layouts/portfolio/list.html ranges through all my portfolio work. This works fine. The file is used when I navigate to localhost:1313/portfolios.
But for having the same content on localhost:1313/ I understand to duplicate the layoutfile to layouts/home.hmtl -> Is this correct? This seems utterly laborious to me. Is there a more convenient way to tell hugo "use the file content/portfolios/_index.md as my landing page"?
Hope you can help me, Thanks in advance!
One solution is to move the content of layouts/portfolio/list.html to a partial, then include this partial in both layouts/portfolio/list.html and layouts/index.html. This way you will not have to duplicate the code you use to list all of your work.
I would also advice you to read the documentation on order lookup for templates, specifically the section related to the home page, as this explains the order of which template files are included.

My local Images Are not working Once i added parameters to the url of the component

Before i added the id of the object to the url the images loaded fine but once i added the ID The local images are not loading but url images work. Everything is returning fine in the console and it is the correct pathname.
I have tried using require but it just gives me a huge error with all of my images and some css.
I expect the corresponding image to show
This how the image file looks in my data
img: "img/product-8.94-1.png",
< img src={require(`../${img}`)} className="img-fluid"
alt="product"/>
This is the route and Link ( i added id)
<Route path="/details/:id" component={Details} />
<Link to={`/details/${id}`}>
Probably you are using relative paths to images in your app, if you changed route path from http://demo.com/details to http://demo.com/details/id the image cannot find the correct path, you got one extra folder details/id.
You don't show as how you get the path to the image, but if your image is in your assets folder of reactjs app, then import it like a component.
import img from "assets/image.jpg";
and then in component add it img src tag like this:
<img src={img} className="img-fluid" alt="product"/>
If you get images from db, then make sure you use full path to the image.
https://codesandbox.io/s/priceless-ardinghelli-sp0yg

Drupal 7 custom logo in page.tpl.php not displaying on all pages

I have a Drupal 7 site with a custom sub theme based on Zen. I have a custom logo that I placed in the page.tpl.php header div. The problem I'm having is that the logo only shows up on the first "main" pages, but not "subpages". Excuse my terminology here trying to explain this. What I mean by subpages is any page that is further down the chain or occurring after the first forward slash. Below is an example of what I mean by "main" pages and "subpages". All these "main" pages are directly after the first slash after the website name. The logo doesn't show up on any pages that occur after these main pages (subpages). All my pages are made using the Pages module, however, the subpages have a path using %term, for example /support/%term or products/%term.
What am I missing and what do I need to do to make my logo in page.tpl.php show up on all pages of my site? Am I supposed to create a new page.tpl.php file for the pages using /%term?
Main pages - logo shows up:
mysite.com/about
mysite.com/products
mysite.com/support
mysite.com/contact
Sub pages - logo doesn't show up:
mysite.com/products/product1
mysite.com/support/product1-support
If I understand you correctly, the quick fix for that is to make sure your logo's path starts with '/', like so:
<img src="/sites/all/themes/customZen/images/logo.png" />
But then if path of the theme changes everything will break, so don't do this.
If you place the logo using CSS as a background, use relative URL (it is relative to the path of .css file)
Or you can do something like this in your page.tpl.php:
<img src="<?php url($directory . '/images/logo.png'); ?>" />
$directory is the directory the template is located in, e.g. sites/all/themes/customZen.
Full list of page.tpl.php variables can be found here: https://api.drupal.org/api/drupal/modules%21system%21page.tpl.php/7.x
Did you solve this?..Well, if you didn't, try with this in your page.tpl.php paste this:
<img alt="" src="<?php echo drupal_get_path('theme', 'customZen');?>/images/logo.png">
Good luck!

Resources