mirror of
https://gh.wpcy.net/https://github.com/elementor/hello-theme.git
synced 2026-04-28 12:22:20 +08:00
27 lines
599 B
TypeScript
27 lines
599 B
TypeScript
import fs from 'fs';
|
|
import path from 'path';
|
|
|
|
// File to store page URL
|
|
const urlStorePath = path.join( __dirname, '..', 'temp-form-page-url.txt' );
|
|
|
|
/**
|
|
* Gets the page URL from the file storage
|
|
*
|
|
* @return {string} The stored page URL or empty string if not found
|
|
*/
|
|
export const getPageUrl = (): string => {
|
|
try {
|
|
return fs.readFileSync( urlStorePath, 'utf8' );
|
|
} catch ( e ) {
|
|
return '';
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Saves a page URL to the file storage
|
|
*
|
|
* @param {string} url - The URL to save
|
|
*/
|
|
export const savePageUrl = ( url: string ): void => {
|
|
fs.writeFileSync( urlStorePath, url );
|
|
};
|