instead of writing the layout for every blog post, i wish to declare the default layout for the posts index, and a different one for the single blog post. in my config i have
defaults:
-
scope:
path: "blog"
values:
layout: "posts"
and this works fine for the blog index (the one with the excerpts). but once i click on an article, i want to have a different layout so i tried:
defaults:
-
scope:
path: "blog"
values:
layout: "posts"
-
scope:
path: "blog/_posts"
values:
layout: "blog-post"
but with no success. it still renders layout: "posts"
how can i fix this?
Path like "blog/_posts" will not match when setting defaults because "_posts" is a "magic folder".
But as your index.html is a page, you can use "scope type" and do :
defaults:
-
scope:
path: "blog"
type: "pages"
values:
layout: "posts"
-
scope:
path: "blog"
type: "posts"
values:
layout: "blog-post"
Related
At work we have a basic Docusaurus v2 page for user documentation, and I can't share it for privacy reasons. Suffice it to say it has a sidebar which is autogenerated, where the top level contains a number of folders as categories and each category only contains .md files.
At the top level (the level of the categories) there is an empty index.md file that only exists so that the page will load. The autogenerated sidebar includes an index entry that points to a blank page. I would like to hide/get rid of this entry.
I have looked at this github discussion on something similar, but I haven't been able to make the solutions work. The sidebar.js file has the following simple contents:
module.exports = {
docs: [
{
type: 'autogenerated',
dirName: '.'
},
],
};
I have tried adding an exclude: ['path\to\index\file'] line, but this results in the error "exclude" is not allowed.
What is the proper way of hiding this index entry from the sidebar? Alternatively, is there a way to set up the site so that the index.md file is not needed at all?
I have the same setup:
/folder1
/file
/folder2
/file
index
And I wand to autogenerate the sidebar with two categories only:
folder1
folder2
Moreover, I wanted to click on the navbar and see index.
I was able to do so by:
Create a custom sidebar
function skipIndex(items) {
return items.filter(({ type, id }) => {
return type !== 'doc' || id !== 'index';
});
}
module.exports = async function sidebarItemsGenerator({ defaultSidebarItemsGenerator, ...args }) {
const sidebarItems = await defaultSidebarItemsGenerator(args);
return skipIndex(sidebarItems);
}
Then in the docusaurus.config.js
presets: [
[
'classic',
({
// https://docusaurus.io/docs/api/plugins/#docusaurus/plugin-content-docs#configuration
docs: {
sidebarItemsGenerator: require('./sidebar.js'),
},
And finally in the index.md file I must add this metadata, otherwise when I reach the index page, the sidebar disappears because the page is not included:
---
displayed_sidebar: docsSidebar
---
I am trying to create a href to link user(provider) name with user(provider) account view.
I am far from expert in this - tried to copy a part of script from other place in the code where it refers to user(provider) account.
The place where I am trying to add link is:
= render partial: 'services/partials/messages/original_message', locals: { header: t('html.text.consultation_with.for_provider', name: #provider_user.name, type: t("element_names.#{#service.service_type}")),...
and the the part of script which was used to refer to user(provider) account looks like this:
[href="#{provider_path(provider)}" id="provider-#{provider.id}"]
So I tried combining those two:
= render partial: 'services/partials/messages/original_message', locals: { header: t('html.text.consultation_with.for_provider', name: [href="#{provider_path(provider)}" id="provider-#{provider.id}"], type: t("element_names.#{#service.service_type}")),...
And was not surprised that it did not worked..
You can't mix up slim element syntax (the one with square brackets, used by slim itself to create attributes of an element) with ruby code (the arguments to render, it's just a plain ruby method call!)
Maybe this would work for you, or some adaptation:
= render partial: 'services/partials/messages/original_message',
locals: {
header: t('html.text.consultation_with.for_provider',
name: #provider_user.name,
provider_link_href: provider_path(provider),
provider_link_id: "provider-#{provider.id}",
type: t("element_names.#{#service.service_type}")),
...
}
And then in the partial, use them like
a[href=provider_link_href id=provider_link_id]
Text of the link
I have a Series model which $hasMany RainLab\Blog\Models\Posts and when I display this model with 'type' => 'relation', in Posts form it looks perfectly fine:
So, I can select one Series and assign it to a Post. What I wanted to do is to be able to create new series while being on Posts page. To do this I tried to use 'type' => 'partial' for Series field. Partial itself contains just:
<?= $this->relationRender('series', ['readOnly' => false]) ?>
config_relation.yaml contents:
series:
label: Series
view:
list: $/plugin/models/series/columns.yaml
form: $/plugin/models/series/fields_simple.yaml
toolbarButtons: link|unlink|create|add|remove
manage:
form: $/plugin/models/series/fields_simple.yaml
columns.yaml contents:
# ===================================
# List Column Definitions
# ===================================
columns:
title:
label: Title
searchable: true
post_count:
label: Posts
sortable: false
created_at:
label: Created At
type: date
invisible: true
updated_at:
label: Updated At
type: date
invisible: true
fields_simple.yaml:
# ===================================
# Form Field Definitions
# ===================================
fields:
title:
label: Title
span: left
required: true
slug:
label: Slug
span: right
placeholder: Slug
required: true
preset:
field: title
type: slug
So, basically, nothing special here. But:
As you see, it looks terrible by default. And one more issue - when deleting the series (or unlinking, I tried both) it does not refresh the form, values remain there, though the relation is removed in DB.
Am I doing anything wrong here? What is the proper way to nicely display this relation with ability to edit it?
is it possible to setup a field which links to a specific content of multiple content types?
So assuming there are 3 predefined contenttype CA, CB, CC. I would like to setup an input field, which allows to link to any content of the contenttypes CA, CB, CC.
Does anybody know how to do this or what section of bolt needs to be extended?
Thanks a lot!
I found the following three ways to link to other pages but they are always a link to one contenttype only.
By selectentry
selectentry:
type: select
values: entries/id
postfix: "Select an entry"
autocomplete: true
sort: title
Single relation
relations:
entries:
multiple: false
label: "Choose an entry"
order: -id
format: "{{ item.title|escape }} <span>(№ {{ item.id }})</span>"
postfix: "By selecting an Entry, you're creating a bi-directional relationship to that Entry."
Multiple relations
relations:
pages:
multiple: true
order: title
label: Select zero or more pages
this is currently not possible to do in a clean way. You could add a few type: select fields, and then in your template use {% if %} statements to display the right thing.
Consider the following initialization of hierarchical routes (excerpt from the AngularDart tutorial):
router.root
..addRoute(
name: 'add',
path: '/add',
enter: view('view/addRecipe.html'))
..addRoute(
name: 'recipe',
path: '/recipe/:recipeId',
mount: (Route route) => route
..addRoute(
name: 'view',
path: '/view',
enter: view('view/viewRecipe.html'))
..addRoute(
name: 'edit',
path: '/edit',
enter: view('view/editRecipe.html'))
..addRoute(
name: 'view_default',
defaultRoute: true,
enter: (_) =>
router.go('view', {'recipeId': ':recipeId'},
startingFrom: route, replace:true)));
While I understand that a subroute's path will be unique (being constructed from the paths of its ancestors), is the route name namespace hierarchical too or must the names be unique?
It's required that the route names are unique for all direct children of a given parent.
OK:
foo
bar
baz
qux
foo
bar
baz
Not OK:
foo
bar
bar
In general it's recommended to have unique route names throughout, for better readability, although it's not a requirement.
When referencing a route, one must specify the full path of the route foo.bar.baz from the root, or provide a relative route anchor router.go('foo', parameters: {}, startingFrom: bar)
One place where non-unique route names can cause issues is with query parameters, as query parameters are prefixed with the route name (not the full path), and can cause leaking of values between routes with the same name (/foo?foo.param1=value). That said, query parameter support is a work-in-progress, so things might change.