create structure if not exist
This commit is contained in:
@ -105,7 +105,12 @@ export default PDFViewerPage;
|
|||||||
|
|
||||||
|
|
||||||
export const getServerSideProps = async (context) => {
|
export const getServerSideProps = async (context) => {
|
||||||
const permitsFolder = '/public/content/permits/';
|
const permitsFolder = path.join(process.cwd(), 'public', 'content', 'permits');
|
||||||
|
|
||||||
|
// Create folders if they do not exist
|
||||||
|
if (!fs.existsSync(permitsFolder)) {
|
||||||
|
fs.mkdirSync(permitsFolder, { recursive: true });
|
||||||
|
}
|
||||||
//get all the files in the permits folder order them by date desc and display them
|
//get all the files in the permits folder order them by date desc and display them
|
||||||
const pdfFiles = fs.readdirSync(path.join(process.cwd(), permitsFolder)).map(file => {
|
const pdfFiles = fs.readdirSync(path.join(process.cwd(), permitsFolder)).map(file => {
|
||||||
return {
|
return {
|
||||||
|
Reference in New Issue
Block a user