None

Config class

Config source


        class Config(BaseModel):
            subroute: Path = Path("")

SubroutePost class

SubroutePost source


        class SubroutePost(BaseModel):
            markata: Any = Field(None, exclude=True)
            model_config = ConfigDict(validate_assignment=True, arbitrary_types_allowed=True)

            @pydantic.validator("slug")
            @classmethod
            def relative_to_subroute(cls, v, *, values: Dict) -> Path:
                subroute = cls.markata.config.subroute
                if subroute == Path(""):
                    return v

                slug = Path(v)

                if not slug.relative_to(subroute):
                    return slug.parent / subroute / slug.stem
                return v

config_model function

config_model source


        def config_model(markata: "Markata") -> None:
            markata.config_models.append(Config)

post_model function

post_model source


        def post_model(markata: Markdown) -> None:
            markata.post_models.append(SubroutePost)

relative_to_subroute method

relative_to_subroute source


        def relative_to_subroute(cls, v, *, values: Dict) -> Path:
                subroute = cls.markata.config.subroute
                if subroute == Path(""):
                    return v

                slug = Path(v)

                if not slug.relative_to(subroute):
                    return slug.parent / subroute / slug.stem
                return v