<commit_before>/**
 * 文章页
 */

'use strict';

import React from 'react';

import { BaseComponent } from '../components/base.jsx';
import { ArchiveExtract, Comment, ArchiveMenu } from '../components/archives.jsx';
import { Categories } from '../components/sidebar.jsx';


/**
 * Post Article
 */
export class Post extends BaseComponent {
    constructor(props, context) {
        super(props, context);
        this.state = {
            post: null,
            hint: '载入中...'
        };
    }

    componentDidMount() {
        $.getJSON({
            url: `/api/v2/post/${this.props.params.pid}/`,
            method: 'GET',
            dataType: 'json'
        })
            .done((resp) => {
                document.title = 'laisky-blog: ' + resp.result.post_title;
                if(resp.result['post_type'] == 'slide') this.loadRevealJs();
                resp.result.post_content = this.convertImg2Webp(resp.result.post_content);
                $(document.body).animate({scrollTop: 0}, 200);
                this.setState({
                    post: resp.result,
                    hint: null
                });

                $('#post').scrollspy({target: '#archive-menu'});
            })
            .fail(() => {
                this.setState({hint: '读取数据失败，请刷新重试'});
            });
    }<commit_msg>fix: scrollspy<commit_after>/**
 * 文章页
 */

'use strict';

import React from 'react';

import { BaseComponent } from '../components/base.jsx';
import { ArchiveExtract, Comment, ArchiveMenu } from '../components/archives.jsx';
import { Categories } from '../components/sidebar.jsx';


/**
 * Post Article
 */
export class Post extends BaseComponent {
    constructor(props, context) {
        super(props, context);
        this.state = {
            post: null,
            hint: '载入中...'
        };
    }

    componentDidMount() {
        $.getJSON({
            url: `/api/v2/post/${this.props.params.pid}/`,
            method: 'GET',
            dataType: 'json'
        })
            .done((resp) => {
                document.title = 'laisky-blog: ' + resp.result.post_title;
                if(resp.result['post_type'] == 'slide') this.loadRevealJs();
                resp.result.post_content = this.convertImg2Webp(resp.result.post_content);
                $(document.body).animate({scrollTop: 0}, 200);
                this.setState({
                    post: resp.result,
                    hint: null
                });

                $('body').scrollspy({target: '#archive-menu'});
            })
            .fail(() => {
                this.setState({hint: '读取数据失败，请刷新重试'});
            });
    }
{'fraction_non_alphanumeric': 0.15921152388172857, 'fraction_numerical': 0.004548900682335102, 'mean_word_length': 1.6656565656565656, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4725552', 'n_tokens_mistral': 792, 'n_tokens_neox': 775, 'n_words': 137}