Commit 9d5243bc authored by El Oualydy Salma's avatar El Oualydy Salma Committed by Pierre-Alain Jachiet

Ordre alphabétique de la barre latérale de navigation

parent 3287b198
const fs = require('fs');
function listMarkdownFilesInDirectory(directoryName) {
return fs
.readdirSync('./' + directoryName)
.sort(function (a, b) {
return a.toLowerCase().localeCompare(b.toLowerCase());
})
.filter(function (filename) {
return filename !== 'README.md';
})
.filter(function (filename) {
return filename.slice(-3) === '.md';
})
.map(function (filename) {
return '/' + directoryName + '/' + filename.slice(0, -3);
});
}
function listSubDirectories(directoryName) {
return fs
.readdirSync('./' + directoryName)
.filter(function (filename) {
return fs.lstatSync('./' + directoryName + '/' + filename).isDirectory();
})
}
function getSidebarGroup(directoryPath) {
const lastDirectory = directoryPath.split("/").pop();
const sidebarGroup = {};
sidebarGroup["title"] = lastDirectory.charAt(0).toUpperCase() + lastDirectory.slice(1);
if (fs.existsSync('./' + directoryPath + '/README.md')) {
sidebarGroup["path"] = '/' + directoryPath + '/';
}
const children = [];
for (subDirectory of listSubDirectories(directoryPath)) {
children.push(getSidebarGroup(directoryPath + '/' + subDirectory));
}
sidebarGroup["children"] = children.concat(listMarkdownFilesInDirectory(directoryPath));
return sidebarGroup
}
const sb = require('./sidebar');
const sidebar = [
getSidebarGroup("introduction"),
getSidebarGroup("fiches"),
getSidebarGroup("glossaire"),
getSidebarGroup("ressources"),
getSidebarGroup("tables"),
{
title: 'Introduction',
path: '/introduction/',
children: [
'/introduction/01-snds',
'/introduction/02-bases-snds',
'/introduction/03-acces-snds',
'/introduction/04-recherche-snds'
]
},
sb.getSidebarGroup("fiches"),
sb.getSidebarGroup("glossaire"),
sb.getSidebarGroup("ressources"),
sb.getSidebarGroup("tables"),
{
title: 'Contribuer',
path: '/contribuer/',
......@@ -80,7 +45,7 @@ module.exports = {
{text: 'Groupe Meetup', link: 'https://www.meetup.com/fr-FR/Health-Data-Hub/'},
],
sidebar: sidebar,
sidebarDepth: 1,
sidebarDepth: 0,
lastUpdated: 'Dernière mise à jour',
algolia: {
apiKey: 'b1d88a4e2413821b4ebe7441ecc95a97',
......@@ -97,4 +62,4 @@ module.exports = {
md.use(require('markdown-it-footnote'))
}
}
};
};
\ No newline at end of file
const fs = require('fs');
/**
* returns the title of a file
* @param {*} directory
* @param {*} filename
*/
function getMarkdownTitle(directory, filename){
var text = fs.readFileSync(directory + '/' + filename);
//returns the first line of the text
var header= text.toString().split('\n').shift()
/*
applies the following transformation
'# Les actes et consultations externes' -> 'les actes et consultations externes'
*/
.slice(1).toLowerCase().trim();
return header
}
/**
* List .md filenames in a directory
* @param {*} directoryName
*/
function listMarkdownFilesInDirectory(directoryName) {
return fs
// returns an array of all the filenames in a directory
.readdirSync('./' + directoryName)
// returns all filenames except README.md
.filter(function (filename) {
return filename !== 'README.md';
})
//returns only filenames that have an .md extension
.filter(function (filename) {
return filename.slice(-3) === '.md';
})
// returns a case insensitive sorting between file titles
.sort(function (a, b) {
return getMarkdownTitle(directoryName, a)
.localeCompare(getMarkdownTitle(directoryName, b));
})
//returns a new array with a transformation on filenames (adding the directory name)
.map(function (filename) {
return '/' + directoryName + '/' + filename.slice(0, -3);
});
}
/**
* list subdirectories in a directory
* @param {*} directoryName
*/
function listSubDirectories(directoryName) {
return fs
// returns an array of all the filenames in a directory
.readdirSync('./' + directoryName)
//returns only the directories
.filter(function (filename) {
return fs.lstatSync('./' + directoryName + '/' + filename).isDirectory();
})
}
/**
* Creates a sidebar group for a given directory
* @param {*} directoryPath
*/
const getSidebarGroup = function (directoryPath) {
const lastDirectory = directoryPath.split("/").pop();
const sidebarGroup = {};
sidebarGroup["title"] = lastDirectory.charAt(0).toUpperCase() + lastDirectory.slice(1);
// checks if it contains a README file
if (fs.existsSync('./' + directoryPath + '/README.md')) {
sidebarGroup["path"] = '/' + directoryPath + '/';
}
const children = [];
for (subDirectory of listSubDirectories(directoryPath)) {
// recursive call for subdirectories
children.push(getSidebarGroup(directoryPath + '/' + subDirectory));
}
sidebarGroup["children"] = children.concat(listMarkdownFilesInDirectory(directoryPath));
// console.log(sidebarGroup["children"])
return sidebarGroup
}
exports.getSidebarGroup = getSidebarGroup;
\ No newline at end of file
# Les actes et consultations externes
# Actes et consultations externes
## Que regroupent les actes et consultations externes ?
......
# Les dépenses de soins de ville dans le DCIR et le DAMIR
# Dépenses de soins de ville dans le DCIR et le DAMIR
<!-- SPDX-License-Identifier: MPL-2.0 -->
## DCIR
......
# Les publics précaires
# Publics précaires
<!-- SPDX-License-Identifier: MPL-2.0 -->
L'objectif de cette fiche est de décrire comment repérer les publics précaires dans le SNDS.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment