I have multiple pages on my web-site and only main page should have a different layout? How can I achieve this?
src/
- page1/ <- LayoutB
- page2/ <- LayoutB
- page3/ <- LayoutB
- index.svelte <- LayoutA
If I use __layout.svelte in the src/ folder it will apply for every page.
Update November 2022
This approach was tested in
npm -v #sveltejs/kit
8.19.2
To make a unique layout for a specific page (or group of pages) you need to use group.
src/
routes/
(unauthenticated)/
welcome/
register/
login/
+page.svelte
+layout.svelte (this layout applies to welcome/, register/ and login/
(authenicated)/
home/
settings/
+page.svelte
+layout.svelte (this layout applies to home/, settings/ and dashboard/
+page.svelte
+layout.svelte (this layout applies to all pages in unauthenticated/ and authenticated/)
I was able to find a solution by using named layouts from SvelteKit
The solution to my problem will look like this
src/
- page1/ <- LayoutB
- page2/ <- LayoutB
- page3/ <- LayoutB
- __layout.svelte (LayoutB)
- __layout-main.svelte (LayoutA)
- index#main.svelte <- LayoutA
I created a layout file with -main suffix and used this name as a reference to the layout in my index#main.svelte file
Related
I've got a project that looks something like this:
.
├── pyproject.toml
├── server.py
├── Shakefile.hs
└── ui
├── index.ts
└── Shakefile.hs
ui/Shakefile.hs contains something to the effect of:
import Development.Shake
main = shakeArgs shakeOptions $ do
want ["dist/index.js"]
"dist/index.js" %> \out -> do
need ["index.ts"]
cmd "tsc --outFile" [out]
and the root Shakefile.hs looks like:
import Development.Shake
main = shakeArgs shakeOptions $ do
want ["dist/server.tar"]
"dist/server.tar" %> \out -> do
need ["ui/dist/index.js", "server.py"]
cmd "tar cf" [out, "ui/dist/index.js", "server.py"]
Question: how should I model dist/server.tar's dependency on ui/dist/index.js?
My first guess was simply to add a rule specifying how to build ui/dist/index.html relative to the project root, with the action being to simply call shake (so that I don't have to keep the recipes in sync):
-- added to ./Shakefile.hs
"ui/dist/index.js" %> \_ -> do
cmd "stack exec shake -- -C ui dist/index.js"
BUT, considering the Shake paper cites Recursive Make Considered Harmful, I'm near certain this isn't the way to go.
Is there a way to import rules from another Shakefile? Can vanilla Haskell's import system be used to implement something like this? In either case, how could we (automatically?) translate rules and actions using paths relative to the child directory to be correct relative to the parent?
In general, I'm wondering about Shake's applicability to monorepos, and about the composability of different Shake-based build systems (i.e. Shakefiles from different internal projects).
Thanks for your consideration!
I have created a project using Nextjs framework.
When I run the project using npm run dev command, My project runs properly, and it's okay.
But when I run the command npm run build to build a project, After that, I can't find a build folder.
Bellow is the full report which is a builder shown to me:
λ npm run build
dastshafa-final#0.1.0 build
next build
info - Checking validity of types
./pages/cartProcess/index.js 13:6 Warning: React Hook useEffect has a
missing dependency: 'displayNavbar'. Either include it or remove the
dependenc y array. If 'displayNavbar' changes too often, find the
parent component that defines it and wrap that definition in use
Callback. react-hooks/exhaustive-deps 31:11 Warning: Do not use
. Use Image from 'next/image' instead. See:
https://nextjs.org/docs/messages/no-img-elem ent
#next/next/no-img-element
./pages/index.js 14:6 Warning: React Hook useEffect has a missing
dependency: 'setDisplayNavbar'. Either include it or remove the depend
ency array. If 'setDisplayNavbar' changes too often, find the parent
component that defines it and wrap that definition in useCallback.
react-hooks/exhaustive-deps
./components/navbar.js 58:21 Warning: Do not use . Use Image
from 'next/image' instead. See:
https://nextjs.org/docs/messages/no-img-elem ent
#next/next/no-img-element 101:17 Warning: passHref is missing. See:
https://nextjs.org/docs/messages/link-passhref
#next/next/link-passhref 117:9 Warning: passHref is missing. See:
https://nextjs.org/docs/messages/link-passhref
#next/next/link-passhref 118:11 Warning: Do not use . Use Image
from 'next/image' instead. See:
https://nextjs.org/docs/messages/no-img-ele ment
#next/next/no-img-element 118:11 Warning: img elements must have an
alt prop, either with meaningful text, or an empty string for
decorative imag es. jsx-a11y/alt-text
./components/productDetail.js 72:6 Warning: React Hook useMemo has a
missing dependency: 'productDetail'. Either include it or remove the
dependency array. react-hooks/exhaustive-deps 106:15 Warning: Do not
use . Use Image from 'next/image' instead. See:
https://nextjs.org/docs/messages/no-img-ele ment
#next/next/no-img-element 106:15 Warning: img elements must have an
alt prop, either with meaningful text, or an empty string for
decorative imag es. jsx-a11y/alt-text
./components/productItem.js 18:7 Warning: Do not use . Use Image
from 'next/image' instead. See:
https://nextjs.org/docs/messages/no-img-eleme nt
#next/next/no-img-element
./components/products.js 21:6 Warning: React Hook useEffect has a
missing dependency: 'dispatch'. Either include it or remove the
dependency arr ay. react-hooks/exhaustive-deps
./components/sort.js 37:6 Warning: React Hook useEffect has a missing
dependency: 'dispatch'. Either include it or remove the dependency arr
ay. react-hooks/exhaustive-deps 41:6 Warning: React Hook useEffect
has a missing dependency: 'filterProducts'. Either include it or
remove the dependen cy array. If 'filterProducts' changes too often,
find the parent component that defines it and wrap that definition in
u seCallback. react-hooks/exhaustive-deps
info - Need to disable some ESLint rules? Learn more here:
https://nextjs.org/docs/basic-features/eslint#disabling-rule s info -
Creating an optimized production build info - Compiled successfully
info - Collecting page data info - Generating static pages (4/4)
info - Finalizing page optimization
Page Size First Load JS ┌ ○
/ 6.37 kB 144 kB ├ └
css/b7d3c6e158495aa9.css 962 B ├ /_app
0 B 129 kB ├ ○ /404 194
B 129 kB ├ ○ /cartProcess 1.45 kB
130 kB ├ └ css/da339555cb6d6d6b.css 233 B └ λ
/product/[...params] 10.4 kB 148 kB
└ css/f78802d3b8b60c2b.css 2.98 kB
First Load JS shared by all 129 kB ├ chunks/framework-5f4595e5518b5600.js 42 kB ├
chunks/main-a054bbf31fb90f6a.js 27.6 kB ├
chunks/pages/_app-26dcf6f0f3b3e602.js 57.2 kB ├
chunks/webpack-62757ff16512d194.js 1.81 kB └
css/70cd855905d78aa0.css 24.4 kB
λ (Server) server-side renders at runtime (uses getInitialProps or
getServerSideProps) ○ (Static) automatically rendered as static HTML
(uses no initial props)
What is the problem? How can I fix it?
Look for a directory named .next which is the default the build command outputs to.
You can set a custom directory (for example build) by adding it to the distDir key in next.config.js:
const nextConfig = {
distDir: "build",
};
module.exports = nextConfig;
If you're exporting your app to static HTML, the export command outputs to a directory named out.
I attempted to replicate the directory structure in this tutorial by jerieljan. Unfortunately I seem to be getting the default PlantUML stylings. I have included the expected results vs. the actual results in screenshots below. I am using the Visual Studio Code extension by jebbs with preview. While the style sheets are too long to include here they can be found in the aforementioned linked tutorial. The diagram file is as follows:
# Sequence Diagram Example
#startuml
'General Defaults
!define BASEPATH ..
!include BASEPATH/globals/stylesheet.iuml
'Actor Definitions
autonumber 1 "0:"
title Sequence Diagram
A -> B: Perform Action
B --> A: (Response)
#enduml
The directory structure is the same as in the tutorial and is as follows:
$ tree
.
├── globals
│ ├── style-presets.iuml
│ └── stylesheet.iuml
└── diagrams
├── example-sequence.puml
├── etc...
Expected Diagram
Actual Diagram
I'm trying to write a shortcode for my hugo site that fetches the title parameter of page.
I have a directory structure like this:
content
├── workshops
│ ├── foo
│ │ └── _index.md
│ ├── bar.md
This works perfectly:
{{ with .Site.GetPage "home" "workshops/foo"}}
{{ .Params.Title }}
{{ end }}
And this one consistently comes up blank (even though there is a title in the markdown).
{{ with .Site.GetPage "home" "workshops/bar"}}
{{ .Params.Title }}
{{ end }}
My question is: How so I get the title of a standalone page?
I've tried a bunch of different combinations of things and I'm just not coming right. I've tried reading the docs and they are horribly convoluted on this point.
I have a solution! I wrote a little Python3.7 script to make directories and move and rename markdown files and just ran it over my entire contents directory. This solved my problem but is a bit of a hack...
import logging
import os
from pathlib import Path
def fixup(path):
location = Path(path)
assert location.is_dir(), location
for child in location.iterdir():
if child.is_dir():
fixup(child)
else:
fix_file(child)
def fix_file(file_path):
name = file_path.name
if not name.endswith(".md"):
# we only care about markdown files.
return
check_metadata(file_path)
if name.startswith("_index."):
# looks good
return
# make a directory with the same name as the file (without the extension)
suffix = ''.join(file_path.suffixes)
prefix = name[: -len(suffix)]
new_dir = file_path.parent / prefix
new_dir.mkdir()
new_path = new_dir / f"_index{suffix}"
file_path.rename(new_path)
def check_metadata(file_path):
""" given the path to a markdown file, make sure that the frontmatter includes
the required metadata
"""
# TODO
# required = ['title']
# allowed = ['pre', 'weight', 'ready']
if __name__ == '__main__':
fixup('content')
Two differences:
Use the global site variable
Just pass the page name as the argument
{{ with site.GetPage "workshops/bar" }}
{{ .Title }}
{{ end }}
I have read many docs, but failed to solve the problem:
Images in my existing project stored in $_SERVER['DOCUMENT_ROOT'].'/media/'
I want, but can't change in cakephp 2.4 default image folder from $_SERVER['DOCUMENT_ROOT'].'/app/webroot/img/' to any I desire.
lib/Cake/bootstrap.php contains constants:
/**
* Path to the public images directory.
*/
if (!defined('IMAGES')) {
define('IMAGES', WWW_ROOT . 'img' . DS);
}
/**
* Web path to the public images directory.
*/
if (!defined('IMAGES_URL')) {
define('IMAGES_URL', 'img/');
}
and
Configure::write('App.imageBaseUrl', IMAGES_URL);
I tried to change:
IMAGES to $_SERVER['DOCUMENT_ROOT'].'/media/'
IMAGES_URL to /
And it doesn't work at all. All image files still points to $_SERVER['DOCUMENT_ROOT'].'/app/webroot/img/' I see it when try to render image in view:
echo $this->Html->image('/img/ride_scheme/chema.jpg', array( 'width' => 300 ));
If I created in app/webroot/img/ride_scheme image file chema.jpg it rendered, but I changed the folder in IMAGES constant in lib/Cake/bootstrap.php !!!
In documentation I see:
Constants IMAGES_URL, JS_URL, CSS_URL have been deprecated and
replaced with config vari- ables App.imageBaseUrl, App.jsBaseUrl,
App.cssBaseUrl respectively.
Constants IMAGES, JS, CSS have been deprecated.
I gues that is the problem.
Please, show me how to change image folder
According to your description, I reckon IMAGES_URL should be media/ and not just /.
Alternatively, you could add a RewriteRule to your .htaccess (in the project root) to rewrite everything to the media folder (assuming you have an Apache web server with the Rewrite module enabled):
RewriteRule ^app/webroot/img/(.*) /media/$1
Or you could create a symbolic link that links the img/ folder to your media folder (assuming you're on Linux hosting and you have ssh/shell access to your server):
cd app/webroot
rm -rf img/
ln -s ../../media img