Skip to main content

PageConfig

Struct PageConfig 

Source
pub struct PageConfig {
Show 15 fields pub source_path: String, pub title: Option<String>, pub canonical_url: Option<String>, pub description: Option<String>, pub lang: Option<String>, pub og_image: Option<String>, pub twitter_card: Option<String>, pub icons: Vec<HeadIcon>, pub stylesheets: Vec<String>, pub scripts: Vec<HeadScript>, pub theme_init: bool, pub theme_key: Option<String>, pub embed_css: bool, pub head_extra: Option<String>, pub reading_frame: Option<ReadingFrame>,
}
Expand description

Configuration for full-page HTML rendering with SurfDoc discovery metadata.

Fields§

§source_path: String

Path to the original .surf source file (served alongside the built site). Used in <link rel="alternate"> and the HTML comment.

§title: Option<String>

Page title. Falls back to front matter title, then “SurfDoc”.

§canonical_url: Option<String>

Optional canonical URL for <link rel="canonical">.

§description: Option<String>

Optional meta description. Falls back to front matter description.

§lang: Option<String>

Optional language code (default: “en”).

§og_image: Option<String>

Optional OG image URL for social sharing.

§twitter_card: Option<String>

Twitter card type: summary (default) or summary_large_image.

§icons: Vec<HeadIcon>

Favicon / apple-touch-icon links, emitted in order.

§stylesheets: Vec<String>

External stylesheet hrefs, emitted in order (after the inlined base CSS when embed_css is true). Cache-bust by including ?v=N in the href.

§scripts: Vec<HeadScript>

External scripts, emitted in <head> in order.

§theme_init: bool

Emit the inline pre-paint theme resolver + toggleTheme/toggleDrawer/ closeDrawer helpers in <head> (FOUC-safe; must run before paint).

§theme_key: Option<String>

localStorage key for the persisted theme. Defaults to theme.

§embed_css: bool

Inline the full SurfDoc CSS as a <style> block (default true). Set false when the consumer links the stylesheet itself (via stylesheets).

§head_extra: Option<String>

Arbitrary extra markup injected at the end of <head>.

§reading_frame: Option<ReadingFrame>

When set, to_shell_page wraps the page content in a reading-frame (sticky toolbar + centered sheet). None leaves pages unchanged.

Implementations§

Source§

impl PageConfig

Source

pub fn from_site_doc(doc: &SurfDoc) -> Self

Build a PageConfig whose head config is read from the document’s ::site block, so the page is self-describing. Recognised ::site properties:

  • description, og-image, twitter-card, lang, theme-key
  • canonical / url (canonical URL)
  • favicon (rel=icon, sizes=any), icon-16 / icon-32 (png), apple-touch-icon
  • stylesheet (repeatable), script / script-defer (repeatable)
  • theme-init: true, embed-css: false

Per-page fields (title, description, canonical_url) can still be overridden by the caller after construction.

Trait Implementations§

Source§

impl Clone for PageConfig

Source§

fn clone(&self) -> PageConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PageConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PageConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.