docusaurus autogenerated sidebar displaying category index pages as separate pages instead - docusaurus

According to the Category index convention docs you should be able to add a category index page for the index within an autogenerated section.
A category index document is a document following one of those filename conventions:
Named as index (case-insensitive): docs/Guides/index.md
Named as README (case-insensitive): docs/Guides/README.mdx
Same name as parent folder: docs/Guides/Guides.md
This works currently but the category indexes aren't working, so this file structure:
foo/
foo.md
foo-bar.md
is not making the foo.md an index page for foo but just another sub page.
It should look like this on the website
foo/ <-- `foo.md` gets displayed here as category index
foo-bar
but it's compiling as this
foo/
foo <-- isn't recognized as a category index but another page
foo-bar
What am I doing wrong?
Stuff I've tried:
using docs/Guides/index.md format
using docs/Guides/README.mdx format
using docs/Guides/Guides.md format
I would have expected one of these to automatically link one of those pages as a category index page
The foo.md also have front matter that I've tried to alter:
foo.md:
---
title: foo
id: foo
---
I've also tried to remove the front matter entirely and it has not worked.

In the sidebars.js file, specify the id of the MD file that you wish to serve as the category index page.
For example:
module.exports = {
training: [
'intro',
{
type: 'category',
label: 'Category Index Page',
link: {
type: 'doc',
id: 'category-index-page' // This is the id of the index page.
},

Related

Nuxt routing double optional params

I have nuxt app. I want to create path like this:
path: '/dworzec-pkp/:slug/:category?/:date?',
So there would be two optional params. Example urls would be:
localhost:5555/dworzec-pkp/nowa-iwiczna <-- w/o optional params
localhost:5555/dworzec-pkp/nowa-iwiczna/12-10-2020 <-- optional param: date
localhost:5555/dworzec-pkp/nowa-iwiczna/departures <-- optional param: category
localhost:5555/dworzec-pkp/nowa-iwiczna/departures/12-10-2020 <-- optional params: date & category
How do I know if url contain category or date? Should I create just directories dworzec-pkp/_slug and within it _.vue file, and then programmatically decide whether it is date or category? Or maybe there's some better solution for that?
Currently I tried like this:
and my issue is that when i enter this localhost:5555/dworzec-pkp/nowa-iwiczna/12-10-2020 then it is treated as :category?. Also I would need to basically almost copy-paste entire _date.vue and index.vue there as this pages are almost same.

Add a new blog entry in Docusaurus V2

I'm building a website with Docusaurus V2.
There are already 3 blog entries in the initial project. I want to add another one. I created a file 4th.mdx in the blog folder. Then added the following content:
---
id: 4th
title: Hello
author: Endilie Yacop Sucipto
authorTitle: Maintainer of Docusaurus
authorURL: https://github.com/endiliey
authorImageURL: https://avatars1.githubusercontent.com/u/17883920?s=460&v=4
authorTwitter: endiliey
tags: [hello, docusaurus]
---
Then, I guess I need to put the id 4th somewhere in other files, right? Does anyone know where I should put that?
Blog files are read from the blog directory and its id does not need to be added somewhere else. Are you not seeing the new entry even after creating the 4th file?

How do I force Pelican to suppress generation of category files?

I don't want Pelican 3.6 to generate:
/author/
/category/
/tag/
/archives.html
/authors.html
/categories.html
/tags.html
DIRECT_TEMPLATES can be set to suppress some of the index files:-
# DIRECT_TEMPLATES = ['index', 'categories', 'authors', 'archives']
DIRECT_TEMPLATES = ['index']
Omitting tag metadata in source content files will prevent generation of the tag folder and index; omitting author metadata and the AUTHOR setting will prevent generation of the author folder and index.
But it seems that suppressing category isn't so simple. I've tried setting DEFAULT_CATEGORY to an empty string, but this results in errors and no output for sources with no category metadata:-
Skipping <some_file>: could not find information about 'NameError: category'
I've also tried removing the relevant template files from the theme being used, but this merely causes them to be replaced with the matching template in the built-in "simple" theme.
Am I missing an established method of suppressing category generation?
The URL settings documentation has a long list of settings, including several […]_SAVE_AS settings. Directly below the URL settings table is a note that answers your question: for any page type that you do not want generated, set the corresponding […]_SAVE_AS setting to ''. For example, to suppress individual category page generation, add this setting:
CATEGORY_SAVE_AS = ''

How to add additional variables in yii url

I'm working with Yii framework and i'm trying to implement "create pdf" button on all sorts of different url's.
My first plan was to simply add variable to url where "create pdf" button links:
'url' => Yii::app()->request->getUrl().'&pdf=true',
And it works fine on all links except when i enter directly to site like: www.example.com. In that case there is no index.php in url so button link is unusable as it looks like this:
www.example.com/&pdf=true
Is there Yii way to append variables to url or I need to do manual checks?
create your links like this :
Yii::app()->createUrl('controllerName/actionName', array('number' => 2, 'name'=>'john'));
//or this if you want it with http:://
Yii::app()->createAbsoluteUrl('controllerName/actionName', array('number' => 2, 'name'=>'john'));
you can add your parameter(s) to the original parameters with the CMap::mergeArray($_GET, array('pdf' => 'true'))
and use the Yii::app()->createUrl or your Controller's createUrl function:
http://www.yiiframework.com/doc/api/1.1/CApplication#createUrl-detail
http://www.yiiframework.com/doc/api/1.1/CController#createUrl-detail

How do Media Views work in cakephp?

I have arranged a file upload to happen on my application relative address: webroot/files
Now I need to force download on the uploaded files. After some googling and trying like most of the suggestions from this post I figured out the correct way to do this is using cakephps Media Views
What I have:
Main site with a table of records. Model -> Record; Table -> records;
These records have a primary key record_id.
In my database I have a Table -> files; Model -> File;
These files have a foreign key record_id and a field 'url' with the relative path to it's location.
After creating a record with files, the files are correctly uploaded to the folder, which relative address is e.g. webroot/files/record_name/file and the tables in database are correctly updated.
What I want to do:
After doubleclicking on one table row open a modal dialog with the information about the record. (done)
In this modal dialog I want to display links that will force download on these files.
I tried many variations of this:
//the retrieving of data after debug looks fine//
$this->loadModel('File');
$files = $this->File->find('list', array(
'conditions'=>array('File.record_id'=>$record_id),
'fields' => array('File.Name', 'File.Url');
))
//actual display of url
foreach($files as $file_name => $file_url) {
echo $this->Html->link($file_name, $file_url);
}
The resulting link looks exactly the way James Revillini presented
This is my actual question
Since that issue was not entirely solved, I thought it would be helpful not only for me, but for anybody who's searching for a quick solution for this problem to see a quick demonstration of how Media-views work. I have no idea where to move after making a dynamic download function:
public function download($name, $path) {
$this->viewClass = 'Media';
$params = array(
'id' => $name,
'name' => $name,
'download' => true,
'path' => $path
);
$this->set($params);
}
Point the link in the modal dialog for the resource to the download() function.
Pass the Record.id to that function. In it find the file and auto-render it.
It should work.