@wordpress/editor
Version:
Enhanced block editor for WordPress posts.
30 lines (27 loc) • 763 B
JavaScript
/**
* WordPress dependencies
*/
import { useSelect } from '@wordpress/data';
import { filterURLForDisplay, safeDecodeURIComponent } from '@wordpress/url';
/**
* Internal dependencies
*/
import { store as editorStore } from '../../store';
/**
* Represents a label component for a post URL.
*
* @return {Component} The PostURLLabel component.
*/
export default function PostURLLabel() {
return usePostURLLabel();
}
/**
* Custom hook to get the label for the post URL.
*
* @return {string} The filtered and decoded post URL label.
*/
export function usePostURLLabel() {
const postLink = useSelect(select => select(editorStore).getPermalink(), []);
return filterURLForDisplay(safeDecodeURIComponent(postLink));
}
//# sourceMappingURL=label.js.map